Skip to content

Instantly share code, notes, and snippets.

@niharbabu99
Last active February 28, 2024 11:43
Show Gist options
  • Save niharbabu99/3c7f154c67b6de5bcb9c79cf0cdd6bad to your computer and use it in GitHub Desktop.
Save niharbabu99/3c7f154c67b6de5bcb9c79cf0cdd6bad to your computer and use it in GitHub Desktop.
JSON commands
Command-1:
cat eucentra1-crs.json | jq -c '(.CapacityReservations[] | {ID: .CapacityReservationId, Available: .AvailableInstanceCount, Type: .InstanceType})'
this gives the result in the below form
{"ID":"cr-00556b16e475b63d8","Available":0,"Type":"t3.medium"}
Sample contents of the json is as below
{
"CapacityReservations": [
{
"CapacityReservationId": "cr-1234abcd56EXAMPLE ",
"EndDateType": "unlimited",
"AvailabilityZone": "eu-west-1a",
"InstanceMatchCriteria": "open",
"Tags": [],
"EphemeralStorage": false,
"CreateDate": "2019-08-16T09:03:18.000Z",
"AvailableInstanceCount": 1,
"InstancePlatform": "Linux/UNIX",
"TotalInstanceCount": 1,
"State": "active",
"Tenancy": "default",
"EbsOptimized": true,
"InstanceType": "a1.medium"
},
{
"CapacityReservationId": "cr-abcdEXAMPLE9876ef ",
"EndDateType": "unlimited",
"AvailabilityZone": "eu-west-1a",
"InstanceMatchCriteria": "open",
"Tags": [],
"EphemeralStorage": false,
"CreateDate": "2019-08-07T11:34:19.000Z",
"AvailableInstanceCount": 3,
"InstancePlatform": "Linux/UNIX",
"TotalInstanceCount": 3,
"State": "cancelled",
"Tenancy": "default",
"EbsOptimized": true,
"InstanceType": "m5.large"
}
]
}
Command-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment