aws-cli
aws-cli copied to clipboard
aws cloudformation deploy --output json does not output json
Describe the bug
When using --output json or AWS_DEFAULT_OUTPUT=json with aws cloudformation deploy command, human-readable text is still produced as output.
AWS_DEFAULT_OUTPUT=json aws cloudformation --output json deploy --template-file ~/stack.yaml --stack-name stack-name --no-execute-changeset
Outputs:
Waiting for changeset to be created..
Changeset created successfully. Run the following command to review changes:
aws cloudformation describe-change-set --change-set-name arn:aws:cloudformation:us-east-1:<acctid>:changeSet/awscli-cloudformation-package-deploy-1697723449/c9695a27-8b16-4bc6-aa7f-866b3a333c39
Expected Behavior
Some kind of stable json object would be produced, returning the change-set-name, e.g.
{
"CloudformationChangeSets": [
{"ChangeSetName": "arn:aws:cloudformation:us-east-1:<acctid>:changeSet/awscli-cloudformation-package-deploy-1697723440/c9695a27-8b16-4bc6-aa7f-866b3a333c34"
]
}
Current Behavior
Waiting for changeset to be created..
Changeset created successfully. Run the following command to review changes:
aws cloudformation describe-change-set --change-set-name arn:aws:cloudformation:us-east-1:<acctid>:changeSet/awscli-cloudformation-package-deploy-1697723449/c9695a27-8b16-4bc6-aa7f-866b3a333c39
Reproduction Steps
aws cloudformation --output json deploy --template-file ~/stack.yaml --stack-name stack-name
Possible Solution
Return json and only json if requested by the user using --output json
Additional Information/Context
It's important to provide json output for programmatic use. Perhaps cloudformation deploy is not intended for programmatic use, but it's difficult to achieve the same result as cloudformation deploy with other cli commands if you want to programmatically execute cloudformation with the option to preview and approve the changeset in the process, while executing everything in a nonidempotent way.
This is because create-change-set command only creates a changeset it an existing stack exists, and create-stack and update-stack require knowledge of whether the stack already exists.
Previewing a changeset in automation for a stack of unknown status thus requires
- run list-stack or describe-stack to determine if stack already exists
- create an empty stack if a stack does not already exist
- create the changeset against the stack
- preview the changeset
- (user interaction to approve the changset)
- apply the changeset if approved
- delete the stack if empty to clean up if the changeset was not approved
whereas, running the same procedure with cloudformation deploy:
- run
cloudformation deploywith --no-execute-changeset - (user interaction to approve the changeset)
- apply the changeset if approved
CLI version used
aws-cli/2.13.27 Python/3.11.6
Environment details (OS name and version, etc.)
ubuntu linux 22.04 and ubuntu linux 23.04
Hi @jxn - thanks for reaching out and for your patience. I brought this up with the team for discussion and I'm going to mark it as feature-request as we agreed this's a valid ask. Though I can't promise where this will land on their radar but I'll make sure to check in with them and keep it posted here.
I would also encourage others who's interested in this feature to upvote 👍🏽 the original post as it may help this move forward.
Totally agree with OP. Please prioritize.