Skip to content
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

resource/aws_security_group: Use default VPC when no VPC ID passed #26697

Merged
merged 3 commits into from Sep 8, 2022

Conversation

gdavison
Copy link
Contributor

@gdavison gdavison commented Sep 7, 2022

When no vpc_id is passed to aws_security_group, use the default VPC to match the behaviour of the AWS API.

Relates #26525
Relates #26666
Relates #23625

Output from acceptance testing:

$ make testacc PKG=ec2 TESTS=TestAccVPCSecurityGroup_

--- PASS: TestAccVPCSecurityGroup_invalidCIDRBlock (9.83s)
--- PASS: TestAccVPCSecurityGroup_namePrefix (88.38s)
--- PASS: TestAccVPCSecurityGroup_ipv6 (90.89s)
--- PASS: TestAccVPCSecurityGroup_self (93.06s)
--- PASS: TestAccVPCSecurityGroup_basic (93.14s)
--- PASS: TestAccVPCSecurityGroup_allowAll (93.43s)
--- PASS: TestAccVPCSecurityGroup_defaultEgressVPC (93.89s)
--- PASS: TestAccVPCSecurityGroup_vpc (95.51s)
--- PASS: TestAccVPCSecurityGroup_sourceSecurityGroup (97.19s)
--- PASS: TestAccVPCSecurityGroup_ipRangeAndSecurityGroupWithSameRules (100.59s)
--- PASS: TestAccVPCSecurityGroup_ingressWithCIDRAndSGsVPC (103.11s)
--- PASS: TestAccVPCSecurityGroup_cidrAndGroups (105.65s)
--- PASS: TestAccVPCSecurityGroup_multiIngress (105.65s)
--- PASS: TestAccVPCSecurityGroup_egressWithPrefixList (114.39s)
--- PASS: TestAccVPCSecurityGroup_ruleGathering (117.20s)
--- PASS: TestAccVPCSecurityGroup_change (136.03s)
--- PASS: TestAccVPCSecurityGroup_namePrefixTerraform (68.74s)
--- PASS: TestAccVPCSecurityGroup_vpcProtoNumIngress (67.09s)
--- PASS: TestAccVPCSecurityGroup_vpcNegOneIngress (66.90s)
--- PASS: TestAccVPCSecurityGroup_failWithDiffMismatch (58.01s)
--- PASS: TestAccVPCSecurityGroup_driftComplex (72.95s)
--- PASS: TestAccVPCSecurityGroup_ingressMode (170.21s)
--- PASS: TestAccVPCSecurityGroup_egressMode (172.46s)
--- PASS: TestAccVPCSecurityGroup_tags (170.21s)
--- PASS: TestAccVPCSecurityGroup_ipRangesWithSameRules (62.89s)
--- PASS: TestAccVPCSecurityGroup_ipv4AndIPv6Egress (69.32s)
--- PASS: TestAccVPCSecurityGroup_nameTerraformPrefix (56.87s)
--- PASS: TestAccVPCSecurityGroup_rulesDropOnError (103.10s)
--- PASS: TestAccVPCSecurityGroup_RuleLimit_cidrBlockExceededAppend (104.97s)
--- PASS: TestAccVPCSecurityGroup_disappears (39.89s)
--- PASS: TestAccVPCSecurityGroup_noVPC (45.66s)
--- PASS: TestAccVPCSecurityGroup_nameGenerated (49.06s)
--- PASS: TestAccVPCSecurityGroup_ruleDescription (126.07s)
--- PASS: TestAccVPCSecurityGroup_ingressWithPrefixList (58.58s)
--- PASS: TestAccVPCSecurityGroup_RuleLimit_exceededAppend (129.34s)
--- PASS: TestAccVPCSecurityGroup_RuleLimit_exceededAllNew (126.46s)
--- PASS: TestAccVPCSecurityGroup_RuleLimit_exceededPrepend (125.52s)
--- PASS: TestAccVPCSecurityGroup_forceRevokeRulesTrue (403.84s)
--- PASS: TestAccVPCSecurityGroup_emrDependencyViolation (845.93s)
--- PASS: TestAccVPCSecurityGroup_forceRevokeRulesFalse (1149.34s)

@github-actions github-actions bot added size/M Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/vpc Issues and PRs that pertain to the vpc service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Sep 7, 2022
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_security_group: Defaults to default VPC when not supplied
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resource/aws_security_group: Defaults to default VPC when not supplied
resource/aws_security_group: `vpc_id` defaults to the AWS Region's default VPC when not configured

Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccVPCSecurityGroup_noVPC\|TestAccVPCSecurityGroup_basic' PKG=ec2 ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 2  -run=TestAccVPCSecurityGroup_noVPC\|TestAccVPCSecurityGroup_basic -timeout 180m
=== RUN   TestAccVPCSecurityGroup_basic
=== PAUSE TestAccVPCSecurityGroup_basic
=== RUN   TestAccVPCSecurityGroup_noVPC
=== PAUSE TestAccVPCSecurityGroup_noVPC
=== CONT  TestAccVPCSecurityGroup_basic
=== CONT  TestAccVPCSecurityGroup_noVPC
--- PASS: TestAccVPCSecurityGroup_basic (26.03s)
--- PASS: TestAccVPCSecurityGroup_noVPC (42.56s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	46.515s

@gdavison gdavison merged commit 8b70bef into main Sep 8, 2022
@gdavison gdavison deleted the b-sg-no-vpc branch September 8, 2022 17:26
@github-actions github-actions bot added this to the v4.30.0 milestone Sep 8, 2022
github-actions bot pushed a commit that referenced this pull request Sep 8, 2022
@github-actions
Copy link

github-actions bot commented Sep 9, 2022

This functionality has been released in v4.30.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented Oct 9, 2022

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. service/vpc Issues and PRs that pertain to the vpc service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants