In this section we're going to go through the steps of setting up your remote state resources.
There's more than one way to set up your remote state, the way we're doing it today is using AWS resources, here's the official Terraform documentation on this.
We're going to deploy these resources using Cloudformation in ap-southeast-2
Sydney (Make sure you're in the right region!)
The Cloudformation template we're using can be found HERE.
This template provisions a CloudFormation stack in ap-southeast-2 that contains a S3 bucket named [YOUR-NAME]-terraform-workshop-state-bucket-XXXXX where XXXXX is the ID of the AWS account, as well as a DynamoDB lock table.
To deploy this stack we can log into the AWS Console and follow these steps:
- Navigate to Cloudformation
- Click
Create stack
- Select
With new resources (standard)
- Select
Template is ready
- Select
Upload a template file
- Click
Choose file
- Select your locally saved file
/remote-state/stack.yaml
- Click
Next
- Give your stack a name
[YOUR-NAME]-terraform-workshop
- Rename your
LockTableName
andStateBucketNamePrefix
parameters (eg.LockTableName = franca-terraform-workshop-lock-table
,StateBucketNamePrefix = franca-terraform-workshop-state-bucket
) - Click
Next
- Click
Next
- Click
Submit
Great job! You've deployed an s3 Bucket and DynamoDB Table to host your state.
You may need to wait a couple of minutes until these resources are fully deployed to continue.
Your Cloudformation stack should show status: CREATE_COMPLETE
Remote state in Terraform deployed this way uses the following resources:
S3 Bucket - Stores the state of your terraform stack
DynamoDB Table - Database used for State Locking and Consistency Checking. This prevents people from making concurrent changes to a stack.