{"id":51410873,"url":"https://github.com/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule","last_synced_at":"2026-07-04T14:32:34.292Z","repository":{"id":345588659,"uuid":"1084538214","full_name":"launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule","owner":"launchbynttdata","description":null,"archived":false,"fork":false,"pushed_at":"2026-04-02T18:56:15.000Z","size":149,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-03T02:36:53.038Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/launchbynttdata.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-27T20:17:34.000Z","updated_at":"2026-04-02T18:56:10.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule","commit_stats":null,"previous_names":["launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchbynttdata%2Ftf-aws-module_primitive-vpc_security_group_egress_rule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchbynttdata%2Ftf-aws-module_primitive-vpc_security_group_egress_rule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchbynttdata%2Ftf-aws-module_primitive-vpc_security_group_egress_rule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchbynttdata%2Ftf-aws-module_primitive-vpc_security_group_egress_rule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/launchbynttdata","download_url":"https://codeload.github.com/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchbynttdata%2Ftf-aws-module_primitive-vpc_security_group_egress_rule/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35125718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-04T02:00:05.987Z","response_time":113,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-04T14:32:32.906Z","updated_at":"2026-07-04T14:32:34.276Z","avatar_url":"https://github.com/launchbynttdata.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tf-aws-module_primitive-vpc_security_group_egress_rule\n\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Tests](https://github.com/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule/actions/workflows/tests.yml/badge.svg)](https://github.com/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule/actions/workflows/tests.yml)\n[![Static Analysis](https://github.com/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule/actions/workflows/static-analysis.yml)\n\n## Overview\n\nThis Terraform primitive module manages a single AWS VPC security group **egress rule**. It provides a lightweight wrapper around the [`aws_vpc_security_group_egress_rule`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_security_group_egress_rule) resource with sensible defaults and basic validation.\n\n## Features\n\n- **Single egress rule management** - Creates and manages one security group egress rule\n- **Multiple destination types** - Supports IPv4/IPv6 CIDR blocks, prefix lists, and security group references\n- **Protocol flexibility** - Handles TCP, UDP, ICMP, and custom protocols\n- **Lightweight validation** - Basic input validation with clear error messages\n- **Terraform 1.5+ compatibility** - Uses modern validation patterns and check blocks\n\n## Usage\n\n### Basic IPv4 CIDR Example\n\n```hcl\nmodule \"ssh_egress\" {\n  source = \"git::https://github.com/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule.git?ref=1.0.0\"\n\n  security_group_id = aws_security_group.app.id\n  ip_protocol       = \"tcp\"\n  from_port         = 22\n  to_port           = 22\n  cidr_ipv4         = \"10.0.1.0/24\"\n  description       = \"Allow SSH to management subnet\"\n}\n```\n\n### IPv6 CIDR Example\n\n```hcl\nmodule \"https_egress_ipv6\" {\n  source = \"git::https://github.com/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule.git?ref=1.0.0\"\n\n  security_group_id = aws_security_group.web.id\n  ip_protocol       = \"tcp\"\n  from_port         = 443\n  to_port           = 443\n  cidr_ipv6         = \"::/0\"\n  description       = \"Allow HTTPS to anywhere IPv6\"\n}\n```\n\n### Prefix List Example\n\n```hcl\nmodule \"s3_egress\" {\n  source = \"git::https://github.com/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule.git?ref=1.0.0\"\n\n  security_group_id = aws_security_group.app.id\n  ip_protocol       = \"tcp\"\n  from_port         = 443\n  to_port           = 443\n  prefix_list_id    = data.aws_ec2_managed_prefix_list.s3.id\n  description       = \"Allow HTTPS to S3\"\n}\n```\n\n### Security Group to Security Group Example\n\n```hcl\nmodule \"database_egress\" {\n  source = \"git::https://github.com/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule.git?ref=1.0.0\"\n\n  security_group_id            = aws_security_group.app.id\n  ip_protocol                  = \"tcp\"\n  from_port                    = 5432\n  to_port                      = 5432\n  referenced_security_group_id = aws_security_group.database.id\n  description                  = \"Allow PostgreSQL to database tier\"\n}\n```\n\n### ICMP Example\n\n```hcl\nmodule \"icmp_egress\" {\n  source = \"git::https://github.com/launchbynttdata/tf-aws-module_primitive-vpc_security_group_egress_rule.git?ref=1.0.0\"\n\n  security_group_id = aws_security_group.app.id\n  ip_protocol       = \"icmp\"\n  from_port         = -1\n  to_port           = -1\n  cidr_ipv4         = \"10.0.0.0/8\"\n  description       = \"Allow ICMP to private networks\"\n}\n```\n\n## Examples\n\nThe module includes comprehensive examples demonstrating various use cases:\n\n- **[complete](examples/complete/)** - Multiple egress rules with different configurations\n- **[minimal](examples/minimal/)** - Simplest possible configuration\n- **[simple](examples/simple/)** - Basic example used for integration testing\n- **[ipv6](examples/ipv6/)** - IPv6 CIDR blocks demonstration\n- **[prefix_list](examples/prefix_list/)** - AWS managed prefix list usage\n- **[sg_to_sg](examples/sg_to_sg/)** - Security group to security group references\n\nEach example is runnable and includes:\n- Complete Terraform configuration\n- Sample `test.tfvars` file\n- Documentation and usage instructions\n\n## Validation Rules\n\nThe module enforces several validation rules to ensure proper configuration:\n\n1. **Exactly one destination** - Must specify exactly one of: `cidr_ipv4`, `cidr_ipv6`, `prefix_list_id`, or `referenced_security_group_id`\n2. **Protocol-port relationship** - TCP and UDP protocols require both `from_port` and `to_port`\n3. **Port range validity** - `from_port` must be less than or equal to `to_port`\n4. **Valid port numbers** - Ports must be between 1 and 65535 (or -1 for ICMP)\n\n## Testing\n\n### Prerequisites\n\n```bash\n# Install required tools\nmake configure\npre-commit install\n```\n\n### Local Testing\n\n```bash\n# Run all quality checks\nmake check\n\n# Individual checks\nmake fmt       # Format code\nmake validate  # Validate syntax\nmake lint      # Static analysis\nmake test      # Unit tests\n```\n\n### Integration Testing\n\n```bash\n# Run integration tests on all examples\nmake integration-test\n\n# Test specific example\ncd examples/simple\nterraform init\nterraform plan -var-file=test.tfvars\nterraform apply -var-file=test.tfvars\nterraform destroy -var-file=test.tfvars\n```\n\n## Requirements\n\n| Name | Version |\n|------|---------|\n| terraform | ~\u003e 1.5.0 |\n| aws | ~\u003e 5.100.0 |\n\n## Providers\n\n| Name | Version |\n|------|---------|\n| aws | ~\u003e 5.100.0 |\n\n## Resources\n\n| Name | Type |\n|------|------|\n| [aws_vpc_security_group_egress_rule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_security_group_egress_rule) | resource |\n\n## Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| security_group_id | The ID of the security group to which this egress rule will be attached. | `string` | n/a | yes |\n| ip_protocol | The IP protocol name or number. Use '-1' to specify all protocols. Protocol numbers: https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml | `string` | n/a | yes |\n| from_port | The start of port range for the TCP and UDP protocols, or an ICMP type number. Required for tcp and udp protocols. Use -1 for ICMP type. | `number` | `null` | no |\n| to_port | The end of port range for the TCP and UDP protocols, or an ICMP code. Required for tcp and udp protocols. Use -1 for ICMP code. | `number` | `null` | no |\n| cidr_ipv4 | The destination IPv4 CIDR range for this egress rule. Mutually exclusive with cidr_ipv6, prefix_list_id, and referenced_security_group_id. | `string` | `null` | no |\n| cidr_ipv6 | The destination IPv6 CIDR range for this egress rule. Mutually exclusive with cidr_ipv4, prefix_list_id, and referenced_security_group_id. | `string` | `null` | no |\n| prefix_list_id | The ID of the prefix list for the destination of this egress rule. Mutually exclusive with cidr_ipv4, cidr_ipv6, and referenced_security_group_id. | `string` | `null` | no |\n| referenced_security_group_id | The ID of the destination security group for this egress rule. Mutually exclusive with cidr_ipv4, cidr_ipv6, and prefix_list_id. | `string` | `null` | no |\n| description | The description of this egress rule. | `string` | `null` | no |\n| tags | A map of tags to assign to the egress rule. | `map(string)` | `{}` | no |\n\n## Outputs\n\n| Name | Description |\n|------|-------------|\n| id | The Terraform resource ID of the security group egress rule. |\n| security_group_rule_id | The AWS-assigned unique identifier for the security group rule. |\n| security_group_id | The ID of the security group to which this egress rule is attached. |\n| egress_rule_effective_source | A canonical string describing the effective destination for this egress rule (CIDR, prefix list, or security group). |\n| arn | The ARN of the security group rule. |\n| tags_all | A map of tags assigned to the resource, including those inherited from the provider default_tags. |\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for information on contributing to this module.\n\n## License\n\nLicensed under the Apache License, Version 2.0 (the \"License\").\n\nYou may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0).\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\n\u003c!-- BEGIN_TF_DOCS --\u003e\n## Requirements\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"requirement_terraform\"\u003e\u003c/a\u003e [terraform](#requirement\\_terraform) | ~\u003e 1.0 |\n| \u003ca name=\"requirement_aws\"\u003e\u003c/a\u003e [aws](#requirement\\_aws) | ~\u003e 5.100 |\n\n## Providers\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"provider_aws\"\u003e\u003c/a\u003e [aws](#provider\\_aws) | 5.100.0 |\n\n## Modules\n\nNo modules.\n\n## Resources\n\n| Name | Type |\n|------|------|\n| [aws_vpc_security_group_egress_rule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_security_group_egress_rule) | resource |\n\n## Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| \u003ca name=\"input_security_group_id\"\u003e\u003c/a\u003e [security\\_group\\_id](#input\\_security\\_group\\_id) | The ID of the security group to which this egress rule will be attached. | `string` | n/a | yes |\n| \u003ca name=\"input_ip_protocol\"\u003e\u003c/a\u003e [ip\\_protocol](#input\\_ip\\_protocol) | The IP protocol name or number. Use '-1' to specify all protocols. Protocol numbers: https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml | `string` | n/a | yes |\n| \u003ca name=\"input_from_port\"\u003e\u003c/a\u003e [from\\_port](#input\\_from\\_port) | The start of port range for the TCP and UDP protocols, or an ICMP type number. Required for tcp and udp protocols. Use -1 for ICMP type. | `number` | `null` | no |\n| \u003ca name=\"input_to_port\"\u003e\u003c/a\u003e [to\\_port](#input\\_to\\_port) | The end of port range for the TCP and UDP protocols, or an ICMP code. Required for tcp and udp protocols. Use -1 for ICMP code. | `number` | `null` | no |\n| \u003ca name=\"input_cidr_ipv4\"\u003e\u003c/a\u003e [cidr\\_ipv4](#input\\_cidr\\_ipv4) | The destination IPv4 CIDR range for this egress rule. Mutually exclusive with cidr\\_ipv6, prefix\\_list\\_id, and referenced\\_security\\_group\\_id. | `string` | `null` | no |\n| \u003ca name=\"input_cidr_ipv6\"\u003e\u003c/a\u003e [cidr\\_ipv6](#input\\_cidr\\_ipv6) | The destination IPv6 CIDR range for this egress rule. Mutually exclusive with cidr\\_ipv4, prefix\\_list\\_id, and referenced\\_security\\_group\\_id. | `string` | `null` | no |\n| \u003ca name=\"input_prefix_list_id\"\u003e\u003c/a\u003e [prefix\\_list\\_id](#input\\_prefix\\_list\\_id) | The ID of the prefix list for the destination of this egress rule. Mutually exclusive with cidr\\_ipv4, cidr\\_ipv6, and referenced\\_security\\_group\\_id. | `string` | `null` | no |\n| \u003ca name=\"input_referenced_security_group_id\"\u003e\u003c/a\u003e [referenced\\_security\\_group\\_id](#input\\_referenced\\_security\\_group\\_id) | The ID of the destination security group for this egress rule. Mutually exclusive with cidr\\_ipv4, cidr\\_ipv6, and prefix\\_list\\_id. | `string` | `null` | no |\n| \u003ca name=\"input_description\"\u003e\u003c/a\u003e [description](#input\\_description) | The description of this egress rule. | `string` | `null` | no |\n| \u003ca name=\"input_tags\"\u003e\u003c/a\u003e [tags](#input\\_tags) | A map of tags to assign to the egress rule. | `map(string)` | `{}` | no |\n\n## Outputs\n\n| Name | Description |\n|------|-------------|\n| \u003ca name=\"output_id\"\u003e\u003c/a\u003e [id](#output\\_id) | The Terraform resource ID of the security group egress rule. |\n| \u003ca name=\"output_security_group_rule_id\"\u003e\u003c/a\u003e [security\\_group\\_rule\\_id](#output\\_security\\_group\\_rule\\_id) | The AWS-assigned unique identifier for the security group rule. |\n| \u003ca name=\"output_security_group_id\"\u003e\u003c/a\u003e [security\\_group\\_id](#output\\_security\\_group\\_id) | The ID of the security group to which this egress rule is attached. |\n| \u003ca name=\"output_egress_rule_effective_source\"\u003e\u003c/a\u003e [egress\\_rule\\_effective\\_source](#output\\_egress\\_rule\\_effective\\_source) | A canonical string describing the effective destination for this egress rule (CIDR, prefix list, or security group). |\n| \u003ca name=\"output_arn\"\u003e\u003c/a\u003e [arn](#output\\_arn) | The ARN of the security group rule. |\n| \u003ca name=\"output_tags_all\"\u003e\u003c/a\u003e [tags\\_all](#output\\_tags\\_all) | A map of tags assigned to the resource, including those inherited from the provider default\\_tags. |\n\u003c!-- END_TF_DOCS --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchbynttdata%2Ftf-aws-module_primitive-vpc_security_group_egress_rule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaunchbynttdata%2Ftf-aws-module_primitive-vpc_security_group_egress_rule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchbynttdata%2Ftf-aws-module_primitive-vpc_security_group_egress_rule/lists"}