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

r/aws_vpc_security_group_association: new resource #40069

Merged
merged 15 commits into from
Nov 14, 2024

Conversation

alexbacchin
Copy link
Contributor

@alexbacchin alexbacchin commented Nov 9, 2024

Description

This resource will allow practitioners associate EC2 Security Groups with other VPCs in the same account.

Relations

Closes #39999

References

https://docs.aws.amazon.com/vpc/latest/userguide/security-group-assoc.html

Output from Acceptance Testing

% make testacc TESTS=TestAccVPCSecurityGroupAssociation PKG=ec2
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.2 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCSecurityGroupAssociation'  -timeout 360m
2024/11/09 16:04:13 Initializing Terraform AWS Provider...
=== RUN   TestAccVPCSecurityGroupAssociation_basic
=== PAUSE TestAccVPCSecurityGroupAssociation_basic
=== RUN   TestAccVPCSecurityGroupAssociation_disappears
=== PAUSE TestAccVPCSecurityGroupAssociation_disappears
=== CONT  TestAccVPCSecurityGroupAssociation_basic
=== CONT  TestAccVPCSecurityGroupAssociation_disappears
--- PASS: TestAccVPCSecurityGroupAssociation_disappears (70.24s)
--- PASS: TestAccVPCSecurityGroupAssociation_basic (71.78s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        71.854s
...

Copy link

github-actions bot commented Nov 9, 2024

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/vpc Issues and PRs that pertain to the vpc service. needs-triage Waiting for first response or review from a maintainer. labels Nov 9, 2024
@alexbacchin alexbacchin force-pushed the f-aws_vpc_security_group_association branch from 088c9a1 to 2e6227d Compare November 9, 2024 03:48
@github-actions github-actions bot added linter Pertains to changes to or issues with the various linters. generators Relates to code generators. labels Nov 9, 2024
@alexbacchin alexbacchin marked this pull request as ready for review November 9, 2024 05:48
@alexbacchin alexbacchin requested a review from a team as a code owner November 9, 2024 05:48
@justinretzolk justinretzolk added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 11, 2024
@jar-b jar-b added new-resource Introduces a new resource. and removed enhancement Requests to existing resources that expand the functionality or scope. labels Nov 13, 2024
@jar-b jar-b self-assigned this Nov 13, 2024
@github-actions github-actions bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Nov 13, 2024
This replaces the previously hardcoded 5 minute timeout used on the create and delete waiters. The default create and delete timeouts are now 5 minutes and will be passed into the waiter functions, allowing practitioners to optionally configure longer timeouts, if desired.
This changes the resource name to `aws_vpc_security_group_vpc_association`, along with renaming many associated functions and structs. The reasoning behind this is to match the typical conventions used throughout the provider. Namely - using `vpc` as the service identifier for EC2 APIs which are scoped to VPC-based actions, and deriving the resource name by noun-ifying the corresponding AWS API. In this case the `AssociateSecurityGroupVpc` API maps to a suffix of `_security_group_vpc_association`. Combining these conventions together results in the complete name `aws_vpc_security_group_vpc_association`.

```console
% make testacc PKG=ec2 TESTS=TestAccVPCSecurityGroupVPCAssociation_basic
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...

--- PASS: TestAccVPCSecurityGroupVPCAssociation_basic (75.12s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        80.366s
```
This attribute will track the state of the security group VPC association.

```console
% make testacc PKG=ec2 TESTS=TestAccVPCSecurityGroupVPCAssociation_basic
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.2 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCSecurityGroupVPCAssociation_basic'  -timeout 360m
2024/11/13 14:45:52 Initializing Terraform AWS Provider...

--- PASS: TestAccVPCSecurityGroupVPCAssociation_basic (34.74s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        39.954s
```
Adds additional logic to the delete method to handle cases where the VPC association and security group are deleted out of band.

```console
% make testacc PKG=ec2 TESTS=TestAccVPCSecurityGroupVPCAssociation_disappears_SecurityGroup
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.2 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCSecurityGroupVPCAssociation_disappears_SecurityGroup'  -timeout 360m
2024/11/13 15:34:21 Initializing Terraform AWS Provider...

--- PASS: TestAccVPCSecurityGroupVPCAssociation_disappears_SecurityGroup (23.92s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        29.764s
```
…tion

Adds additional logic to the delete method to handle cases where the VPC association and target VPC are deleted out of band.

```console
% make testacc PKG=ec2 TESTS=TestAccVPCSecurityGroupVPCAssociation_disappears_VPC
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.2 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCSecurityGroupVPCAssociation_disappears_VPC'  -timeout 360m
2024/11/13 16:31:22 Initializing Terraform AWS Provider...

--- PASS: TestAccVPCSecurityGroupVPCAssociation_disappears_VPC (64.64s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        69.898s
```
Copy link
Member

@jar-b jar-b 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 PKG=ec2 TESTS=TestAccVPCSecurityGroupVPCAssociation_
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.2 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCSecurityGroupVPCAssociation_'  -timeout 360m
2024/11/13 16:36:02 Initializing Terraform AWS Provider...

--- PASS: TestAccVPCSecurityGroupVPCAssociation_disappears (23.04s)
--- PASS: TestAccVPCSecurityGroupVPCAssociation_basic (24.74s)
--- PASS: TestAccVPCSecurityGroupVPCAssociation_disappears_SecurityGroup (63.93s)
--- PASS: TestAccVPCSecurityGroupVPCAssociation_disappears_VPC (64.58s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        71.166s

@jar-b
Copy link
Member

jar-b commented Nov 13, 2024

Thanks for your contribution, @alexbacchin! 👍 👏

@jar-b jar-b merged commit 8d4fd10 into hashicorp:main Nov 14, 2024
41 checks passed
@github-actions github-actions bot added this to the v5.76.0 milestone Nov 14, 2024
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Nov 14, 2024
Copy link

This functionality has been released in v5.76.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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Introduces or discusses updates to documentation. generators Relates to code generators. linter Pertains to changes to or issues with the various linters. new-resource Introduces a new resource. service/vpc Issues and PRs that pertain to the vpc service. 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.

[New Resource]: Security groups associated with multiple VPC
3 participants