We believe your privacy is very important. We use cookies to track your behaviour and provide a better experience
Backend Helpers | Automation and Software Development for Cloud Applicationses
Terraform is a framework for managing infrastructure as code. It includes different providers such as Amazon Web Services , Google Cloud , Microsoft Azure , among others. In this post we will cover a brief introduction to terraform by creating and destroying an AWS S3 bucket.
You will need to download the Right version for your system. Keep in mind that you will download a zipped file. You need to unzipped and place it in a directory included in your $PATH variable. You can verify the installation with the following command:
terraform --help
In the following steps we are going to create a terraform file and we will define our first AWS resource by using Amazon Web Services (AWS) provider
You can configure your AWS credentials by setting up the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. In this link you will find additional information about how to setup these two variables.
Create a file named example.tf . This file will include the definition for a S3 bucket:
provider "aws" {} resource "aws_s3_bucket" "b" { bucket = "my-unique-name-bucket-maigfrga.ntweb.co" acl = "private" region = "eu-west-1" tags = { Name = "MyBucket" Environment = "Development" } }
The command terraform init
initializes your working directory:
Run terraform apply
in order to create a S3 bucket:
The command terraform destroy
will destroy the S3 you just create previously: