Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -e
if [ $# -eq 0 ]; then
echo "USAGE: $0 plugin1 plugin2 ..."
exit 1
fi
plugin_dir=/var/lib/jenkins/plugins
Try this - it requires that you have the AWS command line tools installed and that your instance has either been assigned an IAM role with sufficent permissions, or that your AWS command line tools have been set up with the right credentials. You should use IAM roles if you want to get this info at first boot, which I suspect is what you want to use this for?
aws ec2 describe-instances --region eu-west-1 --output text --instance-ids `curl -s http://169.254.169.254/latest/meta-data/instance-id` | grep TAGS
If you create an IAM role called AllowDescribeInstances with the following policy this and assign it to your instances, this is the minimum permissions set that is required.
{
"Version": "2012-10-17",
"Statement": [