aws-cdk-lib.aws_cloudfront.GeoRestriction

class GeoRestriction

LanguageType name
.NETAmazon.CDK.AWS.CloudFront.GeoRestriction
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscloudfront#GeoRestriction
Javasoftware.amazon.awscdk.services.cloudfront.GeoRestriction
Pythonaws_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

NameTypeDescription
locationsstring[]Two-letter, uppercase country code for a country that you want to allow/deny.
restrictionTypestringSpecifies 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

NameDescription
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

  • GeoRestriction

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

  • GeoRestriction

Deny specific countries which you don't want CloudFront to distribute your content.