-
Notifications
You must be signed in to change notification settings - Fork 16
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
[Issue 1037] Create non-default networking configuration #1044
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing!
# S3 and DynamoDB use Gateway VPC endpoints. All other services use Interface VPC endpoints | ||
interface_vpc_endpoints = toset([for aws_service in local.aws_service_integrations : aws_service if !contains(["s3", "dynamodb"], aws_service)]) | ||
gateway_vpc_endpoints = toset([for aws_service in local.aws_service_integrations : aws_service if contains(["s3", "dynamodb"], aws_service)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Untested idea:
# S3 and DynamoDB use Gateway VPC endpoints. All other services use Interface VPC endpoints | |
interface_vpc_endpoints = toset([for aws_service in local.aws_service_integrations : aws_service if !contains(["s3", "dynamodb"], aws_service)]) | |
gateway_vpc_endpoints = toset([for aws_service in local.aws_service_integrations : aws_service if contains(["s3", "dynamodb"], aws_service)]) | |
# S3 and DynamoDB use Gateway VPC endpoints. All other services use Interface VPC endpoints | |
gateway_services = ["s3", "dynamodb"] | |
interface_vpc_endpoints = setsubtract(local.aws_service_integrations, local.gateway_services) | |
gateway_vpc_endpoints = setintersection(local.aws_service_integrations, local.gateway_services) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would try that, but this file is a straight copy from the Nava template, and I kinda wanna keep it that way.
This is a good suggestion for the Nava template though! => https://github.com/navapbc/template-infra/blob/main/infra/modules/network/vpc-endpoints.tf
## Summary **_Creates_** but does not _**use**_ the non-defaults for dev and prod. Rolls up to, but does't resolve, #1051 ### Time to review: __1 mins__ ## Changes proposed - Creates a prod networking configuration - Renames the "default" networking configuration to "dev" ## Deployment ```bash $ cd infra/networks $ terraform init -backend-config=dev.s3.tfbackend -reconfigure # this used to be "default" $ terraform apply -var="environment_name=dev" ``` ```bash $ cd infra/networks $ terraform init -backend-config=prod.s3.tfbackend -reconfigure $ terraform apply -var="environment_name=prod" ``` ## Yet More Context Similarly to #1044, I had to import the subnet backfill into the prod terraform state. The commands for that were: ```bash terraform import -var="environment_name=prod" 'aws_eip.backfill_private["us-east-1b"]' 'eipalloc-0bb8c35bf764c3bb4' terraform import -var="environment_name=prod" 'aws_eip.backfill_private["us-east-1c"]' 'eipalloc-0fe1a378791710d16' terraform import -var="environment_name=prod" 'aws_eip.backfill_private["us-east-1a"]' 'eipalloc-04e82fbd2ffc46760' terraform import -var="environment_name=prod" 'aws_subnet.backfill_private["us-east-1a"]' 'subnet-0eaabb77c8a4cb36f' terraform import -var="environment_name=prod" 'aws_subnet.backfill_private["us-east-1b"]' 'subnet-0d07d20186586955c' terraform import -var="environment_name=prod" 'aws_route_table.backfill_private["us-east-1a"]' 'rtb-0c3f83c55ed80ced1' terraform import -var="environment_name=prod" 'aws_route_table.backfill_private["us-east-1b"]' 'rtb-03f37f2f0041d2e10' terraform import -var="environment_name=prod" 'aws_route_table.backfill_private["us-east-1c"]' 'rtb-0204f7ff0aafd3fde' terraform import -var="environment_name=prod" 'aws_subnet.backfill_private["us-east-1c"]' 'subnet-030ca9f9cb581f502' terraform import -var="environment_name=prod" 'aws_nat_gateway.backfill_private_1' 'nat-016521ed99f539813' terraform import -var="environment_name=prod" 'aws_nat_gateway.backfill_private_0' 'nat-079ce3476c4199f63' terraform import -var="environment_name=prod" 'aws_nat_gateway.backfill_private_2' 'nat-074c4ad21b794f3c2' ``` ```bash terraform import -var="environment_name=prod" 'aws_route.backfill_private_0' 'rtb-0c3f83c55ed80ced1_0.0.0.0/0' terraform import -var="environment_name=prod" 'aws_route.backfill_private_1' 'rtb-03f37f2f0041d2e10_0.0.0.0/0' terraform import -var="environment_name=prod" 'aws_route.backfill_private_2' 'rtb-0204f7ff0aafd3fde_0.0.0.0/0' ```
Summary
Fixes #1037
Time to review: 10 mins
Major Changes
terraform-aws-modules/vpc/aws
modulevpc-endpoints.tf
) to the latest pattern used by the Nava template, which puts them inside ofmodules/network/
staging
networking terraform configuration file (infra/networks/staging.s3.tfbackend
)Warning
Potential Risk
Given the type of change being made here, its easily possible for terraform to get confused about what should be deployed where. That's why I've already had to make changes in advance of this one, to update the VPC / subnet selection logic. That was these changes:
Additional Context
Additionally, this PR is going to make it so that we are trying to deploy a new named VPC inside of the default networking configuration. In my opinion, that new VPC should be named
dev
. I will then follow-up later to create theprod
VPC. Neither thedev
nor theprod
VPC will actually be used, not until I make another follow-up PR.Yet More Context
To pull this off, I had to import the subnet backfill into the staging terraform state. The idea was that I didn't want to create duplicates of the subnet backfills. To do that, I had to run these commands: