associateWebACL method

Future<void> associateWebACL({
  1. required String resourceArn,
  2. required String webACLArn,
})
Associates a Web ACL with a regional application resource, to protect the resource. A regional application can be an Application Load Balancer (ALB), an API Gateway REST API, or an AppSync GraphQL API.

For AWS CloudFront, don't use this call. Instead, use your CloudFront distribution configuration. To associate a Web ACL, in the CloudFront call UpdateDistribution, set the web ACL ID to the Amazon Resource Name (ARN) of the Web ACL. For information, see UpdateDistribution.

May throw WAFInternalErrorException. May throw WAFInvalidParameterException. May throw WAFNonexistentItemException. May throw WAFUnavailableEntityException. May throw WAFInvalidOperationException.

Parameter resourceArn : The Amazon Resource Name (ARN) of the resource to associate with the web ACL.

The ARN must be in one of the following formats:

  • For an Application Load Balancer: arn:aws:elasticloadbalancing:region:account-id:loadbalancer/app/load-balancer-name/load-balancer-id
  • For an API Gateway REST API: arn:aws:apigateway:region::/restapis/api-id/stages/stage-name
  • For an AppSync GraphQL API: arn:aws:appsync:region:account-id:apis/GraphQLApiId

Parameter webACLArn : The Amazon Resource Name (ARN) of the Web ACL that you want to associate with the resource.

Implementation

Future<void> associateWebACL({
  required String resourceArn,
  required String webACLArn,
}) async {
  ArgumentError.checkNotNull(resourceArn, 'resourceArn');
  _s.validateStringLength(
    'resourceArn',
    resourceArn,
    20,
    2048,
    isRequired: true,
  );
  ArgumentError.checkNotNull(webACLArn, 'webACLArn');
  _s.validateStringLength(
    'webACLArn',
    webACLArn,
    20,
    2048,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSWAF_20190729.AssociateWebACL'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ResourceArn': resourceArn,
      'WebACLArn': webACLArn,
    },
  );
}