Creating Your First Infrastructure With Terraform
Explore the essential steps to set up your first infrastructure with Terraform. Learn to initialize a Terraform project, create an AWS S3 bucket, manage infrastructure changes using Terraform apply, and clean up by destroying resources. This lesson helps you understand how Terraform automates infrastructure state management and prepares you for more advanced Terraform usage.
We'll cover the following...
The first thing you have to do with a new Terraform project is to initialise Terraform for that project. To do this, provide aws_access_key_id and aws_secret_access_key, change <your-name> for the bucket name, and click the RUN button:
📝Note: Before running the project please do make sure that you have set up an AWS account. You can also refer to the lesson, Setting up an AWS Account.
Important Note:
- If you cannot edit the access keys and other fields in the terminal below, you don’t need to provide your credentials. We have got you covered.
- Please use only
us-east-2region for working in AWS in this course. - Please ensure that the bucket name is globally unique.
provider "aws" {
region = "us-east-2"
}
resource "aws_s3_bucket" "first_bucket" {
bucket = "<your-name>-first-bucket"
}
You will see some output on the screen as Terraform initialises, then ...