Skip to content

Instantly share code, notes, and snippets.

@pmoranga
Created February 15, 2016 23:46
Show Gist options
  • Save pmoranga/2db7b5d1e0c120a7de70 to your computer and use it in GitHub Desktop.
Save pmoranga/2db7b5d1e0c120a7de70 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