aws / aws-cli

Universal Command Line Interface for Amazon Web Services
Other
15.54k stars 4.13k forks source link

aws cloudformation deploy --output json does not output json #8254

Open jxn opened 1 year ago

jxn commented 1 year ago

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

whereas, running the same procedure with cloudformation deploy:

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

aBurmeseDev commented 1 year ago

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.

subudhiroshan commented 6 months ago

Totally agree with OP. Please prioritize.