Two aws_s3_object resources designated prod and dev, which load the file in the local assets directory using the built in file()function and upload it to your S3 buckets. Two aws_s3_bucket_policy resources designated prod and dev, which allow anyone to read the objects in the corresponding bucket. Two aws_s3_bucket_website_configuration resources designated prod and dev, which configure your buckets to host websites. Two aws_s3_bucket_acl resources designated prod and dev, which set a public-read ACL for your buckets. Notice that the bucket argument defines the S3 bucket name by interpolating the environment prefix and the random_pet resource name. Two aws_s3_bucket resources designated prod and dev, which each create an S3 bucket. The random_pet resource creates a string to be used as part of the unique name of your S3 bucket. The file consists of a few different resources: In your text editor, open the main.tf file.
variables.tf- declares input variables for your dev and prod environment prefixes, and the AWS region to deploy to.main.tf - configures the resources that make up your infrastructure.The root directory files compose the configuration as well as the inputs and outputs of your deployment. Your root directory contains four files and an "assets" folder. Method with the default AWS credentials file and default profile. The examples in this tutorial assume that you are using the Shared Credentials This tutorial uses Amazon Web Services (AWS) modules.Ĭonfigure one of the authentication methods described in our AWS Provider » PrerequisitesĪlthough the concepts in this tutorial apply to any module creation workflow,
You will modify it to step through the common phases of evolution for a Terraform project, until each environment has its own independent configuration and state. The configuration you use to deploy the application will start in as a monolith. In this tutorial, you will provision two instances of a web application hosted in an S3 bucket that represent production and development environments. These tutorials are for Terraform users who need to restructure Terraform configurations as they grow. However, as your infrastructure grows, restructuring your monolith into logical units will make your Terraform configurations less confusing and safer to manage. Small projects may be convenient to maintain this way. Some Terraform projects start as a monolith, a Terraform project managed by a single main configuration file in a single directory, with a single state file.