Hi,
I’m stuck with creating an aws_instance via a module I created.
I did setup the VPC already, which also uses a module. Now I’d like to create an AWS Instance in that VPC but I can’t figure out how to get the vpc_id that is needed for creation.
Following is the hierarchy of my terraform files
.
|-- dev
| `-- custXX
| |-- services
| `-- vpc
|-- modules
| |-- ec2_service
| | |-- 01-main.tf
| | |-- 98-outputs.tf
| | `-- 99-variables.tf
| `-- vpc
| |-- main.tf
| |-- outputs.tf
| `-- variables.tf
The running vpc comes from dev/custXX/vpc
the aws instance comes from dev/custXX/services/admin-host
In the terraform config for the new host I have added a data source as follows
data "terraform_remote_state" "vpc" {
backend = "s3"
config = {
bucket = "tfstate-dev"
key = "dev/custxx/vpc/terraform.tfstate"
region = var.region
}
}
which gets read but it doesn’t seem to have a vpc_id. Sorry, I can’t get my head around that for days.
Cheers