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
def make_parent_path(variables, prefix='') | |
h = {} | |
variables.each do |k,v| | |
key = "#{prefix}#{k.to_s}" | |
if v.is_a? Hash | |
h.merge!(make_parent_path(v, "#{key}.")) | |
else | |
h[key] = v | |
end | |
end |
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
#!/usr/bin/env ruby | |
# Quickly launch Amazon Linux EC2 instance in Default VPC. | |
# Launched EC2 automatically terminates itself after 1 day. | |
# Required to be set the below environment variables | |
# - AWS_DEFAULT_REGION | |
# - AWS_ACCESS_KEY | |
# - AWS_SECRET_KEY | |
# | |
# Usage : ruby launch.rb |
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
#!/usr/bin/env ruby | |
# EC2のイベント通知を検出するスクリプト | |
require 'aws-sdk-v1' | |
require 'credential_traverser' | |
require 'thread' | |
#AWS.config(logger: Logger.new($stdout), log_level: :debug) | |
CredentialTraverser.traverse do |profile| |
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
require 'aws-sdk' | |
# return 12 digits account number | |
# if failed, raise RuntimeError | |
def get_account_id | |
iam = AWS::IAM::Client.new | |
begin | |
iam.get_user.user.arn =~ /arn:aws:iam::(\d{12}):user\/.*/ | |
rescue => e | |
e.message =~ /arn:aws:iam::(\d{12}):user\/.*/ |
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
#!/usr/bin/env ruby | |
# Quickly launch Amazon Linux EC2 instance in Default VPC. | |
# Required to be set the below environment variables | |
# - AWS_DEFAULT_REGION | |
# - AWS_ACCESS_KEY | |
# - AWS_SECRET_KEY | |
# | |
# Usage : ruby launch.rb | |
require 'aws-sdk' |
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
#!/usr/bin/env ruby | |
# Activate Cloudtrail and create S3 Bucket in each region. | |
# Usage: ./activate.rb --profile <profile_name> | |
# or | |
# Usage: ./activate.rb -k <access_key> -s <secret_key> | |
require 'aws-sdk-v1' | |
require 'optparse' | |
begin |