Closed varunchandak closed 6 years ago
@varunchandak Indeed being able to bulk create/delete/... resources with awless is central to daily devops. As you show, it can be done with piping in conjunction with extra flag and there are some good ideas in there.
Although, the key issue for me here is that we overlooked the create image
command ;) and I need to add it right now to awless!
In term of scripting bulk operations with awless
we have on our roadmap the idea to use the templating language along with a query language to be more powerful, consistent, predictible and type safe.
@varunchandak Creating an image from an instance is now available from master. Help, documentation and params can be seen with awless create image -h
.
As per your scenario, I created new images from my existing instances listing like so:
awless ls instances --columns name --format tsv --no-headers | xargs -I % awless create image instance=@% name=%-final -f
Important: First run it with only the listing of instances; then pipe in the other command but without the -f
(i.e. force without prompting) flag! It will show you the template list it is going to run. Then full run with the -f
flag.
Interesting points:
@
prefix on name that get resolved internally to their corresponding resource IDs), so we just have to list the name of the instance.--local
(or -l
) global flag when trying out scripts or piping awless commands is really useful (as it will get data instantaneously from the local graph, provided it was synced once). I have got an awl=awless --local
alias which comes in pretty handyLet me know how that works for you in the case of instances.
Works Perfectly !
Unfortunately, the target instance went into reboot after firing that command. I think no-reboot
should be made default. Guessing this was overlooked. Nevertheless the output looks good.
Waiting for this release.
Good! The reboot was not overlooked, I just kept the AWS default (as they suppose the user do not want to risk corruption with a running instance).
But I guess it makes sense and its more practical to have by default no reboot and specifying reboot=true
when needed.
I will modify that.
Currently, I have to use AWS CLI and awless in conjunction to meet certain requirements, such as creating an image from an ec2 instance. For a quickie, I use the following:
Can this be achieved something like this:
This can be extended to other resources such as security groups, volumes, etc, and also a good push towards more automation.