Skip to content

t2yijaeho/Custom-AMI-EC2-with-CloudFormation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom AMI Amazon EC2 with AWS CloudFormation

1. Launch AWS CloudShell

2. Create an Amazon EC2

1. Get an AWS CloudFormation stack template body

wget https://github.com/t2yijaeho/Custom-AMI-EC2-with-CloudFormation/raw/matia/Template/EC2-MigVM.yaml
  • For Spot instance
wget https://github.com/t2yijaeho/Custom-AMI-EC2-with-CloudFormation/raw/matia/Template/EC2-MigSpot.yaml

2. Get your local machine public IP address in the browser

3. Create an AWS CloudFormation stack

  • Change <My Custom Image ID> to your Custom Amazon Machine Image ID

  • Change <My IP> to your local machine IP address (ParameterValue must be in CIDR block)

aws cloudformation create-stack \
    --stack-name MigrationVM \
    --template-body file://./EC2-MigVM.yaml \
    --parameters ParameterKey=CustomImageID,ParameterValue="<My Custom Image ID>" \
    ParameterKey=LocalLocation,ParameterValue="<My IP>/32"
aws cloudformation create-stack \
    --stack-name MigrationVM \
    --template-body file://./EC2-MigSpot.yaml \
    --parameters ParameterKey=CustomImageID,ParameterValue="<My Custom Image ID>" \
    ParameterKey=LocalLocation,ParameterValue="<My IP>/32"

4. AWS CloudFormation returns following output

{
"StackId": "arn:aws:cloudformation:us-abcd-x:123456789012:stack/MigrationVM/b4d0f5e0-d4c2-11ec-9529-06edcc65f112"
}

5. Monitor the progress by the stack's events in AWS management console

About

Custom AMI EC2 with CloudFormation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published