This documentation entails the step-by-step guidelines to move an application to the cloud, while enabling AI to it.

CHALLENGE-ARCHITECTURE.png

Section 1: Automating AWS Provisioning with Terraform using Claude as an AI Assistant.

Claude is an artificial intelligence

Step 1: Prompt Claude to generate Terraform Code

  1. Navigate to claude.ai then sign up for a free account

  2. Start a Conversation with Claude

  3. Ask Claude to create Terraform code for an S3 bucket. Use a prompt like:

    “Act as a Terraform and AWS Expert and help me to create the configuration file to provision an S3 bucket on AWS.”

  4. Claude should generate code similar to this:

    # Configure the AWS Provider
    provider "aws" {
      region = "us-east-1"
      # credentials can be provided via AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables
      # or via shared credentials file (~/.aws/credentials) or IAM role
    }
    
    # Generate a random suffix to ensure bucket name uniqueness
    resource "random_pet" "bucket_suffix" {
      length = 2
      separator = "-"
    }
    
    # Create an S3 bucket with a unique name using the random suffix
    resource "aws_s3_bucket" "my_bucket" {
      bucket = "my-bucket-${random_pet.bucket_suffix.id}"
      
      tags = {
        Name        = "My bucket"
        Environment = "Dev"
      }
    }
    
    # Output the bucket name for reference
    output "bucket_name" {
      value = aws_s3_bucket.my_bucket.bucket
      description = "The name of the S3 bucket"
    }
    

Step 2: Create an IAM Role for EC2

  1. Log in to the AWS Management Console.

  2. Navigate to the IAM dashboard.

  3. Click “Roles” in the left sidebar, then “Create role”.

  4. Choose “AWS Service” as the trusted entity type and “EC2” as the use case.

  5. Search for and attach the “AdministratorAccess” policy.

    Note: In a production environment, use a more restricted policy.

  6. Name the role “EC2Admin” and provide a description.

  7. Review and create the role.

Step 3: Launch an EC2 Instance

  1. Go to the EC2 dashboard in the AWS Management Console.
  2. Click “Launch Instance”.