Last active
December 12, 2015 05:29
-
-
Save okochang/4722251 to your computer and use it in GitHub Desktop.
AWS::EC2::Clientクライアントを使って色々とdescribeするサンプル
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
# -*- coding: utf-8 -*- | |
require 'aws-sdk' | |
ACCESS_KEY = "set your access key id" | |
SECRET_KEY = "set your secret key" | |
REGION = 'ec2.ap-northeast-1.amazonaws.com' | |
ec2 = AWS::EC2.new( | |
:access_key_id => ACCESS_KEY, | |
:secret_access_key => SECRET_KEY, | |
:ec2_endpoint => REGION | |
).client | |
## EC2インスタンスの場合 | |
ec2.describe_instances(options = {:instance_ids => ["i-xxxxxxxx"]}) | |
## このような形に省力する事も出来ます ※以降の内容も同様に省略可能です | |
ec2.describe_instances(:instance_ids => ["i-xxxxxxxx"]) | |
## Availability Zoneの場合 | |
ec2.describe_availability_zones(options = {:zone_names => ["ap-northeast-1a"]}) | |
## AMIの場合 | |
ec2.describe_images(options = {:image_ids => ["ami-xxxxxxxx"]}) | |
## EIPの場合 | |
ec2.describe_addresses(options = {:public_ips => ["xx.xxx.xx.xxx"]}) | |
## VPCの場合 | |
ec2.describe_vpcs(options = {:vpc_ids => ["vpc-xxxxxxxx"]}) | |
## VPC Subnetの場合 | |
ec2.describe_subnets(options = {:subnet_ids => ["subnet-xxxxxxxx"]}) | |
## Route Tableの場合 | |
ec2.describe_route_tables(options = {:route_table_ids => ["rtb-xxxxxxxx"]}) | |
## Internet Gatewayの場合 | |
ec2.describe_internet_gateways(options = {:internet_gateway_ids => ["igw-xxxxxxxx"]}) | |
## Virtual Private Gatewayの場合 | |
ec2.describe_vpn_gateways(options = {:vpn_gateway_ids => ["vgw-xxxxxxxx"]}) | |
## Customer Gatewayの場合 | |
ec2.describe_customer_gateways(options = {:customer_gateway_ids => ["cgw-xxxxxxxx"]}) | |
## VPNコネクションの場合 | |
ec2.describe_vpn_connections(options = {:vpn_connection_ids => ["vpn-xxxxxxxx"]}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment