Here are the steps to install AWS CLI version 2 on Mac OS X.
--I have a Mac OSX PC --You can connect to the Internet --I have an AWS account --AWS CLI version 2 is for installation
Before you start, create an IAM user to work with the AWS CLI.
--AWS console - IAM --Access management> User --Add user --Username: (optional) --Access type: Programmatic access --Permission settings: (optional)
When you create a user, you will be assigned a ʻAccess key ID and a
Secret access key`.
Make a note of it as you will need it later when configuring.
Execute the command as shown in AWS Documents. It is a mystery whether the last backslash is needed.
Install awscli
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
After installing the AWS CLI, configure it next. It's like logging in.
You can give it any profile name. Creating a named profile makes it easier to switch users.
(For example, if you own another AWS account and want to use aws-cli on the same PC)
You will be asked four questions at the prompt.
Please read {Access key ID}
and {Secret access key}
as appropriate.
Specify the region and output format you like.
If you don't need to switch users, you don't need the --profile {profile name}
part.
Run configure
aws configure --profile {Profile name}
Execution result
AWS Access Key ID [None]: {Access key ID}
AWS Secret Access Key [None]: {Secret access key}
Default region name [None]: us-west-2
Default output format [None]: json
I will try to get the information of EC2 instance.
If you haven't created a named profile, you don't need the --profile {profile name}
part.
EC2 information acquisition
aws ec2 describe-instances --profile {Profile name}
Execution result
{
"Reservations": [
{
"Groups": [],
"Instances": [
{
"AmiLaunchIndex": 0,
"ImageId": "ami-XXXXXXXX",
"InstanceId": "i-XXXXXXXXXXXXXXXXX",
"InstanceType": "t2.nano",
"LaunchTime": "2020-01-01T00:00:00+00:00",
"Monitoring": {
"State": "disabled"
},
"Placement": {
"AvailabilityZone": "us-west-2b",
"GroupName": "",
"Tenancy": "default"
},
"PrivateDnsName": "ip-XXX-XXX-XXX-XXX.us-west-2.compute.internal",
"PrivateIpAddress": "XXX.XXX.XXX.XXX",
"ProductCodes": [],
"PublicDnsName": "ec2-XXX-XXX-XXX-XXX.us-west-2.compute.amazonaws.com",
"PublicIpAddress": "XXX.XXX.XXX.XXX",
"State": {
"Code": 16,
"Name": "running"
},
"StateTransitionReason": "",
"SubnetId": "subnet-XXXXXXXX",
"VpcId": "vpc-XXXXXXXX",
"Architecture": "x86_64",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"AttachTime": "2020-01-01T00:00:00+00:00",
"DeleteOnTermination": false,
"Status": "attached",
"VolumeId": "vol-XXXXXXXXXXXXXXXXX"
}
}
],
"ClientToken": "",
"EbsOptimized": false,
"EnaSupport": true,
"Hypervisor": "xen",
"NetworkInterfaces": [
{
"Association": {
"IpOwnerId": "XXXXXXXXXXXX",
"PublicDnsName": "ec2-XXX-XXX-XXX-XXX.us-west-2.compute.amazonaws.com",
"PublicIp": "XXX.XXX.XXX.XXX"
},
"Attachment": {
"AttachTime": "2020-01-01T00:00:00+00:00",
"AttachmentId": "eni-attach-XXXXXXXXXXXXXXXXX",
"DeleteOnTermination": true,
"DeviceIndex": 0,
"Status": "attached"
},
"Description": "",
"Groups": [
{
"GroupName": "XXXXXXXXXXXXXX",
"GroupId": "sg-XXXXXXXX"
}
],
"Ipv6Addresses": [],
"MacAddress": "XX:XX:XX:XX:XX:XX",
"NetworkInterfaceId": "eni-XXXXXXXXXXXXXXXXX",
"OwnerId": "XXXXXXXXXXXX",
"PrivateDnsName": "ip-XXX-XXX-XXX-XXX.us-west-2.compute.internal",
"PrivateIpAddress": "XXX.XXX.XXX.XXX",
"PrivateIpAddresses": [
{
"Association": {
"IpOwnerId": "XXXXXXXXXXXX",
"PublicDnsName": "ec2-XXX-XXX-XXX-XXX.us-west-2.compute.amazonaws.com",
"PublicIp": "XXX.XXX.XXX.XXX"
},
"Primary": true,
"PrivateDnsName": "ip-XXX-XXX-XXX-XXX.us-west-2.compute.internal",
"PrivateIpAddress": "XXX.XXX.XXX.XXX"
}
],
"SourceDestCheck": true,
"Status": "in-use",
"SubnetId": "subnet-XXXXXXXX",
"VpcId": "vpc-XXXXXXXX",
"InterfaceType": "interface"
}
],
"RootDeviceName": "/dev/xvda",
"RootDeviceType": "ebs",
"SecurityGroups": [
{
"GroupName": "XXXXXXXXXXXXXX",
"GroupId": "sg-XXXXXXXX"
}
],
"SourceDestCheck": true,
"VirtualizationType": "hvm",
"CpuOptions": {
"CoreCount": 1,
"ThreadsPerCore": 1
},
"CapacityReservationSpecification": {
"CapacityReservationPreference": "open"
},
"HibernationOptions": {
"Configured": false
},
"MetadataOptions": {
"State": "applied",
"HttpTokens": "optional",
"HttpPutResponseHopLimit": 1,
"HttpEndpoint": "enabled"
}
}
],
"OwnerId": "XXXXXXXXXXXX",
"ReservationId": "r-XXXXXXXXXXXXXXXXX"
}
]
}
Recommended Posts