setStackPolicy method

Future<void> setStackPolicy({
  1. required String stackName,
  2. String? stackPolicyBody,
  3. String? stackPolicyURL,
})

Sets a stack policy for a specified stack.

Parameter stackName : The name or unique stack ID that you want to associate a policy with.

Parameter stackPolicyBody : Structure containing the stack policy body. For more information, go to Prevent Updates to Stack Resources in the AWS CloudFormation User Guide. You can specify either the StackPolicyBody or the StackPolicyURL parameter, but not both.

Parameter stackPolicyURL : Location of a file containing the stack policy. The URL must point to a policy (maximum size: 16 KB) located in an S3 bucket in the same Region as the stack. You can specify either the StackPolicyBody or the StackPolicyURL parameter, but not both.

Implementation

Future<void> setStackPolicy({
  required String stackName,
  String? stackPolicyBody,
  String? stackPolicyURL,
}) async {
  ArgumentError.checkNotNull(stackName, 'stackName');
  _s.validateStringLength(
    'stackPolicyBody',
    stackPolicyBody,
    1,
    16384,
  );
  _s.validateStringLength(
    'stackPolicyURL',
    stackPolicyURL,
    1,
    1350,
  );
  final $request = <String, dynamic>{};
  $request['StackName'] = stackName;
  stackPolicyBody?.also((arg) => $request['StackPolicyBody'] = arg);
  stackPolicyURL?.also((arg) => $request['StackPolicyURL'] = arg);
  await _protocol.send(
    $request,
    action: 'SetStackPolicy',
    version: '2010-05-15',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['SetStackPolicyInput'],
    shapes: shapes,
  );
}