結構めんどうだったのでメモ
$ aws cloudformation describe-stacks\
--region リージョン\
--profile プロファイル\
--stack-name "スタック名"\
--output text\
--query 'Stacks[].Outputs[?OutputKey==`Outputsのキー`].[OutputValue]'
--query
に指定している値は、--query
オプションなしで--output json
で出力してから作りました。
$ aws cloudformation describe-stacks\
--region us-east-1\
--profile xxxxxxxxxxxx\
--stack-name "xxxxxxxxxxxx"\
--output json
{
"Stacks": [
{
"StackId": "arn:aws:cloudformation:us-east-1:xxxxxxxxxxxx:stack/xxxxxxxxxxxx/xxxxxxxxxxxx",
"StackName": "xxxxxxxxxxxx",
"ChangeSetId": "arn:aws:cloudformation:us-east-1:xxxxxxxxxxxx:changeSet/xxxxxxxxxxxx/xxxxxxxxxxxx",
"Parameters": [
{
"ParameterKey": "Env",
"ParameterValue": "dev"
}
],
"CreationTime": "2020-12-15T06:25:42.183Z",
"LastUpdatedTime": "2020-12-15T06:25:53.614Z",
"RollbackConfiguration": {},
"StackStatus": "CREATE_COMPLETE",
"DisableRollback": false,
"NotificationARNs": [],
"Capabilities": [
"CAPABILITY_NAMED_IAM"
],
"Outputs": [
{
"OutputKey": "xxxxxxxxxxxx",
"OutputValue": "xxxxxxxxxxxx",
"Description": "xxxxxxxxxxxx"
}
],
"Tags": [],
"EnableTerminationProtection": false,
"DriftInformation": {
"StackDriftStatus": "NOT_CHECKED"
}
}
]
}
参考:https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-output.html