I am using AWS CodeCommit which seems to be like a stripped down version of git.
If all these EC2 instances have the same role tag how do I accomplish this?
I don't want to do anything fancy, all I want is to be specify a tag, click a button and all those EC2 instances with that tag pull for CodeCommit. I want to do this from my local machine.
I know I need to put the SSH keys to access CodeCommit in each of my EC2 servers and install git on each of them (I will bake this into an AMI). I'm just not sure how to "trigger" each of the EC2 machines to do a git pull? Is there an AWS command?
I am not a dev ops guy and only know basic linux and php.
Go to the instances section and click on "instances". It will show you all the running instances in the select region.
You can create a trigger for a CodeCommit repository so that events in that repository trigger notifications from an Amazon Simple Notification Service (Amazon SNS) topic.
For EC2 instances that are launched with an IAM role, you don't even have to bake in SSH keys. Git can get CodeCommit credentials from the EC2 instance metadata. Bake a Linux-based AMI with the latest AWS CLI package and the following lines in ~/.gitconfig:
[credential]
helper = !aws --profile default codecommit credential-helper $@
UseHttpPath = true
Launch the instance with an IAM role attached, and then you can clone your CodeCommit repo without any more setup.
You might want to look into Capistrano and Capify-EC2 if you want to run git commands across a fleet of EC2 instances based on tags.
Updated: If you're open to using AWS OpsWorks to deploy from CodeCommit, there's a recent blog article about how to do that. You can also use OpsWorks to run arbitrary commands across instances with Capistrano.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With