createLifecyclePolicy method

Future<CreateLifecyclePolicyResponse> createLifecyclePolicy({
  1. required String description,
  2. required String executionRoleArn,
  3. required PolicyDetails policyDetails,
  4. required SettablePolicyStateValues state,
  5. Map<String, String>? tags,
})

Creates a policy to manage the lifecycle of the specified AWS resources. You can create up to 100 lifecycle policies.

May throw InvalidRequestException. May throw LimitExceededException. May throw InternalServerException.

Parameter description : A description of the lifecycle policy. The characters ^0-9A-Za-z _-+$ are supported.

Parameter executionRoleArn : The Amazon Resource Name (ARN) of the IAM role used to run the operations specified by the lifecycle policy.

Parameter policyDetails : The configuration details of the lifecycle policy.

Parameter state : The desired activation state of the lifecycle policy after creation.

Parameter tags : The tags to apply to the lifecycle policy during creation.

Implementation

Future<CreateLifecyclePolicyResponse> createLifecyclePolicy({
  required String description,
  required String executionRoleArn,
  required PolicyDetails policyDetails,
  required SettablePolicyStateValues state,
  Map<String, String>? tags,
}) async {
  ArgumentError.checkNotNull(description, 'description');
  _s.validateStringLength(
    'description',
    description,
    0,
    500,
    isRequired: true,
  );
  ArgumentError.checkNotNull(executionRoleArn, 'executionRoleArn');
  _s.validateStringLength(
    'executionRoleArn',
    executionRoleArn,
    0,
    2048,
    isRequired: true,
  );
  ArgumentError.checkNotNull(policyDetails, 'policyDetails');
  ArgumentError.checkNotNull(state, 'state');
  final $payload = <String, dynamic>{
    'Description': description,
    'ExecutionRoleArn': executionRoleArn,
    'PolicyDetails': policyDetails,
    'State': state.toValue(),
    if (tags != null) 'Tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/policies',
    exceptionFnMap: _exceptionFns,
  );
  return CreateLifecyclePolicyResponse.fromJson(response);
}