aws-ia / terraform-aws-network-hubandspoke

https://registry.terraform.io/modules/aws-ia/network-hubandspoke/aws
Apache License 2.0
28 stars 10 forks source link

unable to use to module with only vpc id #26

Open floriantdoungmene opened 12 months ago

floriantdoungmene commented 12 months ago

Hi I have created inspection (with engress) VPC and ingress VPC but when I used only the vpc id in the mudle, it does not work. Could you show an example with the use of VPC ids for inspection ingress and spoke vpc?

Voici le code: module "hub-and-spoke" { source = "../modules/terraform-aws-network-hubandspoke"

For testing purposes, uncomment the line below and comment the "source" and "version" lines above

source = "../.."

identifier = "test" transit_gateway_id = aws_ec2_transit_gateway.tgw.id network_definition = { type = "CIDR" value = "10.0.0.0/8" } central_vpcs = {

inspection = {
  vpc_id = module.inspection_vpc.vpc_attributes.id

}
ingress = { vpc_id = module.ingress_vpc.vpc_attributes.id

}

} }

Voici le message d'erreur quand je fais le terraform plan

Planning failed. Terraform encountered an error while generating this plan.

╷ │ Error: Unsupported attribute │ │ on ..\modules\terraform-aws-network-hubandspoke\main.tf line 40, in module "central_vpcs": │ 40: az_count = each.value.az_count │ ├──────────────── │ │ each.value is object with 1 attribute "vpc_id" │ │ This object does not have an attribute named "az_count". ╵ ╷ │ Error: Unsupported attribute │ │ on ..\modules\terraform-aws-network-hubandspoke\main.tf line 40, in module "central_vpcs": │ 40: az_count = each.value.az_count │ ├──────────────── │ │ each.value is object with 1 attribute "vpc_id" │ │ This object does not have an attribute named "az_count". ╵ ╷ │ Error: Invalid value for variable │ │ on ..\modules\terraform-aws-network-hubandspoke\main.tf line 49, in module "central_vpcs": │ 49: subnets = merge(try(each.value.subnets, {}), local.subnet_config[each.key]) │ ├──────────────── │ │ var.subnets is object with 2 attributes │ │ Each subnet type must contain only 1 key: cidrs or netmask or ipv6_native. │ │ This was checked by the validation rule at ..\modules\terraform-aws-vpc\variables.tf:277,3-13. ╵ ╷ │ Error: Invalid value for variable │ │ on ..\modules\terraform-aws-network-hubandspoke\main.tf line 49, in module "central_vpcs": │ 49: subnets = merge(try(each.value.subnets, {}), local.subnet_config[each.key]) │ ├──────────────── │ │ var.subnets is object with 2 attributes │ │ Each subnet type must contain only 1 key: cidrs or netmask or ipv6_native. │ │ This was checked by the validation rule at ..\modules\terraform-aws-vpc\variables.tf:277,3-13. ╵

pablo19sc commented 11 months ago

Hi @floriantdoungmene thanks for the feedback!

Simply let me understand what you are trying to do. Do you want to pass an already created VPC and create the TGW routing out of it?