How to add WAF to my cognito UserPool with cdk

461 Views Asked by At

I can't find examples or documentation about how to use cdk to attach a waf to a cognito userpool.

1

There are 1 best solutions below

0
Vikram S On BEST ANSWER

There is no API in Cognito Userpool. You will need to create CfnWebACLAssociation and provide the Userpool ARN for the resource ARN.

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_wafv2.CfnWebACLAssociation.html#resourcearn

import { aws_wafv2 as wafv2 } from 'aws-cdk-lib';
const cfnWebACLAssociation = new wafv2.CfnWebACLAssociation(this, 'MyCfnWebACLAssociation', {
  resourceArn: 'arn: *partition* :cognito-idp: *region* : *account-id* :userpool/ *user-pool-id*',
  webAclArn: 'webAclArn',
});