Skip to content

Instantly share code, notes, and snippets.

@tikg
Last active November 6, 2025 01:14
Show Gist options
  • Select an option

  • Save tikg/f172d1b0767c85609b933e9113493927 to your computer and use it in GitHub Desktop.

Select an option

Save tikg/f172d1b0767c85609b933e9113493927 to your computer and use it in GitHub Desktop.
Docker Kubernetes(minikube) Terraform and ec2

Docker Kubernetes(minikube) Terraform and ec2

checking if AMI ID exists

tik@tik-1tb:/media/tik/1TB_02/lab/terra-aws$ aws ec2 describe-images --region us-west-1 --image-ids ami-01f10c2eaffc9c7e5

An error occurred (InvalidAMIID.NotFound) when calling the DescribeImages operation: The image id '[ami-01f10c2eaffc9c7e5]' does not exist

Checking endpoint LOL!

tik-1tb:/media/tik/1TB_02/lab/terra-aws$ aws ec2 describe-images 

Could not connect to the endpoint URL: "https://ec2.Wakaranai.amazonaws.com/"
tik-1tb:/media/tik/1TB_02/lab/terra-aws$ 

Figuring out the correct endpoint:

image image

via

tik@tik-1tb:/media/tik/1TB_02/lab/terra-aws$ aws configure
AWS Access Key ID [****************ZRHI]: 
AWS Secret Access Key [****************wfJH]: 
Default region name [Wakaranai]: ap-southeast-2
Default output format [None]: 
tik@tik-1tb:/media/tik/1TB_02/lab/terra-aws$ 
tik@tik-1tb:/media/tik/1TB_02/lab/terra-aws$ aws ec2 describe-images 
{
    "Images": [
        {
            "PlatformDetails": "Linux/UNIX",
            "UsageOperation": "RunInstances",
            "BlockDeviceMappings": [
                {
                    "Ebs": {
                        "DeleteOnTermination": true,
                        "SnapshotId": "snap-0e7ffdc13f467e7a3",
                        "VolumeSize": 8,
                        "VolumeType": "gp2",
                        "Encrypted": false
                    },
                    "DeviceName": "/dev/xvda"

Instances View (None yet)

image

Checking ap-south-east1 and us-east-1

  • I overlooked the fact and saw that the top right corner from where my dashboard was in "ap-southeast-1" and the AMI that was free and eligible was in "us-east-1"
  • I changed my dashboard region to "us-east-1" (N. Virginia) and was able to successfully deploy my EC2 Instance with Terraform
  • image
image

Wuhoo!... GUI View (updated)

image

Next step is to create log in and SSH

Had to allow traffic via Security Groups

  • Allowed ICMP v4 and SSH traffic from 0.0.0.0/0
image

Result

image

Voila! Able to login

tik@tik-1tb:~/Downloads$ date
Wed Nov  5 01:59:20 PM JST 2025
tik@tik-1tb:~/Downloads$ 
tik@tik-1tb:~/Downloads$ 
tik@tik-1tb:~/Downloads$ ssh -i tt-amazon-ec2_us-east-1.pem [email protected]
Register this system with Red Hat Insights: rhc connect

Example:
# rhc connect --activation-key <key> --organization <org>

The rhc client and Red Hat Insights will enable analytics and additional
management capabilities on your system.
View your connected systems at https://console.redhat.com/insights

You can learn more about how to register your system 
using rhc at https://red.ht/registration
Last login: Wed Nov  5 04:59:11 2025 from 219.104.144.0
[ec2-user@ip-172-31-28-17 ~]$ 
[ec2-user@ip-172-31-28-17 ~]$ date
Wed Nov  5 04:59:27 UTC 2025
[ec2-user@ip-172-31-28-17 ~]$ 

Parsing data from Terraform Show

There are other ways, but this is the laziest one image

Able to stop the instance, need to aws configure before execution

An error occurred (InvalidInstanceID.NotFound) when calling the StopInstances operation: The instance ID 'i-0f8243b62b7ae9852' does not exist
tik@tik-1tb:~/Downloads$ aws configure
AWS Access Key ID [****************ZRHI]: 
AWS Secret Access Key [****************wfJH]: 
Default region name [ap-southeast-2]: us-east-1
Default output format [None]: 
tik@tik-1tb:~/Downloads$ aws ec2 stop-instances --instance-ids i-0f8243b62b7ae9852
{
    "StoppingInstances": [
        {
            "InstanceId": "i-0f8243b62b7ae9852",
            "CurrentState": {
                "Code": 64,
                "Name": "stopping"
            },
            "PreviousState": {
                "Code": 16,
                "Name": "running"
            }
        }
    ]
}
tik@tik-1tb:~/Downloads$ 
  • Screen
image image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment