Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WAFv2: fix incorrect ARNs in Cloudfront scope #8660

Merged

Conversation

tiurin
Copy link
Contributor

@tiurin tiurin commented Mar 7, 2025

Issue

Reported in localstack/localstack#12272.

ARN for WAF resources in Cloudfront scope should specify us-east-1 region. Currently region is being set to global in moto.

I checked in AWS console that it stands true for all WAF resources: Web ACLs, IP sets, Regex pattern sets, Rule groups.

The regression was likely introduced in #7710.

Solution

Region for global scope backend defaults to "aws". It needs to be overridden with us-east-1 for ARN purposes as Cloudfront-related resources are managed from us-east-1 and have it specified in ARN. However backend itself should stay separate for global and regional, to distinguish between WAF for us-east-1 and WAF for Cloudfront.

ARNs for global and regional resources for us-east-1 differ only in resource name prefix - global/ and regional/ respectively.

tiurin added 5 commits March 6, 2025 23:46
Backend has "aws" region in case of global services like Cloudfront, however they are managed from us-east-1 and have a corresponding ARN.
get_partition already handles all the cases and setting region to global for special partitions doesn't seem to be correct specifically for WAF ARNs (gov doesn't have its own Cloudfront and China is not global).
ARN region is not indicative by itself in case of WAF for Cloudfront.
Copy link

codecov bot commented Mar 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.75%. Comparing base (4477ee6) to head (79760fe).
Report is 6 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8660   +/-   ##
=======================================
  Coverage   92.75%   92.75%           
=======================================
  Files        1252     1252           
  Lines      108676   108678    +2     
=======================================
+ Hits       100807   100809    +2     
  Misses       7869     7869           
Flag Coverage Δ
servertests 28.27% <33.33%> (-0.01%) ⬇️
unittests 92.73% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @tiurin - welcome to Moto!

@bblommers bblommers added this to the 5.1.2 milestone Mar 12, 2025
@bblommers bblommers merged commit c6f64e8 into getmoto:master Mar 12, 2025
52 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants