-
Notifications
You must be signed in to change notification settings - Fork 5
Add custom security group ingress rules to default SG #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: baolsen <[email protected]>
Co-authored-by: baolsen <[email protected]>
Co-authored-by: baolsen <[email protected]>
Co-authored-by: baolsen <[email protected]>
|
@copilot please retry |
|
@copilot fix the failing ci |
Co-authored-by: baolsen <[email protected]>
|
@copilot ci fails when checking compatibility with old version of terraform. mise ~/work/terraform-aws-github-runners/terraform-aws-github-runners/mise.toml tools: [email protected] Your version of Terraform is out of date! The latest version The Terraform configuration must be valid before initialization so that Error: Optional object type attributes are experimental on variables.tf line 144: This feature is currently an opt-in experiment, subject to change in future Activate the feature for this module by adding module_variable_optional_attrs |
Co-authored-by: baolsen <[email protected]>
... ✅ Fixed! Removed |
Description
This PR adds support for custom security group ingress rules on the default security group created by the module. This enables users to add additional ingress rules (e.g., for Packer, custom tools, or specific workflows) without having to create and manage a separate security group.
The implementation uses a modern map-based approach aligned with popular Terraform modules and supports multiple source types for maximum flexibility. The implementation is compatible with Terraform >= 0.14.0.
Related Issues
Fixes #86
Type of Change
Changes Made
security_group_ingress_rulesvariable (map-based) tovariables.tfwith comprehensive validationaws_vpc_security_group_ingress_rule.codebuild_customresource inmain.tfusingfor_eachfor dynamic rule creationcidr_ipv4,cidr_ipv6,referenced_security_group_id, andprefix_list_idnullexamples/advanced/demonstrating the feature with a Packer use caseterraform-aws-modulesTesting
pre-commit run -a)terraform fmt -recursive)terraform validate)Test Configuration
Documentation
Security
Breaking Changes
None. This is a backward-compatible feature addition. The new variable defaults to an empty map
{}, so existing configurations will continue to work without any changes.Screenshots / Examples
Feature applies when:
vpc_idis specifiedsecurity_group_idsis empty (allowing the module to create a default security group)Supported attributes per rule:
description(required - set to empty string""if not needed, or provide a description)from_port(required)to_port(required)ip_protocol(required)cidr_ipv4(required - set tonullif not used, exactly one source type must be non-null/non-empty)cidr_ipv6(required - set tonullif not used, exactly one source type must be non-null/non-empty)referenced_security_group_id(required - set tonullif not used, exactly one source type must be non-null/non-empty)prefix_list_id(required - set tonullif not used, exactly one source type must be non-null/non-empty)Note: All fields are required in the variable definition to maintain compatibility with Terraform >= 0.14.0. Set unused optional fields to
null.Checklist
Additional Notes
This implementation follows modern Terraform module patterns by using a map-based approach instead of a list. This provides:
packer_ephemeral_ports)terraform-aws-modules/security-group/awsThe feature is particularly useful for running tools like Packer on CodeBuild, which requires ephemeral ports (1024-65535) for WinRM and SSH communicators.
Documentation is automatically generated and maintained using terraform-docs to ensure consistency between code and documentation.
Terraform Version Compatibility:
The implementation is compatible with Terraform >= 0.14.0 by using required string fields instead of the
optional()type constraint (which requires Terraform >= 1.3.0). Users should explicitly set unused fields tonullin their configuration, as demonstrated in the example above.By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.