provider.tf:
$ cat provider.tf
provider "aws" {
version = "~> 2.0"
region = "eu-west-1"
profile = "dev"
shared_credentials_file = "~/.aws/credentials"
}
vpc.tf:
$ cat vpc.tf
data "aws_vpc" "default" {
default = true
}
data "aws_subnet_ids" "private" {
vpc_id = data.aws_vpc.default.id
tags = {
Tier = "private"
}
}
output.tf:
$ cat output.tf
output "vpc_id" {
description = "The Default VPC ID"
value = data.aws_vpc.default.id
}
Run:
$ terraform init
$ terraform apply
data.aws_vpc.default: Refreshing state...
data.aws_subnet_ids.private: Refreshing state...
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
vpc_id = vpc-xxxxxxxx