Skip to main content

Step 4: Infrastructure as Code

This example use IaC backed component from @dinghy/tf-aws to not only generate same diagramm as Step 3: draw.io, but also terraform code below:

The terraform code snippet is for illustration only.

output/app/app.tf.json
{
"terraform": {
"required_providers": {
"aws": {
"source": "aws",
"version": "6.22.0"
}
}
},
"provider": {
"aws": [
{
"region": "eu-west-1",
"default_tags": {
"tags": {
"iac:stack-title": "Web App",
"iac:stack-name": "web-app"
}
}
}
]
},
"data": {
"aws_vpc": {
"awsvpc_vpc": {}
}
},
"resource": {
"aws_subnet": {
"awssubnet_publicsubnet": {
"vpc_id": "${data.aws_vpc.awsvpc_vpc.id}",
"cidr_block": "10.0.0.0/16"
},
"awssubnet_privatesubnet": {
"vpc_id": "${data.aws_vpc.awsvpc_vpc.id}",
"cidr_block": "10.10.0.0/16"
}
},
"aws_lb": {
"awslb_loadbalancer": {
"vpc_id": "${data.aws_vpc.awsvpc_vpc.id}",
"subnets": [
"${aws_subnet.awssubnet_publicsubnet.id}"
]
}
},
"aws_instance": {
"awsinstance_application": {
"ami": "ami-005e54dee72cc1d00",
"subnet_id": "${aws_subnet.awssubnet_privatesubnet.id}"
}
},
"aws_db_instance": {
"awsdbinstance_postgres": {
"instance_class": "db.t3.micro"
}
}
}
}