Skip to main content

This is an AWS CDK Construct for IP Restriction Rule on WAF V2

Project description

AWS WAF(V2) IP Restrict Rule

GitHub npm (scoped) PyPI GitHub Workflow Status (branch) GitHub release (latest SemVer)

View on Construct Hub

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-rule

install by yarn

yarn add @gammarers/aws-waf-ip-restrict-rule

Python

pip install gammarers.aws-waf-ip-restrict-rule

Example

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gammarers_aws_waf_ip_restrict_rule-2.1.52.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file gammarers_aws_waf_ip_restrict_rule-2.1.52.tar.gz.

File metadata

File hashes

Hashes for gammarers_aws_waf_ip_restrict_rule-2.1.52.tar.gz
Algorithm Hash digest
SHA256 5ca1943c04157df64f0acc635ec655d56c0a4e2444f5b0f062f191de1da12a85
MD5 ed6011ae95bd376e9c7fc41856b07579
BLAKE2b-256 2514bcb941bb50a182f7367b44de9904924d3e5ac5d1ae9f775a801bc64230cc

See more details on using hashes here.

File details

Details for the file gammarers_aws_waf_ip_restrict_rule-2.1.52-py3-none-any.whl.

File metadata

File hashes

Hashes for gammarers_aws_waf_ip_restrict_rule-2.1.52-py3-none-any.whl
Algorithm Hash digest
SHA256 c94f4fe421618376322b6905eb1043ae89cb7f7048c2b45ba608b388aa755fc7
MD5 a081df5298c39e5c3e13c9cedd3b5577
BLAKE2b-256 73682010d3e25934d1c6cbc21c7fb3dc4c46ece9584b0e5386ada4bcff48681b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page