@gammarers/aws-waf-ip-restrict-rule
v2.1.54
Published
This is an AWS CDK Construct for IP Restriction Rule on WAF V2
Readme
AWS WAF(V2) IP Restrict Rule
This is an AWS CDK Construct for IP Restrict Rule on WAF V2
Install
TypeScript
install by npm
npm install @gammarers/aws-waf-ip-restrict-ruleinstall by yarn
yarn add @gammarers/aws-waf-ip-restrict-rulePython
pip install gammarers.aws-waf-ip-restrict-ruleExample
import { WAFIPRestrictRule } from '@gammarers/aws-waf-ip-restrict-rule';
const allowedIpSet = new wafv2.CfnIPSet(stack, 'AllowedIpSet', {
addresses: [
'203.0.113.0/24',
'198.51.100.0/24',
],
ipAddressVersion: 'IPV4',
scope: 'CLOUDFRONT',
name: 'AllowedIpSet',
});
const ipRestrictRule = new WAFIPRestrictRule({
allowIPSetArn: allowedIpSet.attrArn,
});
new wafv2.CfnWebACL(stack, 'WebACL', {
defaultAction: { allow: {} },
scope: 'CLOUDFRONT',
name: 'WebAclWithCustomRules',
visibilityConfig: {
cloudWatchMetricsEnabled: true,
metricName: 'WebAclMetric',
sampledRequestsEnabled: true,
},
rules: [
ipRestrictRule.allowRule({ priority: 1 }),
ipRestrictRule.blockRule({ priority: 2 }),
],
});
License
This project is licensed under the Apache-2.0 License.
