GeoRestriction

class aws_cdk.aws_cloudfront.GeoRestriction(*args: Any, **kwargs)

Bases: object

Controls the countries in which content is distributed.

ExampleMetadata:

infused

Example:

# Adding restrictions to a Cloudfront Web Distribution.
# source_bucket: s3.Bucket

cloudfront.CloudFrontWebDistribution(self, "MyDistribution",
    origin_configs=[cloudfront.SourceConfiguration(
        s3_origin_source=cloudfront.S3OriginConfig(
            s3_bucket_source=source_bucket
        ),
        behaviors=[cloudfront.Behavior(is_default_behavior=True)]
    )
    ],
    geo_restriction=cloudfront.GeoRestriction.allowlist("US", "GB")
)

Attributes

locations

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

restriction_type

Specifies the restriction type to impose.

Static Methods

classmethod allowlist(*locations)

Allow specific countries which you want CloudFront to distribute your content.

Parameters:

locations (str) – Two-letter, uppercase country code for a country that you want to allow. Include one element for each country. See ISO 3166-1-alpha-2 code on the International Organization for Standardization website

Return type:

GeoRestriction

classmethod denylist(*locations)

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

Parameters:

locations (str) – Two-letter, uppercase country code for a country that you want to deny. Include one element for each country. See ISO 3166-1-alpha-2 code on the International Organization for Standardization website

Return type:

GeoRestriction