AWS - CLI
Command Line
いろいろ試してみる
EC2 CLI
現在利用可能なリージョン一覧を表示
$ aws --output table ec2 describe-regions
-------------------------------------------------------
| DescribeRegions |
+-----------------------------------------------------+
|| Regions ||
|+----------------------------------+----------------+|
|| Endpoint | RegionName ||
|+----------------------------------+----------------+|
|| ec2.eu-central-1.amazonaws.com | eu-central-1 ||
|| ec2.sa-east-1.amazonaws.com | sa-east-1 ||
|| ec2.ap-northeast-1.amazonaws.com | ap-northeast-1 ||
|| ec2.eu-west-1.amazonaws.com | eu-west-1 ||
|| ec2.us-east-1.amazonaws.com | us-east-1 ||
|| ec2.us-west-1.amazonaws.com | us-west-1 ||
|| ec2.us-west-2.amazonaws.com | us-west-2 ||
|| ec2.ap-southeast-1.amazonaws.com | ap-southeast-1 ||
|| ec2.ap-southeast-2.amazonaws.com | ap-southeast-2 ||
|+----------------------------------+----------------+|
VPCの一覧表示例
$ aws --output table ec2 describe-vpcs
-------------------------------------------------------------------------------------------
| DescribeVpcs |
+-----------------------------------------------------------------------------------------+
|| Vpcs ||
+---------------+---------------+-----------------+-----------+-----------+--------------+|
| CidrBlock | DhcpOptionsId | InstanceTenancy | IsDefault | State | VpcId ||
+---------------+---------------+-----------------+-----------+-----------+--------------+|
| 172.31.0.0/16 | dopt-12345678 | default | True | available | vpc-12345678 ||
+---------------+---------------+-----------------+-----------+-----------+--------------+|
サブネット一覧表示
$ aws --output table ec2 describe-subnets
----------------------------------------------------------------------------------------------------------------------
| DescribeSubnets |
+--------------------------------------------------------------------------------------------------------------------+
|| Subnets ||
|+-----------------+-----------+----------------+---------+------------+-----------+-----------------+--------------+|
|| Availability | Available | CidrBlock | Default | MapPublic | State | SubnetId | VpcId ||
|| Zone | IpAddress | | ForAz | InOnLaunch | | | ||
|| | Count | | | | | | ||
|+-----------------+-----------+----------------+---------+------------+-----------+-----------------+--------------+|
|| ap-northeast-1c | 4091 | 172.31.16.0/20 | True | True | available | subnet-00001111 | vpc-00001111 ||
|| ap-northeast-1a | 4091 | 172.31.0.0/20 | True | True | available | subnet-22223333 | vpc-22223333 ||
|+-----------------+-----------+----------------+---------+------------+-----------+-----------------+--------------+|
アベイラビリティゾーン一覧
$ aws --output table ec2 describe-availability-zones
--------------------------------------------------
| DescribeAvailabilityZones |
+------------------------------------------------+
|| AvailabilityZones ||
|+----------------+-----------+-----------------+|
|| RegionName | State | ZoneName ||
|+----------------+-----------+-----------------+|
|| ap-northeast-1 | available | ap-northeast-1a ||
|+----------------+-----------+-----------------+|
|| ap-northeast-1 | available | ap-northeast-1c ||
|+----------------+-----------+-----------------+|
インターネットゲートウェイの表示
$ aws --output table ec2 describe-internet-gateways
--------------------------------
| DescribeInternetGateways |
+------------------------------+
|| InternetGateways ||
|+----------------------------+|
|| InternetGatewayId ||
|+----------------------------+|
|| igw-12345678 ||
|+----------------------------+|
||| Attachments |||
||+-----------+--------------+||
||| State | VpcId |||
||+-----------+--------------+||
||| available | vpc-12345678 |||
||+-----------+--------------+||
ネットワークACLの表示
$ aws --output table ec2 describe-network-acls
------------------------------------------------------------
| DescribeNetworkAcls |
+----------------------------------------------------------+
|| NetworkAcls ||
|+-----------+--------------+-----------------------------+|
|| IsDefault | NetworkAclId | VpcId ||
|+-----------+--------------+-----------------------------+|
|| True | acl-11112222 | vpc-11112222 ||
|+-----------+--------------+-----------------------------+|
||| Associations |||
||+-------------------+--------------+-------------------+||
||| NetworkAcl | NetworkAclId | SubnetId |||
||| AssociationId | | |||
||+-------------------+--------------+-------------------+||
||| aclassoc-11112222 | acl-11112222 | subnet-11112222 |||
||| aclassoc-33334444 | acl-33334444 | subnet-33334444 |||
||+-------------------+--------------+-------------------+||
||| Entries |||
||+-----------+--------+----------+--------+-------------+||
||| CidrBlock | Egress | Protocol | Rulen | RuleNumber |||
||| | | | Action | RuleNumber |||
||+-----------+--------+----------+--------+-------------+||
||| 0.0.0.0/0 | True | -1 | allow | 100 |||
||| 0.0.0.0/0 | True | -1 | deny | 32767 |||
||| 0.0.0.0/0 | False | -1 | allow | 100 |||
||| 0.0.0.0/0 | False | -1 | deny | 32767 |||
||+-----------+--------+----------+--------+-------------+||