Common HCL(Terraform) to use resources of AWS.

Define the AWS provider
        
provider "aws" {
    region = "us-east-1"  # Replace with your desired AWS region
    }
        
    
Create an S3 bucket to store Terraform state files
        
resource "aws_s3_bucket" "terraform_state_bucket" {
    bucket = "my-terraform-state-bucket"  # Replace with your bucket name
    acl    = "private"
    }
        
    
Enable versioning for the S3 bucket
        
resource "aws_s3_bucket_versioning" "terraform_state_versioning" {
    bucket = aws_s3_bucket.terraform_state_bucket.id
    enabled = true
    }
        
    
Create an IAM user for Terraform deployments
        
resource "aws_iam_user" "terraform_user" {
    name = "terraform-user"
            // Save Secret in Github and use it in here
    }
        
    
Attach necessary policies to the IAM user (e.g., S3, DynamoDB, etc.)
        
    resource "aws_iam_user_policy_attachment" "terraform_user_policy" {
    user       = aws_iam_user.terraform_user.name
    policy_arn = "arn:aws:iam::aws:policy/AmazonS3FullAccess"  # Example policy
    }
        
    
Create an S3 bucket for storing Terraform state locks (optional)
        
    resource "aws_s3_bucket" "terraform_locks_bucket" {
    bucket = "my-terraform-locks-bucket"  # Replace with your bucket name
    acl    = "private"
    }
        
    
Create an Amazon DynamoDB table for Terraform state locking (optional)
        
    resource "aws_dynamodb_table" "terraform_locks_table" {
    name           = "terraform-locks"
    billing_mode   = "PAY_PER_REQUEST"
    hash_key       = "LockID"
    attribute {
    name = "LockID"
    type = "S"
    }
    }
        
    
Terraform Code
        
    terraform init
    terraform apply
        
    


Let's work together...

Would you like a cup of coffee?