Skip to content

Commit

Permalink
Fixed CloudFront Origin Shield region selection
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthSim committed Feb 27, 2024
1 parent 68c49d3 commit b6d3c0d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.2.1] - 2024-02-28
### Fixed
- Fixed CloudFront Origin Shield region selection.

## [0.2.0] - 2024-02-23
### Added
- Added `HowToConfigure` output.
Expand Down
28 changes: 27 additions & 1 deletion template.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,32 @@ def __init__(self, value_one: object, value_two: object) -> None:
},
})

if not args.no_network:
template.add_mapping("OriginShieldRegionMap", {
# Regions with origin shield
"us-east-2": {"Region": "us-east-2"},
"us-east-1": {"Region": "us-east-1"},
"us-west-2": {"Region": "us-west-2"},
"ap-south-1": {"Region": "ap-south-1"},
"ap-northeast-2": {"Region": "ap-northeast-2"},
"ap-southeast-1": {"Region": "ap-southeast-1"},
"ap-southeast-2": {"Region": "ap-southeast-2"},
"ap-northeast-1": {"Region": "ap-northeast-1"},
"eu-central-1": {"Region": "eu-central-1"},
"eu-west-1": {"Region": "eu-west-1"},
"eu-west-2": {"Region": "eu-west-2"},
"sa-east-1": {"Region": "sa-east-1"},
# Regions without origin shield
"us-west-1": {"Region": "us-west-2"},
"af-south-1": {"Region": "eu-west-1"},
"ap-east-1": {"Region": "ap-southeast-1"},
"ca-central-1": {"Region": "us-east-1"},
"eu-south-1": {"Region": "eu-central-1"},
"eu-west-3": {"Region": "eu-west-2"},
"eu-north-1": {"Region": "eu-west-2"},
"me-south-1": {"Region": "ap-south-1"},
})

# ==============================================================================
# CLOUDWATCH LOGS
# ==============================================================================
Expand Down Expand Up @@ -1357,7 +1383,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
),
OriginShield=cloudfront.OriginShield(
Enabled=True,
OriginShieldRegion=Region,
OriginShieldRegion=FindInMap("OriginShieldRegionMap", Region, "Region"),
),
)],
DefaultCacheBehavior=cloudfront.DefaultCacheBehavior(
Expand Down

0 comments on commit b6d3c0d

Please sign in to comment.