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.23.tar.gz (28.4 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.23.tar.gz.

File metadata

File hashes

Hashes for gammarers_aws_waf_ip_restrict_rule-2.1.23.tar.gz
Algorithm Hash digest
SHA256 abed0ad012bb1309b9f9abd7efac109f7580386c76e963a3cff12cd06715af6c
MD5 083d60be4e68bb62214808ef42ec94c7
BLAKE2b-256 028b1c7c583387d5ac364ca52092f44ce41990d9b9ca11f25af4e1cf92060ff9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gammarers_aws_waf_ip_restrict_rule-2.1.23-py3-none-any.whl
Algorithm Hash digest
SHA256 a78dfd5bbe02e0806f1a4da7bbdf21b5593ee9f1e9c381a422551957b03a2c7c
MD5 680124c08da1464990725e241529c04e
BLAKE2b-256 a8d256d86aba9ff8787705e9239532ec95468e122e2e034f258fe88d3b0f2751

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