aws configコマンドを利用することで、認証情報と設定ファイルを変更することができます。
[ec2-user@ip-10-0-0-187 ~]$ aws configure
AWS Access Key ID [****************33RA]:
AWS Secret Access Key [****************Ev7n]:
Default region name [ap-northeast-1]:
Default output format [text]:
Default output formatは、3種類あって、table, text, jsonが選べます。
それぞれの出力内容の違いは以下の通りです。
■table
[ec2-user@ip-10-0-0-187 ~]$ aws configure
AWS Access Key ID [****************33RA]:
AWS Secret Access Key [****************Ev7n]:
Default region name [ap-northeast-1]:
Default output format [text]: table
[ec2-user@ip-10-0-0-187 ~]$ aws ec2 describe-instances
-----------------------------------------------------------------------------------------
| DescribeInstances |
+---------------------------------------------------------------------------------------+
|| Reservations ||
|+-------------------------------------------+-----------------------------------------+|
|| OwnerId | 034872295764 ||
|| ReservationId | r-e2c45510 ||
|+-------------------------------------------+-----------------------------------------+|
||| Instances |||
||+------------------------+----------------------------------------------------------+||
||| AmiLaunchIndex | 0 |||
||| Architecture | x86_64 |||
||| ClientToken | NrYkf1452264732183 |||
||| EbsOptimized | False |||
||| Hypervisor | xen |||
||| ImageId | ami-383c1956 |||
||| InstanceId | i-21a8e284 |||
||| InstanceType | t2.nano |||
||| KeyName | mykey |||
||| LaunchTime | 2016-01-25T23:11:06.000Z |||
||| PrivateDnsName | ip-10-0-0-187.ap-northeast-1.compute.internal |||
||| PrivateIpAddress | 10.0.0.187 |||
||| PublicDnsName | ec2-xx-xx-xxx-xx.ap-northeast-1.compute.amazonaws.com |||
||| PublicIpAddress | xx.xx.xxx.xx |||
||| RootDeviceName | /dev/xvda |||
||| RootDeviceType | ebs |||
||| SourceDestCheck | True |||
||| StateTransitionReason | |||
||| SubnetId | subnet-83ade9f4 |||
||| VirtualizationType | hvm |||
||| VpcId | vpc-98593efd |||
||+------------------------+----------------------------------------------------------+||
|||| BlockDeviceMappings ||||
|||+-----------------------------------------+---------------------------------------+|||
|||| DeviceName | /dev/xvda ||||
|||+-----------------------------------------+---------------------------------------+|||
||||| Ebs |||||
||||+-----------------------------------+-------------------------------------------+||||
||||| AttachTime | 2016-01-25T23:10:40.000Z |||||
||||| DeleteOnTermination | False |||||
||||| Status | attached |||||
||||| VolumeId | vol-dfc38f20 |||||
||||+-----------------------------------+-------------------------------------------+||||
|||| Monitoring ||||
|||+----------------------------------+----------------------------------------------+|||
|||| State | disabled ||||
|||+----------------------------------+----------------------------------------------+|||
|||| NetworkInterfaces ||||
|||+------------------------+--------------------------------------------------------+|||
|||| Description | Primary network interface ||||
|||| MacAddress | 06:94:95:b5:63:d7 ||||
|||| NetworkInterfaceId | eni-77f3c13e ||||
|||| OwnerId | 034872295764 ||||
|||| PrivateDnsName | ip-10-0-0-187.ap-northeast-1.compute.internal ||||
|||| PrivateIpAddress | 10.0.0.187 ||||
|||| SourceDestCheck | True ||||
|||| Status | in-use ||||
|||| SubnetId | subnet-83ade9f4 ||||
|||| VpcId | vpc-98593efd ||||
|||+------------------------+--------------------------------------------------------+|||
||||| Association |||||
||||+----------------+--------------------------------------------------------------+||||
||||| IpOwnerId | 034872295764 |||||
||||| PublicDnsName | ec2-xx-xx-xxx-xx.ap-northeast-1.compute.amazonaws.com |||||
||||| PublicIp | xx.xx.xxx.xx |||||
||||+----------------+--------------------------------------------------------------+||||
||||| Attachment |||||
||||+-----------------------------------+-------------------------------------------+||||
||||| AttachTime | 2016-01-08T14:52:12.000Z |||||
||||| AttachmentId | eni-attach-08c08e13 |||||
||||| DeleteOnTermination | True |||||
||||| DeviceIndex | 0 |||||
||||| Status | attached |||||
||||+-----------------------------------+-------------------------------------------+||||
||||| Groups |||||
||||+------------------------------------+------------------------------------------+||||
||||| GroupId | sg-9e7a6afb |||||
||||| GroupName | ogura-test |||||
||||+------------------------------------+------------------------------------------+||||
||||| PrivateIpAddresses |||||
||||+---------------------+---------------------------------------------------------+||||
||||| Primary | True |||||
||||| PrivateDnsName | ip-10-0-0-187.ap-northeast-1.compute.internal |||||
||||| PrivateIpAddress | 10.0.0.187 |||||
||||+---------------------+---------------------------------------------------------+||||
|||||| Association ||||||
|||||+----------------+------------------------------------------------------------+|||||
|||||| IpOwnerId | 034872295764 ||||||
|||||| PublicDnsName | ec2-xx-xx-xxx-xx.ap-northeast-1.compute.amazonaws.com ||||||
|||||| PublicIp | xx.xx.xxx.xx ||||||
|||||+----------------+------------------------------------------------------------+|||||
|||| Placement ||||
|||+-----------------------------------------+---------------------------------------+|||
|||| AvailabilityZone | ap-northeast-1a ||||
|||| GroupName | ||||
|||| Tenancy | default ||||
|||+-----------------------------------------+---------------------------------------+|||
|||| SecurityGroups ||||
|||+-------------------------------------+-------------------------------------------+|||
|||| GroupId | sg-9e7a6afb ||||
|||| GroupName | ogura-test ||||
|||+-------------------------------------+-------------------------------------------+|||
|||| State ||||
|||+---------------------------------+-----------------------------------------------+|||
|||| Code | 16 ||||
|||| Name | running ||||
|||+---------------------------------+-----------------------------------------------+|||
|||| Tags ||||
|||+-----------------------------+---------------------------------------------------+|||
|||| Key | Name ||||
|||| Value | ogura-test1 ||||
|||+-----------------------------+---------------------------------------------------+|||
■text
[ec2-user@ip-10-0-0-187 ~]$ aws configure
AWS Access Key ID [****************33RA]:
AWS Secret Access Key [****************Ev7n]:
Default region name [ap-northeast-1]:
Default output format [table]: text
[ec2-user@ip-10-0-0-187 ~]$ aws ec2 describe-instances
RESERVATIONS 034872295764 r-e2c45510
INSTANCES 0 x86_64 NrYkf1452264732183 False xen ami-383c1956 i-21a8e284 t2.nano mykey 2016-01-25T23:11:06.000Z ip-10-0-0-187.ap-northeast-1.compute.internal 10.0.0.187 ec2-xx-xx-xxx-xx.ap-northeast-1.compute.amazonaws.com xx.xx.xxx.xx /dev/xvda ebs True subnet-83ade9f4 hvm vpc-98593efd
BLOCKDEVICEMAPPINGS /dev/xvda
EBS 2016-01-25T23:10:40.000Z False attached vol-dfc38f20
MONITORING disabled
NETWORKINTERFACES Primary network interface 06:94:95:b5:63:d7 eni-77f3c13e 034872295764 ip-10-0-0-187.ap-northeast-1.compute.internal 10.0.0.187 True in-use subnet-83ade9f4 vpc-98593efd
ASSOCIATION 034872295764 ec2-xx-xx-xxx-xx.ap-northeast-1.compute.amazonaws.com xx.xx.xxx.xx
ATTACHMENT 2016-01-08T14:52:12.000Z eni-attach-08c08e13 True 0 attached
GROUPS sg-9e7a6afb ogura-test
PRIVATEIPADDRESSES True ip-10-0-0-187.ap-northeast-1.compute.internal 10.0.0.187
ASSOCIATION 034872295764 ec2-xx-xx-xxx-xx.ap-northeast-1.compute.amazonaws.com xx.xx.xxx.xx
PLACEMENT ap-northeast-1a default
SECURITYGROUPS sg-9e7a6afb ogura-test
STATE 16 running
TAGS Name ogura-test1
■json
[ec2-user@ip-10-0-0-187 ~]$ aws configure
AWS Access Key ID [****************33RA]:
AWS Secret Access Key [****************Ev7n]:
Default region name [ap-northeast-1]:
Default output format [text]: json
[ec2-user@ip-10-0-0-187 ~]$ aws ec2 describe-instances
{
"Reservations": [
{
"OwnerId": "034872295764",
"ReservationId": "r-e2c45510",
"Groups": [],
"Instances": [
{
"Monitoring": {
"State": "disabled"
},
"PublicDnsName": "ec2-xx-xx-xxx-xx.ap-northeast-1.compute.amazonaws.com",
"State": {
"Code": 16,
"Name": "running"
},
"EbsOptimized": false,
"LaunchTime": "2016-01-25T23:11:06.000Z",
"PublicIpAddress": "xx.xx.xxx.xx",
"PrivateIpAddress": "10.0.0.187",
"ProductCodes": [],
"VpcId": "vpc-98593efd",
"StateTransitionReason": "",
"InstanceId": "i-21a8e284",
"ImageId": "ami-383c1956",
"PrivateDnsName": "ip-10-0-0-187.ap-northeast-1.compute.internal",
"KeyName": "mykey",
"SecurityGroups": [
{
"GroupName": "ogura-test",
"GroupId": "sg-9e7a6afb"
}
],
"ClientToken": "NrYkf1452264732183",
"SubnetId": "subnet-83ade9f4",
"InstanceType": "t2.nano",
"NetworkInterfaces": [
{
"Status": "in-use",
"MacAddress": "06:94:95:b5:63:d7",
"SourceDestCheck": true,
"VpcId": "vpc-98593efd",
"Description": "Primary network interface",
"Association": {
"PublicIp": "xx.xx.xxx.xx",
"PublicDnsName": "ec2-xx-xx-xxx-xx.ap-northeast-1.compute.amazonaws.com",
"IpOwnerId": "034872295764"
},
"NetworkInterfaceId": "eni-77f3c13e",
"PrivateIpAddresses": [
{
"PrivateDnsName": "ip-10-0-0-187.ap-northeast-1.compute.internal",
"Association": {
"PublicIp": "xx.xx.xxx.xx",
"PublicDnsName": "ec2-xx-xx-xxx-xx.ap-northeast-1.compute.amazonaws.com",
"IpOwnerId": "034872295764"
},
"Primary": true,
"PrivateIpAddress": "10.0.0.187"
}
],
"PrivateDnsName": "ip-10-0-0-187.ap-northeast-1.compute.internal",
"Attachment": {
"Status": "attached",
"DeviceIndex": 0,
"DeleteOnTermination": true,
"AttachmentId": "eni-attach-08c08e13",
"AttachTime": "2016-01-08T14:52:12.000Z"
},
"Groups": [
{
"GroupName": "ogura-test",
"GroupId": "sg-9e7a6afb"
}
],
"SubnetId": "subnet-83ade9f4",
"OwnerId": "034872295764",
"PrivateIpAddress": "10.0.0.187"
}
],
"SourceDestCheck": true,
"Placement": {
"Tenancy": "default",
"GroupName": "",
"AvailabilityZone": "ap-northeast-1a"
},
"Hypervisor": "xen",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"Status": "attached",
"DeleteOnTermination": false,
"VolumeId": "vol-dfc38f20",
"AttachTime": "2016-01-25T23:10:40.000Z"
}
}
],
"Architecture": "x86_64",
"RootDeviceType": "ebs",
"RootDeviceName": "/dev/xvda",
"VirtualizationType": "hvm",
"Tags": [
{
"Value": "ogura-test1",
"Key": "Name"
}
],
"AmiLaunchIndex": 0
}
]
}
]
}