Skip to main content
This example demonstrates how to create a basic AWS infrastructure including a VPC, subnet, security group, and an EC2 instance. It also shows how to configure an S3 backend for state management.

Prerequisites

Ensure you have the AWS provider generated in your project:

Complete Example

Key Concepts

  • Provider Configuration: The AwsProvider construct initializes the connection to AWS.
  • Backend Configuration: S3Backend tells Terraform to store the state file in an S3 bucket.
  • Resource Referencing: Notice how subnet.id and sg.id are used to link resources together. tfts handles the underlying Terraform references automatically.
  • Tags: Most AWS resources support a tags property for organization and cost tracking.