-
Notifications
You must be signed in to change notification settings - Fork 0
tf: create vpc and subnet instead of asking user for the details in tfvars #3
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
base: main
Are you sure you want to change the base?
Conversation
…fvars Signed-off-by: Pratyush Singhal <psinghal20@gmail.com>
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.
Pull Request Overview
This PR enables Terraform to create its own VPC and public subnet instead of requiring users to supply those IDs via tfvars.
- Added Terraform resources for VPC, Internet Gateway, public subnet, route table, and AZ data source.
- Removed
vpc_id
andsubnet_id
variables and references, updating FRR instance and ASG to use the new resources. - Introduced outputs for the created VPC and subnet IDs and cleaned up stage.tfvars defaults.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
cloud/aws/vpc.tf | New resources for VPC creation, IGW, public subnet, routing, AZs |
cloud/aws/inputs.tf | Removed vpc_id /subnet_id variables; updated BGP default range |
cloud/aws/outputs.tf | Added outputs for vpc_id and subnet_id |
cloud/aws/frr.tf | Switched FRR router subnet reference to the created subnet |
cloud/aws/asg.tf | Updated SG and ASG to use created VPC and subnet IDs |
cloud/aws/tfvars/stage.tfvars | Removed user-supplied VPC/subnet IDs; adjusted BGP listen CIDR |
Comments suppressed due to low confidence (3)
cloud/aws/vpc.tf:3
- [nitpick] Consider parameterizing this CIDR block rather than hard-coding
10.0.0.0/16
, so it can be customized per environment.
cidr_block = "10.0.0.0/16"
cloud/aws/vpc.tf:1
- [nitpick] New VPC and subnet resources lack accompanying Terraform tests or validations. Adding
terraform validate
or unit tests (e.g., with terratest) could help catch misconfigurations early.
# Create VPC
cloud/aws/outputs.tf:25
- [nitpick] The generic output name
vpc_id
might collide when this module is consumed alongside others. Consider a more specific name likemitm_vpc_id
.
output "vpc_id" {
enable_dns_support = true | ||
|
||
tags = { | ||
Name = "mitm-vpc" |
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.
[nitpick] The resource tags are hard-coded. You may want to expose a variable for the VPC name tag to support different naming conventions or environments.
Copilot uses AI. Check for mistakes.
cloud/aws/vpc.tf
Outdated
# Create public subnet | ||
resource "aws_subnet" "public" { | ||
vpc_id = aws_vpc.main.id | ||
cidr_block = "10.0.1.0/24" | ||
availability_zone = data.aws_availability_zones.available.names[0] | ||
map_public_ip_on_launch = true | ||
|
||
tags = { | ||
Name = "mitm-public-subnet" |
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.
Selecting only the first availability zone can limit resilience. Consider distributing subnets across multiple AZs or making this configurable.
# Create public subnet | |
resource "aws_subnet" "public" { | |
vpc_id = aws_vpc.main.id | |
cidr_block = "10.0.1.0/24" | |
availability_zone = data.aws_availability_zones.available.names[0] | |
map_public_ip_on_launch = true | |
tags = { | |
Name = "mitm-public-subnet" | |
# Create public subnets across multiple availability zones | |
resource "aws_subnet" "public" { | |
count = var.num_azs | |
vpc_id = aws_vpc.main.id | |
cidr_block = cidrsubnet("10.0.0.0/16", 8, count.index) | |
availability_zone = data.aws_availability_zones.available.names[count.index] | |
map_public_ip_on_launch = true | |
tags = { | |
Name = "mitm-public-subnet-${count.index}" |
Copilot uses AI. Check for mistakes.
cidr block Signed-off-by: Pratyush Singhal <psinghal20@gmail.com>
Change to allow Terraform to create VPC and subnet instead of asking users for specific VPC ID or subnet ID.
Purely vibe-coded 😛 so review carefully please