Home

Scale and Load Balance your Architecture: Step-by-Step And Troubleshooting Initial Setup and Configuration

Project Overview

This guide provides detailed instructions on creating an Amazon Machine Image (AMI) using the AWS Command Line Interface (CLI). It covers troubleshooting common issues like connectivity problems, authentication failures, and provides step-by-step guidance to successfully create an AMI.

Task 1: Connect to the EC2 Instance

Task 2: Troubleshooting EC2 Connectivity Issues

Instance in Private Subnet:

Make Subnet Public:

Assign Public IP to Instance:

Allocate a New Elastic IP Address:

  1. Navigate to the EC2 Dashboard in the AWS Management Console.
  2. Select Elastic IPs from the left-hand menu.
  3. Click on Allocate Elastic IP address.
  4. Click Allocate to get a new Elastic IP address.

Associate the Elastic IP with Your Instance:

  1. Select the newly allocated Elastic IP address.
  2. Click on Actions > Associate Elastic IP address.
  3. Choose Instance and select your instance from the dropdown menu.
  4. Click Associate. Navigate back to Instance Connect and it is successful.

Task 3: Install AWS CLI

If not already installed:

sudo apt-get install awscli # For Debian-based
sudo yum install awscli # For RHEL-based systems

Task 4: Configure AWS CLI Config And Credentials

aws configure

Task 5: Manually Editing Configuration Files In AWS Nano

Edit AWS Config File:

nano ~/.aws/config
[default]
output = json
region = us-west-2 # Replace with your preferred region

Edit AWS Credentials File In Nano:

nano ~/.aws/credentials
[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
aws_session_token = YOUR_SESSION_TOKEN # If using temporary credentials

Creating the AMI

Verify Instance ID:

curl http://169.254.169.254/latest/meta-data/instance-id

Create the AMI:

aws ec2 create-image \
--instance-id i-<> \
--name "MyCurrentInstanceAMI" \
--description "An AMI for demonstration purposes" \
--no-reboot

Task 6: Dealing With Encountered Issues and Resolutions

AuthFailure Error:

export AWS_ACCESS_KEY_ID=<your-access-key-id>
export AWS_SECRET_ACCESS_KEY=<your-secret-access-key-id>
export AWS_SESSION_TOKEN=<YOUR_SESSION_TOKEN>

Invalid Region Name:

[default]
output = json
region = us-west-2

Task 7: Final Steps and Verification

Verify Configuration:

aws configure list

Create the AMI:

aws ec2 create-image \
--instance-id <> \
--name "MyCurrentInstanceAMI" \
--description "An AMI for demonstration purposes" \
--no-reboot

Result:

Summary

Related Topics

These detailed steps should help you understand and replicate the process of configuring network settings for EC2 instance connect and creating an AMI using AWS CLI as well as trouble shooting errors that might happen in the process.