aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

create-change-set does not allow using StackPolicyBody in --cli-input-json

Open bitfoo1 opened this issue 7 years ago • 3 comments

Hello,

I am using aws cli to create and execute CloudFormation change sets. I saw that there is an option to enable us to control what is allowed while updating our CF Stacks. (Stack Policies) If I create a cli skeleton for creating/updating a stack like aws cloudformation create-stack --generate-cli-skeleton > out.json I see that there is a field called StackPolicyBody. If I do the same but for a different create-change-set there is no field like that. Why is that missing?

Thank you for clarifying that to me.

bitfoo1 avatar Jul 19 '19 08:07 bitfoo1

Thank you for posting this issue.

According to our documentation, the API parameter StackPolicyBody is being used in the following API calls:

SetStackPolicy GetStackPolicy CreateStack UpdateStack

As you pointed out, StackPolicyBody is not listed with aws cloudformation create-change-set because the service is not explosing it to the CLI. It is also not listed with the CreateChangeSet API parameters as shown here.

According to our docs, after you apply a stack policy, you can't remove it from the stack, but you can use the AWS CLI to modify it. To set a stack policy when you create a stack, you can use the CLI command aws cloudformation create-stack with the --stack-policy-body option to type in the modified policy. To modify the stack policy, you can use the CLI command aws cloudformation set-stack-policy with the --stack-policy-body option to type in a modified policy. If you execute a change set on a stack that has a stack policy associated with it, AWS CloudFormation enforces the policy when it updates the stack. You also can't specify a temporary stack policy that overrides the existing policy when you execute a change set. To update a protected resource, you must update the stack policy or use the direct modification method. There is an example of direct modification posted in our docs.

This behavior is controlled by the CloudFormation service and not the CLI. To submit a feature request to the service team, I suggest reaching out to the service team forums or AWS Premium Support.

I hope this answers your question.

justnance avatar Jul 30 '19 03:07 justnance

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

no-response[bot] avatar Aug 06 '19 04:08 no-response[bot]

Was a feature request filed upstream? The CloudFormation (CLI) API is missing a lot of parameters I would expect to be there for consistency, and create-change-set --stack-policy-body is one of them.

hoxu avatar Jan 27 '22 09:01 hoxu