Compute - List Instances - AWS CLI
Aim
Details of the output from Ansible
AWS CLI
$ cd awscli/
$ source ../../../providers/aws/setup.bash
$ ./compute-list-instances.bash
+ echo 'An example of Listing EC2 Instances'
An example of Listing EC2 Instances
+ aws ec2 describe-instances --profile=alphatest --region=eu-west-2 --endpoint-url=https://aws.piranha.sh
{
"Reservations": [
{
"Groups": [],
"Instances": [
{
"AmiLaunchIndex": 0,
"ImageId": "b41826f84c65",
"InstanceId": "17294516",
"InstanceType": "nano",
"KeyName": "",
"LaunchTime": "2023-11-04T01:07:53.000Z",
"Monitoring": {
"State": "disabled"
},
"Placement": {
"AvailabilityZone": "eu-west-2",
"GroupName": "",
"Tenancy": "default"
},
"PrivateDnsName": "",
"PrivateIpAddress": "",
"ProductCodes": [],
"PublicDnsName": "",
"PublicIpAddress": "",
"State": {
"Code": 16,
"Name": "running"
},
"StateTransitionReason": "",
"SubnetId": "",
"VpcId": "internet1",
"Architecture": "x86_64",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda",
"Ebs": {
"AttachTime": "2023-11-04T01:07:53.000Z",
"DeleteOnTermination": true,
"Status": "attached",
"VolumeId": ""
}
}
],
"ClientToken": "",
"EbsOptimized": false,
"Hypervisor": "qemu",
"IamInstanceProfile": {
"Arn": "arn:piranha:iam::17294516:instance-profile/AdminRole",
"Id": "PR17294516"
},
"NetworkInterfaces": [],
"RootDeviceName": "/dev/sda",
"RootDeviceType": "ebs",
"SecurityGroups": [
{
"GroupName": "",
"GroupId": ""
}
],
"SourceDestCheck": true,
"Tags": [
{
"Key": "Name",
"Value": "scripbox"
}
],
"VirtualizationType": "RP1",
"CpuOptions": {
"CoreCount": 1,
"ThreadsPerCore": 1
}
},
{
"AmiLaunchIndex": 0,
"ImageId": "a78f168d3a3d",
"InstanceId": "17254945",
"InstanceType": "t2.small",
"KeyName": "",
"LaunchTime": "2023-12-03T22:29:44.000Z",
"Monitoring": {
"State": "disabled"
},
"Placement": {
"AvailabilityZone": "eu-west-2",
"GroupName": "",
"Tenancy": "default"
},
"PrivateDnsName": "",
"PrivateIpAddress": "",
"ProductCodes": [],
"PublicDnsName": "",
"PublicIpAddress": "",
"State": {
"Code": 16,
"Name": "running"
},
"StateTransitionReason": "",
"SubnetId": "",
"VpcId": "vpc-4ddf2c0558",
"Architecture": "x86_64",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda",
"Ebs": {
"AttachTime": "2023-12-03T22:29:44.000Z",
"DeleteOnTermination": true,
"Status": "attached",
"VolumeId": ""
}
}
],
"ClientToken": "",
"EbsOptimized": false,
"Hypervisor": "qemu",
"IamInstanceProfile": {
"Arn": "arn:piranha:iam::17254945:instance-profile/AdminRole",
"Id": "PR17254945"
},
"NetworkInterfaces": [],
"RootDeviceName": "/dev/sda",
"RootDeviceType": "ebs",
"SecurityGroups": [
{
"GroupName": "",
"GroupId": ""
}
],
"SourceDestCheck": true,
"Tags": [
{
"Key": "Name",
"Value": "test-a-box"
}
],
"VirtualizationType": "RP1",
"CpuOptions": {
"CoreCount": 1,
"ThreadsPerCore": 1
}
},
{
"AmiLaunchIndex": 0,
"ImageId": "a78f168d3a3d",
"InstanceId": "98095291",
"InstanceType": "t3a.small",
"KeyName": "",
"LaunchTime": "2023-10-22T14:51:54.000Z",
"Monitoring": {
"State": "disabled"
},
"Placement": {
"AvailabilityZone": "eu-west-2",
"GroupName": "",
"Tenancy": "default"
},
"PrivateDnsName": "",
"PrivateIpAddress": "",
"ProductCodes": [],
"PublicDnsName": "",
"PublicIpAddress": "",
"State": {
"Code": 16,
"Name": "running"
},
"StateTransitionReason": "",
"SubnetId": "",
"VpcId": "",
"Architecture": "x86_64",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda",
"Ebs": {
"AttachTime": "2023-10-22T14:51:54.000Z",
"DeleteOnTermination": true,
"Status": "attached",
"VolumeId": ""
}
}
],
"ClientToken": "",
"EbsOptimized": false,
"Hypervisor": "qemu",
"IamInstanceProfile": {
"Arn": "arn:piranha:iam::98095291:instance-profile/AdminRole",
"Id": "PR98095291"
},
"NetworkInterfaces": [],
"RootDeviceName": "/dev/sda",
"RootDeviceType": "ebs",
"SecurityGroups": [
{
"GroupName": "",
"GroupId": ""
}
],
"SourceDestCheck": true,
"Tags": [
{
"Key": "Name",
"Value": "vm-in-default-vpc"
}
],
"VirtualizationType": "RP1",
"CpuOptions": {
"CoreCount": 1,
"ThreadsPerCore": 1
}
},
{
"AmiLaunchIndex": 0,
"ImageId": "a78f168d3a3d",
"InstanceId": "27461204",
"InstanceType": "t3a.small",
"KeyName": "",
"LaunchTime": "2023-10-22T14:52:40.000Z",
"Monitoring": {
"State": "disabled"
},
"Placement": {
"AvailabilityZone": "eu-west-2",
"GroupName": "",
"Tenancy": "default"
},
"PrivateDnsName": "",
"PrivateIpAddress": "",
"ProductCodes": [],
"PublicDnsName": "",
"PublicIpAddress": "",
"State": {
"Code": 16,
"Name": "running"
},
"StateTransitionReason": "",
"SubnetId": "",
"VpcId": "",
"Architecture": "x86_64",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda",
"Ebs": {
"AttachTime": "2023-10-22T14:52:40.000Z",
"DeleteOnTermination": true,
"Status": "attached",
"VolumeId": ""
}
}
],
"ClientToken": "",
"EbsOptimized": false,
"Hypervisor": "qemu",
"IamInstanceProfile": {
"Arn": "arn:piranha:iam::27461204:instance-profile/AdminRole",
"Id": "PR27461204"
},
"NetworkInterfaces": [],
"RootDeviceName": "/dev/sda",
"RootDeviceType": "ebs",
"SecurityGroups": [
{
"GroupName": "",
"GroupId": ""
}
],
"SourceDestCheck": true,
"Tags": [
{
"Key": "Name",
"Value": "vm-internet"
}
],
"VirtualizationType": "RP1",
"CpuOptions": {
"CoreCount": 1,
"ThreadsPerCore": 1
}
},
{
"AmiLaunchIndex": 0,
"ImageId": "a78f168d3a3d",
"InstanceId": "12925085",
"InstanceType": "t2.medium",
"KeyName": "",
"LaunchTime": "2023-10-24T02:06:03.000Z",
"Monitoring": {
"State": "disabled"
},
"Placement": {
"AvailabilityZone": "eu-west-2",
"GroupName": "",
"Tenancy": "default"
},
"PrivateDnsName": "",
"PrivateIpAddress": "",
"ProductCodes": [],
"PublicDnsName": "",
"PublicIpAddress": "",
"State": {
"Code": 16,
"Name": "running"
},
"StateTransitionReason": "",
"SubnetId": "",
"VpcId": "",
"Architecture": "x86_64",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda",
"Ebs": {
"AttachTime": "2023-10-24T02:06:03.000Z",
"DeleteOnTermination": true,
"Status": "attached",
"VolumeId": ""
}
}
],
"ClientToken": "",
"EbsOptimized": false,
"Hypervisor": "qemu",
"IamInstanceProfile": {
"Arn": "arn:piranha:iam::12925085:instance-profile/AdminRole",
"Id": "PR12925085"
},
"NetworkInterfaces": [],
"RootDeviceName": "/dev/sda",
"RootDeviceType": "ebs",
"SecurityGroups": [
{
"GroupName": "",
"GroupId": ""
}
],
"SourceDestCheck": true,
"Tags": [
{
"Key": "Name",
"Value": "vpc-and-internet"
}
],
"VirtualizationType": "RP1",
"CpuOptions": {
"CoreCount": 1,
"ThreadsPerCore": 1
}
}
],
"OwnerId": "LMLMLMLMLM5DU76I7S6A8G65",
"ReservationId": "r-1234567890abcdef0"
}
]
}
+ sleep 10s