Sets a stack policy for a specified stack.
Parameters:
-
stack_name
(Optional[StackName], default:
None
)
–
The name or unique stack ID that you want to associate a policy with.
-
stack_policy_body
(Optional[StackPolicyBody], default:
None
)
–
Structure that contains the stack policy body. For more information, see Prevent updates to stack resources in the CloudFormation User Guide. You can specify either the StackPolicyBody or the StackPolicyURL parameter, but not both.
-
stack_policy_url
(Optional[StackPolicyURL], default:
None
)
–
Location of a file that contains the stack policy. The URL must point to a policy (maximum size: 16 KB) located in an Amazon S3 bucket in the same Amazon Web Services Region as the stack. The location for an Amazon S3 bucket must start with https://. URLs from S3 static websites are not supported.
You can specify either the StackPolicyBody or the StackPolicyURL parameter, but not both.
Raises:
Source code in docs_src/capo_cloudformation/_services/cloud_formation.py
| def set_stack_policy(
self,
*,
config_overrides: Optional[CloudFormationClientConfig] = None,
stack_name: Optional["capo_cloudformation.types.stack_name.StackName"] = None,
stack_policy_body: Optional[
"capo_cloudformation.types.stack_policy_body.StackPolicyBody"
] = None,
stack_policy_url: Optional[
"capo_cloudformation.types.stack_policy_url.StackPolicyURL"
] = None,
) -> None:
"""<p>Sets a stack policy for a specified stack.</p>
Args:
stack_name: <p>The name or unique stack ID that you want to associate a policy with.</p>
stack_policy_body: <p>Structure that contains the stack policy body. For more information, see <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html">Prevent updates to stack resources</a> in the <i>CloudFormation User Guide</i>. You can specify either the <code>StackPolicyBody</code> or the <code>StackPolicyURL</code> parameter, but not both.</p>
stack_policy_url: <p>Location of a file that contains the stack policy. The URL must point to a policy (maximum size: 16 KB) located in an Amazon S3 bucket in the same Amazon Web Services Region as the stack. The location for an Amazon S3 bucket must start with <code>https://</code>. URLs from S3 static websites are not supported.</p> <p>You can specify either the <code>StackPolicyBody</code> or the <code>StackPolicyURL</code> parameter, but not both.</p>
Raises:
capo_cloudformation.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_cloudformation.types.set_stack_policy_input.SetStackPolicyInput]",
) -> OperationResponse[None]:
import capo_cloudformation._operations.cloud_formation.set_stack_policy
output, http_response = (
capo_cloudformation._operations.cloud_formation.set_stack_policy.set_stack_policy(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("SetStackPolicy")
)
input_: capo_cloudformation.types.set_stack_policy_input.SetStackPolicyInput = {}
if stack_name is not None:
input_["stack_name"] = stack_name
if stack_policy_body is not None:
input_["stack_policy_body"] = stack_policy_body
if stack_policy_url is not None:
input_["stack_policy_url"] = stack_policy_url
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|