Reputation: 662
I am working on solving a problem, I have userdata as a part of launch config in EC2 instance, which installs aws cli and python package, sometimes the aws cli and python does not get installed and the EC2 instance is up and running.
Code in my userdata
pip install awscli
To solve this i was looking into the aws documentation.I found there are two ways to solve this problem using Waitcondition with cfn-signal and using Creation policy.
I was wondering which is the way forward in my case.
Upvotes: 2
Views: 1514
Reputation: 857
AWS documentation says:
For Amazon EC2 and Auto Scaling resources, we recommend that you use a CreationPolicy attribute instead of wait conditions.
Add a CreationPolicy attribute to those resources, and use the cfn-signal helper script to signal when an instance creation process has completed successfully.
You can use a wait condition for situations like the following:
To coordinate stack resource creation with configuration actions that are external to the stack creation.
Because your EC2 instance is a part of cf stack, you should use CreationPolicy attribute. Check here for more information.
Upvotes: 2
Reputation: 14462
Third way and probably the easiest one is to pre-bake a custom AMI where you can manually install aws cli
and the mentioned python package, and debug any problem that may occur.
Then, instead of running new EC2 instance with user-data
script, just run your custom AMI with the mentioned configuration already in place. That way, your instance will boot up faster and you don't have to worry about any errors that may occur during that script execution as that script has already been executed and tested.
Upvotes: 0