terraform-aws-modules / terraform-aws-ec2-instance

Terraform module to create AWS EC2 instance(s) resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/ec2-instance/aws
Apache License 2.0
753 stars 1.86k forks source link

Not able to use subnet_ids in ec2 module #328

Closed Dhina-test closed 1 year ago

Dhina-test commented 1 year ago

Hi , here i am sharing my ec2 module block and error can you help to solve this ?

`module "private_ec2" { source = "terraform-aws-modules/ec2-instance/aws" version = "4.2.0"

name = "private-ec2-ins"

ami = data.aws_ami.ubuntu.id instance_type = var.instance_type key_name = var.key_pair

monitoring = true

vpc_security_group_ids = [module.bastion_sg.security_group_id] subnet_ids = [module.vpc.private_subnets[0], module.vpc.private_subnets[1]] user_data = file("${path.module}/install.sh")

tags = { Terraform = "true" Environment = "dev" } }`

and error in terraform validate image

antonbabenko commented 1 year ago

Use subnet_id as suggested in the error message. See examples in the readme.

Dhina-test commented 1 year ago

Yes @antonbabenko , but i am trying add more than one subnets. and here i am using subnet_id instead of subnet_ids In may case i defined subnet details in variable section for vpc

image

Then i will be calling those in ec2 module from vpc module outputs image

and now error in terraform validate

image Can you help for this ?

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.