below environment
- node-js: 16.16.0
- aws-cdk: 2.41.0
When I just tried cdk deploy it gives me the following error:
Resource handler returned message: "Error reason: EXACTLY_ONE_CONDITION_REQUIRED, field: MANAGED_RULE_GROUP_CONFIG, parameter: ManagedRuleGroupConfig (Service: Wafv2, Status Code: 400, Request ID: f35c1b88-57f9-420b-9f
db-3e6e99aefb8d, Extended Request ID: null)" (RequestToken: f9a83934-9d2b-9b52-0f97-ebf49c15c42c, HandlerErrorCode: InvalidRequest)
below my source code
import * as cdk from 'aws-cdk-lib';
import * as wafv2 from 'aws-cdk-lib/aws-wafv2';
export class CdkWorkshopStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// defines an AWS WAFv2 WebACL resource
const webACL = new wafv2.CfnWebACL(this, 'WebACL', {
defaultAction: {
block: {},
},
scope: 'REGIONAL',
name: 'waf-sample',
description: 'this is a test',
visibilityConfig: {
cloudWatchMetricsEnabled: true,
metricName: 'WebACL',
sampledRequestsEnabled: true
},
rules: [
{
priority: 9,
name: 'AWS-AWSManagedRulesATPRuleSet',
statement: {
managedRuleGroupStatement: {
name: 'AWSManagedRulesATPRuleSet',
vendorName: 'AWS',
managedRuleGroupConfigs: [{
loginPath: '/loginPath',
payloadType: 'JSON',
usernameField: {
identifier: '/form/username',
},
passwordField: {
identifier: '/form/password',
},
}],
}
},
overrideAction: { none: {} },
visibilityConfig: {
cloudWatchMetricsEnabled: true,
metricName: 'AWS-AWSManagedRulesATPRuleSet',
sampledRequestsEnabled: true
}
},
],
});
}
}
I know that 'managedRuleGroupConfigs' is the cause. But i don't know what exactly is wrong.
I tried deploying with managedRuleGroupConfigs.loginPath ,then the following error.
CdkWorkshopStack failed: Error: The stack named CdkWorkshopStack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Error reason: A required field is missing from the parameter., field: MANAGED_RULE_SET_STATEMENT, parameter: null (Service: Wafv2, Status Code: 400, Request ID: 3aa6ce31-b677-4058-9ef3-158f19b6022e, Extended Request ID: null)" (RequestToken: c569740d-4f74-f11d-4b8a-a1fe7431ab19, HandlerErrorCode: InvalidRequest)
I just need your knowledge.