0 votes
1 view
in AWS by (18.2k points)

I want to create an EC2 cloudformation stack which basically can be described in the following steps:

1.- Launch instance

2.- Provision the instance

3.- Stop the instance and create an AMI image out of it

4.- Create an autoscaling group with the created AMI image as a source to launch new instances.

Basically I can do 1 and 2 in one cloudformation template and 4 in a second template. What I don't seem able to do is to create an AMI image from an instance inside a cloudformation template, which basically generates the problem of having to manually remove the AMI if I want to remove the stack.

That being said, my questions are:

1.- Is there a way to create an AMI image from an instance INSIDE the cloudformation template?

2.- If the answer to 1 is no, is there a way to add an AMI image (or any other resource for that matter) to make it part of a completed stack?

1 Answer

0 votes
by (42.5k points)

1. Create an initial instance with a cloudformation template

2. Create, using Ansible, an AMI of the instance created on step 1

3. Create the remainder of the stack (ELB, auto scaling groups, etc) with a second cloudformation template that updates the one created on step one, which uses the AMI created on step 2 to launch instances.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...