TheSemicolon
TheSemicolon

Reputation: 87

Create EC2 instances after they are terminated using "update" from service catalog product

I have 2 EC2 instances spawned using service catalog product provisioning. For some reasons, I have terminated them both and want to spawn new EC2 instances back (Not the terminated ones). So I tried to update the product again from service catalog and was hoping the service catalog would create them back because the earlier instances are not present. Product provisioning is successful and yet the EC2 instances are not created.

My product is actually a full stack comprising of some sub-stacks and one of the sub-stack actually creates the EC2 instance.

We could envision this as below -

Full Stack

Question is how to get the new EC2 instances created without having to terminate the full stack.

More info on permission for these -
I have 2 roles that I have used to achieve this. 1 role is used only to provision products from service catalog. Other is admin like role that I can use to terminate the EC2 instance. I just don't want to spawn the EC2's from the admin role and use the products to provision them.

Upvotes: 1

Views: 869

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 270224

AWS CloudFormation is not "aware" of resources changes made outside of its control. So, it currently thinks that the EC2 instances still exist, even though they have been terminated.

If you have sufficient permissions to use CloudFormation, you could:

  • Download the CloudFormation template that was deployed by Service Catalog
  • Remove the section that defines the EC2 instances
  • Update the stack by providing the edited template -- this will cause CloudFormation to terminate the instances (that are already terminated)
  • Edit the template and add back the instance definitions, then Update the stack again with this template (effectively the same template that was originally used to launch the stack) -- this should cause new instances to be deployed that match the original specification

Upvotes: 2

Related Questions