-
Notifications
You must be signed in to change notification settings - Fork 15
feat: add VPC and subnet name support #54
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,75 @@ | ||||||||||
| provider "aws" { | ||||||||||
| region = var.region | ||||||||||
| } | ||||||||||
|
|
||||||||||
| # Create VPC and subnets with specific names for demonstration | ||||||||||
| module "vpc" { | ||||||||||
| source = "cloudposse/vpc/aws" | ||||||||||
| version = "2.1.0" | ||||||||||
|
|
||||||||||
| namespace = var.namespace | ||||||||||
| stage = var.stage | ||||||||||
| name = "example-vpc" | ||||||||||
|
|
||||||||||
| ipv4_primary_cidr_block = "10.0.0.0/16" | ||||||||||
| assign_generated_ipv6_cidr_block = true | ||||||||||
| } | ||||||||||
|
|
||||||||||
| module "subnets" { | ||||||||||
| source = "cloudposse/dynamic-subnets/aws" | ||||||||||
| version = "2.3.0" | ||||||||||
| namespace = var.namespace | ||||||||||
| stage = var.stage | ||||||||||
| name = "example-subnets" | ||||||||||
|
|
||||||||||
| availability_zones = var.availability_zones | ||||||||||
| vpc_id = module.vpc.vpc_id | ||||||||||
| igw_id = [module.vpc.igw_id] | ||||||||||
| ipv4_cidr_block = [module.vpc.vpc_cidr_block] | ||||||||||
| ipv6_enabled = var.ipv6_enabled | ||||||||||
| } | ||||||||||
|
|
||||||||||
| # Example 1: Using VPC and subnet IDs (traditional approach) | ||||||||||
| module "ssm_agent_with_ids" { | ||||||||||
| source = "../../" | ||||||||||
| stage = var.stage | ||||||||||
| namespace = var.namespace | ||||||||||
| name = "ssm-with-ids" | ||||||||||
|
|
||||||||||
| vpc_id = module.vpc.vpc_id | ||||||||||
| subnet_ids = module.subnets.private_subnet_ids | ||||||||||
| } | ||||||||||
|
|
||||||||||
| # Example 2: Using VPC and subnet names (new functionality) | ||||||||||
| module "ssm_agent_with_names" { | ||||||||||
| source = "../../" | ||||||||||
| stage = var.stage | ||||||||||
| namespace = var.namespace | ||||||||||
| name = "ssm-with-names" | ||||||||||
|
|
||||||||||
| vpc_name = module.vpc.vpc_id_tag_name # This would be the Name tag value | ||||||||||
| subnet_names = [ | ||||||||||
| # These would be the actual Name tag values of the subnets | ||||||||||
| # In a real scenario, you'd know these names or get them from data sources | ||||||||||
| "example-private-subnet-1", | ||||||||||
| "example-private-subnet-2" | ||||||||||
| ] | ||||||||||
|
|
||||||||||
| depends_on = [module.subnets] | ||||||||||
| } | ||||||||||
|
Comment on lines
+58
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent ❓ Verification inconclusivedepends_on here won’t fix plan-time data lookups Data sources inside the child module resolve during planning; they won’t “wait” for module.subnets. This example will often fail on first plan/apply when the subnets don’t yet exist. Document this limitation or prefer IDs when creating the subnets in the same run. - depends_on = [module.subnets]
+ # Note: Name-based lookups plan-time resolve and can fail on first apply if subnets are created in the same run.
+ # Consider using IDs when creating subnets, or run in two stages (create subnets, then apply this module with names).Document plan-time data lookup limitation and prefer IDs or two-stage applies
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| # Example 3: Mixed configuration (VPC by ID, subnets by name) | ||||||||||
| module "ssm_agent_mixed" { | ||||||||||
| source = "../../" | ||||||||||
| stage = var.stage | ||||||||||
| namespace = var.namespace | ||||||||||
| name = "ssm-mixed" | ||||||||||
|
|
||||||||||
| vpc_id = module.vpc.vpc_id | ||||||||||
| subnet_names = [ | ||||||||||
| "example-private-subnet-1", | ||||||||||
| "example-private-subnet-2" | ||||||||||
| ] | ||||||||||
|
|
||||||||||
| depends_on = [module.subnets] | ||||||||||
| } | ||||||||||
|
Comment on lines
+74
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Same plan-time lookup caveat for mixed example Remove depends_on and add a note, or switch the example to consume existing infra names. - depends_on = [module.subnets]
+ # See note above regarding plan-time name lookups when subnets are created in the same run.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| variable "region" { | ||
| type = string | ||
| description = "AWS region" | ||
| default = "us-east-1" | ||
| } | ||
|
|
||
| variable "namespace" { | ||
| type = string | ||
| description = "Namespace for resource naming" | ||
| default = "mp" | ||
| } | ||
|
|
||
| variable "stage" { | ||
| type = string | ||
| description = "Stage for resource naming" | ||
| default = "test" | ||
| } | ||
|
|
||
| variable "availability_zones" { | ||
| type = list(string) | ||
| description = "List of availability zones" | ||
| default = ["us-east-1a", "us-east-1b"] | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.