8000 tf: create vpc and subnet instead of asking user for the details in tfvars by psinghal20 · Pull Request #3 · tetrateio/mitm-env · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

psinghal20
Copy link

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

…fvars

Signed-off-by: Pratyush Singhal <psinghal20@gmail.com>
@psinghal20 psinghal20 requested review from tanujd11 and Copilot June 12, 2025 11:04
Copy link
@Copilot Copilot AI left a 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 and subnet_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 like mitm_vpc_id.
output "vpc_id" {

enable_dns_support = true

tags = {
Name = "mitm-vpc"
Copy link
Preview
Copilot AI Jun 12, 2025

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
Comment on lines 21 to 29
# 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"
Copy link
Preview
Copilot AI Jun 12, 2025

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.

Suggested change
# 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3966
Development

Successfully merging this pull request may close these issues.

1 participant
0