Skip to content

Instantly share code, notes, and snippets.

@claydanford
Last active June 5, 2019 20:45
Show Gist options
  • Save claydanford/a3da778964493b56bd49ca12f27c6161 to your computer and use it in GitHub Desktop.
Save claydanford/a3da778964493b56bd49ca12f27c6161 to your computer and use it in GitHub Desktop.
Jenkins agent retrieves the API key and master instance infromation.
#cloud-config
runcmd:
- MASTER_ID=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names ${master_asg} --query 'AutoScalingGroups[0].Instances[0].InstanceId' --output text --region ${aws_region}) && echo $MASTER_ID > /opt/master_id.txt
- AGENT_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id) && echo $AGENT_ID > /opt/agent_id.txt
- MASTER_IP=$(aws ec2 describe-instances --instance-ids $(cat /opt/master_id.txt) --query 'Reservations[0].Instances[0].PrivateIpAddress' --output text --region ${aws_region}) && echo $MASTER_IP > /opt/master_ip.txt
- API_KEY=$(aws ssm get-parameter --name "${api_ssm_parameter}" --with-decryption --region ${aws_region} --output text --query 'Parameter.Value') && echo $API_KEY > /opt/api_key.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment