-1

One of my developer is creating a Images and they are storing in AWS, and I can see them under Images --> AMI.

Now here my request starts -

I want to take the latest AMI and launch EC2. So how can I write JSON to call the latest AMI and launch EC2.

Can you please help me quickly. Thanks in Advance!

1 Answers1

0

You have two options:

  • Determine the AMI to use, and then pass that value to the CloudFormation template as a Parameter. Whatever code you use to launch the template would be responsible for doing a lookup on the AMI to use, so it is happening before CloudFormation is called.
  • Use a Custom Resource in CloudFormation that can call a Lambda function, which would determine the AMI to use. The Lambda function would return the value to CloudFormation, which would then use that value to launch the instance.

Either way, you would need to write code to perform your logic. It cannot be done within the JSON itself.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470