Skip to content
v2.273.0

GeoRestriction Class ​

Controls the countries in which content is distributed.

Example ​

ts
// 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 ​

locationsstring[]locationstyping.List[str]locationsList<String>Locationsstring[]Locations*[]*stringrequired#
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

restrictionTypestringrestriction_typestrrestrictionTypeStringRestrictionTypestringRestrictionType*stringrequired#
Specifies the restriction type to impose.

Methods ​

allowlist(...locations: string[]): GeoRestriction // chainable@staticmethod def allowlist(locations: str) -> GeoRestrictionpublic static GeoRestriction allowlist(String locations)public static GeoRestriction Allowlist(string locations)func Allowlist(Locations *string) GeoRestrictionstatic#
Allow specific countries which you want CloudFront to distribute your content.
1 parameter

Parameters

  • locationslocationslocationslocationsLocations — Two-letter, uppercase country code for a country that you want to allow.
denylist(...locations: string[]): GeoRestriction // chainable@staticmethod def denylist(locations: str) -> GeoRestrictionpublic static GeoRestriction denylist(String locations)public static GeoRestriction Denylist(string locations)func Denylist(Locations *string) GeoRestrictionstatic#
Deny specific countries which you don't want CloudFront to distribute your content.
1 parameter

Parameters

  • locationslocationslocationslocationsLocations — Two-letter, uppercase country code for a country that you want to deny.