IT notes

Merge Terraform States

If states are being stored in S3, after importing a resource, for example: $ terraform import aws_customer_gateway.main cgw-b4dc3961 You will end with a terraform.tfstate that differs from the one in the S3 bucket. To merge the remote and local state do this: $ terraform state pull > terraform.tfstate $ terraform import aws_customer_gateway.main cgw-b4dc3961 $ terraform state push terraform.tfstate First get the current s3 state: $ terraform state pull > terraform.

Terraform Full Vpc

Example of a full VPC setup using terraform, including VPN and using the default subnet: resource "aws_vpc" "test" { cidr_block = "10.100.0.0/16" enable_dns_hostnames = "true" enable_dns_support = "true" tags { Name = "test" } } output "vpc_id" { value = "${aws_vpc.test.id}" } resource "aws_internet_gateway" "igw" { vpc_id = "${aws_vpc.test.id}" tags { Name = "internet gateway" } } resource "aws_subnet" "public-a" { vpc_id = "${aws_vpc.test.id}" cidr_block = "10.100.0.0/24" availability_zone = "eu-central-1a" tags { Name = "public A" } } output "subnet-public-a" { value = "${aws_subnet.