Skip to content

Instantly share code, notes, and snippets.

@akira345
Last active February 8, 2016 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akira345/93dff2ba1ca8a57ac9ed to your computer and use it in GitHub Desktop.
Save akira345/93dff2ba1ca8a57ac9ed to your computer and use it in GitHub Desktop.
AWSでVPC/サブネット上でプライベートIPがぶつかっていないかチェックするメモ。AWS SDK for Ruby V1使用。動くRubyスクリプトではないので注意。
vpc_id = ""
subnet_id=""
private_ip = ""
#すでにローカルIPが使用されていないか?
ary_ips = []
ec2.client.describe_network_interfaces(filters: [{ name: "vpc-id",values: [vpc_id]},{name: "subnet-id",values: [subnet_id]}])[:network_interface_set].each {|d|
d[:private_ip_addresses_set].each {|dd|
ary_ips.push(dd[:private_ip_address])
}
}
if ary_ips.include?(private_ip)
pp "Duplicate Private IP!!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment