aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap

AWS::WAFv2::WebACL - Drift not detected on drifted RuleActionOverrides

Open
#2,276 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
No language data
Stars
1.1k
Forks
62
PR merge metrics
No merged PRs in 30d

Description

### Name of the resource

AWS::WAFv2::WebACL

### Issue Description

Manually modifying the RuleActionOverrides of the WebACL Rules do not cause the resource to be drifted in CloudFormation.

### Expected Behavior

Upon modifying the RuleActionOverrides of the WebACL Rules, the drift should be seen in CloudFormation and it show as MODIFIED.

### Observed Behavior

Drift detection instead shows IN_SYNC, which is not an accurate representation of the physical resource's configurations.

### Test Cases

Deploy a simple AWS::WAFv2::WebACL resource, manually modify it to override all rule actions (incl. AnonymousIPList and HostingProviderIPList) and then run drift detection.

Steps (via AWS CLI):

1. Execute the below AWS CLI command / deploy the CloudFormation template and immediately run drift detection on the stack:

```
aws cloudformation create-stack --stack-name waf-drift-test --on-failure DELETE --template-body \
'Resources:
WebACL:
Type: AWS::WAFv2::WebACL
Properties:
Name: Test-WebACL
Scope: REGIONAL
DefaultAction:
Allow: {}
VisibilityConfig:
SampledRequestsEnabled: false
CloudWatchMetricsEnabled: false
MetricName: Test-WebACLMetric
Rules:
- Name: AWSManagedRulesAnonymousIpListRule
Priority: 20
OverrideAction:
None: {}
VisibilityConfig:
SampledRequestsEnabled: false
CloudWatchMetricsEnabled: false
MetricName: AWSManagedRulesAnonymousIpListRuleMetric
Statement:
ManagedRuleGroupStatement:
VendorName: AWS
Name: AWSManagedRulesAnonymousIpList'
```

2. Get and store the ID and LockTocken:
```
ID=`aws wafv2 list-web-acls \
--scope REGIONAL \
--query "WebACLs[?Name=='Test-WebACL'].Id" \
--output text` && \
LT=`aws wafv2 list-web-acls \
--scope REGIONAL \
--query "WebACLs[?Name=='Test-WebACL'].LockToken" \
--output text`
```

3. Update the Rules on the WebACL to include RuleActionOverrides:
```
aws wafv2 update-web-acl \
--name Test-WebACL \
--scope REGIONAL \
--id $ID \
--lock-token $LT \
--default-action Allow={} \
--visibility-config SampledRequestsEnabled=false,CloudWatchMetricsEnabled=false,MetricName=Test-WebACLMetric \
--rules '[{
"Name": "AWSManagedRulesAnonymousIpListRule",
"Priority": 20,
"Statement": {
"ManagedRuleGroupStatement": {
"VendorName": "AWS",
"Name": "AWSManagedRulesAnonymousIpList",
"RuleActionOverrides": [
{
"Name": "AnonymousIPList",
"ActionToUse": {
"Allow": {}
}
},
{
"Name": "HostingProviderIPList",
"ActionToUse": {
"Allow": {}
}
}
]
}
},
"OverrideAction": {
"None": {}
},
"VisibilityConfig": {
"SampledRequestsEnabled": false,
"CloudWatchMetricsEnabled": false,
"MetricName": "AWSManagedRulesAnonymousIpListRuleMetric"
}
}]'
```

Contributor guide

Open the contributing guide

Research direction

Start by deploying the supplied AWS::WAFv2::WebACL template with the AWS CLI, run CloudFormation drift detection, and then apply the listed RuleActionOverrides update. Compare the reported state with the manually modified WebACL; the work is done when those overrides cause the resource to be reported as MODIFIED rather than IN_SYNC.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.