How to configure terraform state file as Amazon S3

In this blog post, I would like to present how to create terraform state file as s3. I will be writing series of blog posts about terraform, ansible automation, How to use AWS CDK to automate infrastructure.

To begin with, Let us start about how to configure terraform state file as Amazon S3.

Before you configure terraform state, you need to make sure terraform install. For more details about how to install terraform you may refer here

Create s3 bucket (You can do this by using aws console or aws cli)

I’ve used eu-west-1 region for creating bucket if you are using default region us-east-1 then you do not need to mention region, Locationconstraint.

Example with default region (us-east-1)

aws s3api create-bucket –bucket terraformstateinfo2020

Now, let’s create backed terraform file


terraform {
required_version = “>=0.13.0”
backend “s3” {
region = “eu-west-1”
profile = “default”
key = “terraformstatefile”
bucket = ” terraformstateinfo2020″

Let us run terraform init command to see if the terraform state is configured!

You can check the state file locally as below. At this moment you don’t have any information except bucket name.

cd .terraform

Hope you enjoyed the post.


Ramasankar Molleti


Published by Ramasankar

Hi. I’m Ramasankar Molleti. I’m a passionate IT professional with over 14 years of experience on providing solutions for customers who are looking on cloud computing, Database Migration, Development, and Big Data. I love learning new technologies and share my knowledge to community. I am currently working as Sr Cloud Architect with focus on Cloud Infrastructure, Big Data. I work with developers to architect, build, and manage cloud infrastructure, and services. I have deeep knowledge and experience on working with various database platforms such as MS SQL Server, PostgeSQL, Oracle, MongoDB, Redshift, Dyanamodb, Amazon Aurora. I worked as Database Engineer, Database Administrator, BI Developer and successfully transit myself into Cloud Architect with focus on Cloud infranstructure and Big Data. I live in USA and put my thoughts down on this blog. If you want to get in touch with me, contact me on my Linkedin here: My Certifications: Amazon: AWS Certified Solutions Architect – Professional AWS Certified DevOps Engineer – Professional certificate AWS Certified Big Data – Specialty AWS Certified Security – Specialty certificate AWS Certified Advanced Networking – Specialty certificate AWS Certified Solutions Architect – Associate Microsoft: Microsoft® Certified Solutions Associate: SQL Server 2012/2014 Microsoft Certified Professional Microsoft® Certified IT Professional: Database Administrator 2008 Microsoft® Certified Technology Specialist: SQL Server 2008, Implementation and Maintenance

One thought on “How to configure terraform state file as Amazon S3

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: