Created
September 30, 2014 15:20
-
-
Save Phelms215/4928e7b0e340298d32da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name:: basic | |
# Recipe:: windows | |
# | |
# Copyright 2014, Information Logistics Inc | |
# | |
# All rights reserved - Do Not Redistribute | |
# | |
instance = open('http://169.254.169.254/latest/meta-data/instance-id') { |io| data = io.read } | |
availability_zone =open('http://169.254.169.254/latest/meta-data/placement/availability-zone') { |io| data = io.read } | |
region = availability_zone.to_s.chop | |
instance_id = instance.to_s.chomp | |
command = `aws ec2 describe-tags --filters "Name=resource-id,Values=#{instance_id}" "Name=tag-key,Values=ChefTags" --region #{region} --query "Tags[*].Value"` | |
TagsArray = command.to_s.chomp.split(",") | |
TagsArray.each do |key| | |
if not tagged?(key) | |
tag(key) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment