-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cloudfront): support geo restrictions for cloudfront distribution (
#7345) - Restrictions currently support GeoRestriction only, but if CloudFront adds support for other types it can easily be expanded - Closes #3456
- Loading branch information
1 parent
87860ca
commit cf25ba0
Showing
5 changed files
with
356 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-geo-restrictions.expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"Resources": { | ||
"Bucket83908E77": { | ||
"DeletionPolicy": "Delete", | ||
"UpdateReplacePolicy": "Delete", | ||
"Type": "AWS::S3::Bucket" | ||
}, | ||
"MyDistributionCFDistributionDE147309": { | ||
"Type": "AWS::CloudFront::Distribution", | ||
"Properties": { | ||
"DistributionConfig": { | ||
"DefaultCacheBehavior": { | ||
"AllowedMethods": [ | ||
"GET", | ||
"HEAD" | ||
], | ||
"CachedMethods": [ | ||
"GET", | ||
"HEAD" | ||
], | ||
"ForwardedValues": { | ||
"Cookies": { | ||
"Forward": "none" | ||
}, | ||
"QueryString": false | ||
}, | ||
"TargetOriginId": "origin1", | ||
"ViewerProtocolPolicy": "redirect-to-https", | ||
"Compress": true | ||
}, | ||
"DefaultRootObject": "index.html", | ||
"Enabled": true, | ||
"HttpVersion": "http2", | ||
"IPV6Enabled": true, | ||
"Origins": [ | ||
{ | ||
"DomainName": { | ||
"Fn::GetAtt": [ | ||
"Bucket83908E77", | ||
"RegionalDomainName" | ||
] | ||
}, | ||
"Id": "origin1", | ||
"S3OriginConfig": {} | ||
} | ||
], | ||
"PriceClass": "PriceClass_100", | ||
"ViewerCertificate": { | ||
"CloudFrontDefaultCertificate": true | ||
}, | ||
"Restrictions": { | ||
"GeoRestriction": { | ||
"Locations": ["US", "UK"], | ||
"RestrictionType": "whitelist" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-geo-restrictions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as s3 from '@aws-cdk/aws-s3'; | ||
import * as cdk from '@aws-cdk/core'; | ||
import * as cloudfront from '../lib'; | ||
|
||
const app = new cdk.App(); | ||
|
||
const stack = new cdk.Stack(app, 'cloudfront-geo-restrictions'); | ||
|
||
const sourceBucket = new s3.Bucket(stack, 'Bucket', { | ||
removalPolicy: cdk.RemovalPolicy.DESTROY, | ||
}); | ||
|
||
new cloudfront.CloudFrontWebDistribution(stack, 'MyDistribution', { | ||
originConfigs: [ | ||
{ | ||
s3OriginSource: { | ||
s3BucketSource: sourceBucket, | ||
}, | ||
behaviors : [ {isDefaultBehavior: true}], | ||
}, | ||
], | ||
geoRestriction: cloudfront.GeoRestriction.whitelist('US', 'UK'), | ||
}); | ||
|
||
app.synth(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters