class GeoRestriction
| Language | Type name | 
|---|---|
|  .NET | Amazon.CDK.AWS.CloudFront.GeoRestriction | 
|  Go | github.com/aws/aws-cdk-go/awscdk/v2/awscloudfront#GeoRestriction | 
|  Java | software.amazon.awscdk.services.cloudfront.GeoRestriction | 
|  Python | aws_cdk.aws_cloudfront.GeoRestriction | 
|  TypeScript (source) | aws-cdk-lib»aws_cloudfront»GeoRestriction | 
Controls the countries in which content is distributed.
Example
// Adding restrictions to a Cloudfront Web Distribution.
declare const sourceBucket: s3.Bucket;
new cloudfront.CloudFrontWebDistribution(this, 'MyDistribution', {
  originConfigs: [
    {
      s3OriginSource: {
        s3BucketSource: sourceBucket,
      },
      behaviors : [ {isDefaultBehavior: true}],
    },
  ],
  geoRestriction: cloudfront.GeoRestriction.allowlist('US', 'GB'),
});
Properties
| Name | Type | Description | 
|---|---|---|
| locations | string[] | Two-letter, uppercase country code for a country that you want to allow/deny. | 
| restriction | string | Specifies the restriction type to impose. | 
locations
Type:
string[]
Two-letter, uppercase country code for a country that you want to allow/deny.
Include one element for each country. See ISO 3166-1-alpha-2 code on the International Organization for Standardization website
restrictionType
Type:
string
Specifies the restriction type to impose.
Methods
| Name | Description | 
|---|---|
| static allowlist(...locations) | Allow specific countries which you want CloudFront to distribute your content. | 
| static denylist(...locations) | Deny specific countries which you don't want CloudFront to distribute your content. | 
static allowlist(...locations)
public static allowlist(...locations: string[]): GeoRestriction
Parameters
- locations string— Two-letter, uppercase country code for a country that you want to allow.
Returns
Allow specific countries which you want CloudFront to distribute your content.
static denylist(...locations)
public static denylist(...locations: string[]): GeoRestriction
Parameters
- locations string— Two-letter, uppercase country code for a country that you want to deny.
Returns
Deny specific countries which you don't want CloudFront to distribute your content.
