Skip to content

Instantly share code, notes, and snippets.

@jarosite
Last active August 29, 2015 14:27
Show Gist options
  • Save jarosite/61936e241e91738ba719 to your computer and use it in GitHub Desktop.
Save jarosite/61936e241e91738ba719 to your computer and use it in GitHub Desktop.
Puppet external fact for EC2 Tags
#!/bin/bash
region=`facter ec2_placement_availability_zone | sed 's/[a-z]$//g'`
instanceId=`facter ec2_instance_id`
/usr/bin/aws ec2 describe-tags --filters "Name=resource-id,Values=${instanceId}" --region ${region} | jq '.Tags[] | "ec2_tag_" + .Key + "=" + .Value' | tr [:upper:] [:lower:] | tr -d '"'
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment