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

Get default aws subnet ids #1131

Merged
merged 5 commits into from
Jun 14, 2022
Merged

Conversation

Etiene
Copy link
Contributor

@Etiene Etiene commented May 26, 2022

Description

Resolves #1130.

The VPC object obtained when running aws.GetDefaultVpc includes all subnets in the default VPC, and not just the default subnets. This is a problem because often this is used with the intention to get the default subnets in a region, as by default the default VPC has a default subnet in each availability zone. However, there are occasions where more subnets are created in the default VPC causing unintended effects.

For example:

This PR

  • adds aws.GetDefaultSubnetIDsForVpc to retrieve default subnet ids
  • updates aws.IsPublicSubnet to check implicit association with the main route table in VPC when the subnet does not have any explicitly associated route tables
  • and fixes the TestGetVpcsE test to check for greater or equal number of subnets and availability zones instead of equal.

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes

  • Added aws.GetDefaultSubnetIDsForVpc to retrieve default subnet ids
  • Updated aws.IsPublicSubnet to check implicit association with the main route table in VPC when the subnet does not have any explicitly associated route tables

denis256
denis256 previously approved these changes May 28, 2022
Copy link
Member

@denis256 denis256 left a comment

Choose a reason for hiding this comment

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

👍

}

for _, subnet := range vpc.Subnets {
if subnet.DefaultForAz == true {
Copy link
Member

Choose a reason for hiding this comment

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

I was wondering if is required to check for true

Copy link
Contributor Author

@Etiene Etiene May 31, 2022

Choose a reason for hiding this comment

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

oh yea, this is not necessary. removed in 864adce and added a new check in the tests for excluding recently created subnets too

@Etiene
Copy link
Contributor Author

Etiene commented Jun 13, 2022

Thanks for approving this @denis256!

PS: I don't have the powers to re-run the CI tests nor merge PRs in this repo :)

@yorinasub17
Copy link
Contributor

Kicked off test after rebasing on master (which has a few test fixes): https://app.circleci.com/pipelines/github/gruntwork-io/terratest/1037/workflows/495242aa-7f88-4005-8776-1b5d26fefdfe

@yorinasub17
Copy link
Contributor

Confirmed the test failures are unrelated to this change, so will go ahead and merge + release this!

@yorinasub17 yorinasub17 merged commit 0dd0f81 into gruntwork-io:master Jun 14, 2022
@Etiene Etiene deleted the 1130-defaultsubnets branch June 27, 2022 09:53
@Etiene
Copy link
Contributor Author

Etiene commented Jun 27, 2022

@yorinasub17 Lovely, thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting default subnets of default VPC
3 participants