Skip to content

Commit

Permalink
chore(docs): update readme(update exmaple)
Browse files Browse the repository at this point in the history
  • Loading branch information
yicr committed Dec 25, 2024
1 parent 8598a56 commit b2ba6e0
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,33 @@ pip install gammarers.aws-waf-ip-restrict-rule
```typescript
import { WAFIPRestrictRule } from '@gammarers/aws-waf-ip-restrict-rule';

const ipRestrictRule = new WAFIPRestrictRule(stack, 'WAFIPRestrictRule', {
allowIpAddresses: [
'192.0.2.0/24',
'198.51.100.0/24',
const allowedIpSet = new wafv2.CfnIPSet(stack, 'AllowedIpSet', {
addresses: [
'203.0.113.0/24',
'198.51.100.0/24',
],
scope: WAFIPRestrictRuleScope.GLOBAL,
priority: 1,
ipAddressVersion: 'IPV4',
scope: 'CLOUDFRONT',
name: 'AllowedIpSet',
});

const ipRestrictRule = new WAFIPRestrictRule({
allowIPSetArn: allowedIpSet.attrArn,
});

new wafv2.CfnWebACL(stack, 'WebACL', {
defaultAction: { allow: {} },
scope: 'CLOUD_FRONT',
scope: 'CLOUDFRONT',
name: 'WebAclWithCustomRules',
visibilityConfig: {
cloudWatchMetricsEnabled: true,
metricName: 'WebAclMetric',
sampledRequestsEnabled: true,
},
rules: [ipRestrictRule.rule],
rules: [
ipRestrictRule.allowRule({ priority: 1 }),
ipRestrictRule.blockRule({ priority: 2 }),
],
});

```
Expand Down

0 comments on commit b2ba6e0

Please sign in to comment.