Skip to content

Instantly share code, notes, and snippets.

@Phelms215
Created September 30, 2014 15:51
Show Gist options
  • Save Phelms215/349f99b669c9225edbb1 to your computer and use it in GitHub Desktop.
Save Phelms215/349f99b669c9225edbb1 to your computer and use it in GitHub Desktop.
#
# 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
puts instance_id
puts region
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("TEST")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment