LoginSignup
1
0

More than 3 years have passed since last update.

AWSCLIでCloudFormationのOutputsから値取得

Posted at

結構めんどうだったのでメモ

$ 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

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0