Terraform Settings block

terraform {
    #required Terraform Version
    required_version = "~> 1.0.11"
    #Required Providers and their versions
    required_providers {
        aws = {
            source = "hashicorp/aws"
            version = "~> 3.21" 
        }
    }
    #Remote Backend for storing Terraform state in S3 bucket
    backend "s3" {
        bucket = "mybucket"
        key = "path/to/my/key"
        region = "us-east-1"
    }
}

 

Terraform Resource Block

# Terraform Settings Block
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      #version = "~> 3.21" # Optional but recommended in production
    }
  }
}

# Provider Block
provider "aws" {
  profile = "default" # AWS Credentials Profile configured on your local desktop terminal  $HOME/.aws/credentials
  region  = "us-east-1"
}

# Resource Block
resource "aws_instance" "ec2demo" {
  ami           = "ami-04ad2567c9e3d7893" # Amazon Linux in us-east-1, update as per your region
  instance_type = "t2.micro"
}