I’m trying to update my launch configurations by using the aws autoscaling describe-launch-configurations command, manipulating the fields with jq in bash, and then creating a new launch configuration with aws autoscaling create-launch-configurations --cli-input-json.
So far, it’s actually worked pretty well except for the userData field which needs to be decoded from base64 to utf8 but once I do so, it has the shebang on a new line and creates a mess in the JSON. Has anyone successfully used the --cli-input-json command with written userData?
Please help!
PS If anyone has a better way to update launch configurations via the CLI, let me know!
Most of my launch configurations are inside a cloudformation stack. When I need to update the launch config, I update the cloudformation stack and it handles the messy stuff inside.
For example, if I have a new AMI for a deployment, I update the AMI parameter on the CF stack and it creates the new LC and updates the active LC on the scaling group.
Hmm that’s normally what i would do but i’m trying to automate the process a little more so that i dont have to manually update the actual cloudformation template. Plus, wouldnt that involve tearing down the stack and then standing it back up? Maybe 10-15 mins?
Can you change the user data to download/clone a script from a repo and run that? Then you can easily iterate that script and keep the user data script static.
user-data can be string value or file path value starting with “file://”. i’d suggest decoding redix format straight to file buffer and pass that buffer file as user-data instead of this decode-then-re-encode base64 to plain text back into base64 nonsense.
I wasn’t sure if you can pass the file path in when using the --cli-input-flag. I thought everything had to be “raw” json data? There’s not much docs about it
you just have to make sure userData is missing in cli-input-json data. cli-input-json doesn’t generally clobber other command arguments, but i would be lying if that’s the case for all (emr is notriously known for being the black sheep of awscli).