CfnDistribution
- class aws_cdk.aws_cloudfront.CfnDistribution(scope, id, *, distribution_config, tags=None)
Bases:
CfnResource
A CloudFormation
AWS::CloudFront::Distribution
.A distribution tells CloudFront where you want content to be delivered from, and the details about how to track and manage content delivery.
- CloudformationResource:
AWS::CloudFront::Distribution
- Link:
- ExampleMetadata:
infused
Example:
# source_bucket: s3.Bucket my_distribution = cloudfront.Distribution(self, "MyCfWebDistribution", default_behavior=cloudfront.BehaviorOptions( origin=origins.S3Origin(source_bucket) ) ) cfn_distribution = my_distribution.node.default_child cfn_distribution.override_logical_id("MyDistributionCFDistribution3H55TI9Q")
Create a new
AWS::CloudFront::Distribution
.- Parameters:
scope (
Construct
) –scope in which this resource is defined.
id (
str
) –scoped id of the resource.
distribution_config (
Union
[IResolvable
,DistributionConfigProperty
,Dict
[str
,Any
]]) – The distribution’s configuration.tags (
Optional
[Sequence
[Union
[CfnTag
,Dict
[str
,Any
]]]]) – A complex type that contains zero or moreTag
elements.
Methods
- add_deletion_override(path)
Syntactic sugar for
addOverride(path, undefined)
.- Parameters:
path (
str
) – The path of the value to delete.- Return type:
None
- add_depends_on(target)
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
- Parameters:
target (
CfnResource
) –- Return type:
None
- add_metadata(key, value)
Add a value to the CloudFormation Resource Metadata.
- Parameters:
key (
str
) –value (
Any
) –
- See:
- Return type:
None
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- add_override(path, value)
Adds an override to the synthesized CloudFormation resource.
To add a property override, either use
addPropertyOverride
or prefixpath
with “Properties.” (i.e.Properties.TopicName
).If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal
.
in the property name, prefix with a\
. In most programming languages you will need to write this as"\\."
because the\
itself will need to be escaped.For example:
cfn_resource.add_override("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", ["myattribute"]) cfn_resource.add_override("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE")
would add the overrides Example:
"Properties": { "GlobalSecondaryIndexes": [ { "Projection": { "NonKeyAttributes": [ "myattribute" ] ... } ... }, { "ProjectionType": "INCLUDE" ... }, ] ... }
The
value
argument toaddOverride
will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.- Parameters:
path (
str
) –The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
value (
Any
) –The value. Could be primitive or complex.
- Return type:
None
- add_property_deletion_override(property_path)
Adds an override that deletes the value of a property from the resource definition.
- Parameters:
property_path (
str
) – The path to the property.- Return type:
None
- add_property_override(property_path, value)
Adds an override to a resource property.
Syntactic sugar for
addOverride("Properties.<...>", value)
.- Parameters:
property_path (
str
) – The path of the property.value (
Any
) – The value.
- Return type:
None
- apply_removal_policy(policy=None, *, apply_to_update_replace_policy=None, default=None)
Sets the deletion policy of the resource based on the removal policy specified.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.
The resource can be deleted (
RemovalPolicy.DESTROY
), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN
).- Parameters:
policy (
Optional
[RemovalPolicy
]) –apply_to_update_replace_policy (
Optional
[bool
]) – Apply the same deletion policy to the resource’s “UpdateReplacePolicy”. Default: truedefault (
Optional
[RemovalPolicy
]) – The default policy to apply in case the removal policy is not defined. Default: - Default value is resource specific. To determine the default value for a resoure, please consult that specific resource’s documentation.
- Return type:
None
- get_att(attribute_name)
Returns a token for an runtime attribute of this resource.
Ideally, use generated attribute accessors (e.g.
resource.arn
), but this can be used for future compatibility in case there is no generated attribute.- Parameters:
attribute_name (
str
) – The name of the attribute.- Return type:
- get_metadata(key)
Retrieve a value value from the CloudFormation Resource Metadata.
- Parameters:
key (
str
) –- See:
- Return type:
Any
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- inspect(inspector)
Examines the CloudFormation resource and discloses attributes.
- Parameters:
inspector (
TreeInspector
) –tree inspector to collect and process attributes.
- Return type:
None
- override_logical_id(new_logical_id)
Overrides the auto-generated logical ID with a specific ID.
- Parameters:
new_logical_id (
str
) – The new logical ID to use for this stack element.- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str
- Returns:
a string representation of this resource
Attributes
- CFN_RESOURCE_TYPE_NAME = 'AWS::CloudFront::Distribution'
- attr_domain_name
The domain name of the resource, such as
d111111abcdef8.cloudfront.net
.- CloudformationAttribute:
DomainName
- attr_id
The identifier for the distribution, for example
EDFDVBD632BHDS5
.- CloudformationAttribute:
Id
- cfn_options
Options for this resource, such as condition, update policy etc.
- cfn_resource_type
AWS resource type.
- creation_stack
return:
the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.
- distribution_config
The distribution’s configuration.
- logical_id
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use
overrideLogicalId(newLogicalId)
.- Returns:
the logical ID as a stringified token. This value will only get resolved during synthesis.
- node
The construct tree node associated with this construct.
- ref
Return a string that will be resolved to a CloudFormation
{ Ref }
for this element.If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through
Lazy.any({ produce: resource.ref })
.
- stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
- tags
A complex type that contains zero or more
Tag
elements.
Static Methods
- classmethod is_cfn_element(x)
Returns
true
if a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceof
to allow stack elements from different versions of this library to be included in the same stack.- Parameters:
x (
Any
) –- Return type:
bool
- Returns:
The construct as a stack element or undefined if it is not a stack element.
- classmethod is_cfn_resource(construct)
Check whether the given construct is a CfnResource.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod is_construct(x)
Return whether the given object is a Construct.
- Parameters:
x (
Any
) –- Return type:
bool
CacheBehaviorProperty
- class CfnDistribution.CacheBehaviorProperty(*, path_pattern, target_origin_id, viewer_protocol_policy, allowed_methods=None, cached_methods=None, cache_policy_id=None, compress=None, default_ttl=None, field_level_encryption_id=None, forwarded_values=None, function_associations=None, lambda_function_associations=None, max_ttl=None, min_ttl=None, origin_request_policy_id=None, realtime_log_config_arn=None, response_headers_policy_id=None, smooth_streaming=None, trusted_key_groups=None, trusted_signers=None)
Bases:
object
A complex type that describes how CloudFront processes requests.
You must create at least as many cache behaviors (including the default cache behavior) as you have origins if you want CloudFront to serve objects from all of the origins. Each cache behavior specifies the one origin from which you want CloudFront to get objects. If you have two origins and only the default cache behavior, the default cache behavior will cause CloudFront to get objects from one of the origins, but the other origin is never used.
For the current quota (formerly known as limit) on the number of cache behaviors that you can add to a distribution, see Quotas in the Amazon CloudFront Developer Guide .
If you don’t want to specify any cache behaviors, include only an empty
CacheBehaviors
element. Don’t include an emptyCacheBehavior
element because this is invalid.To delete all cache behaviors in an existing distribution, update the distribution configuration and include only an empty
CacheBehaviors
element.To add, change, or remove one or more cache behaviors, update the distribution configuration and specify all of the cache behaviors that you want to include in the updated distribution.
For more information about cache behaviors, see Cache Behavior Settings in the Amazon CloudFront Developer Guide .
- Parameters:
path_pattern (
str
) – The pattern (for example,images/*.jpg
) that specifies which requests to apply the behavior to. When CloudFront receives a viewer request, the requested path is compared with path patterns in the order in which cache behaviors are listed in the distribution. .. epigraph:: You can optionally include a slash (/
) at the beginning of the path pattern. For example,/images/*.jpg
. CloudFront behavior is the same with or without the leading/
. The path pattern for the default cache behavior is*
and cannot be changed. If the request for an object does not match the path pattern for any cache behaviors, CloudFront applies the behavior in the default cache behavior. For more information, see Path Pattern in the Amazon CloudFront Developer Guide .target_origin_id (
str
) – The value ofID
for the origin that you want CloudFront to route requests to when they match this cache behavior.viewer_protocol_policy (
str
) – The protocol that viewers can use to access the files in the origin specified byTargetOriginId
when a request matches the path pattern inPathPattern
. You can specify the following options: -allow-all
: Viewers can use HTTP or HTTPS. -redirect-to-https
: If a viewer submits an HTTP request, CloudFront returns an HTTP status code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the new URL. -https-only
: If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403 (Forbidden). For more information about requiring the HTTPS protocol, see Requiring HTTPS Between Viewers and CloudFront in the Amazon CloudFront Developer Guide . .. epigraph:: The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that you clear your objects’ cache because cached objects are protocol agnostic. That means that an edge location will return an object from the cache regardless of whether the current request protocol matches the protocol used previously. For more information, see Managing Cache Expiration in the Amazon CloudFront Developer Guide .allowed_methods (
Optional
[Sequence
[str
]]) – A complex type that controls which HTTP methods CloudFront processes and forwards to your Amazon S3 bucket or your custom origin. There are three choices: - CloudFront forwards onlyGET
andHEAD
requests. - CloudFront forwards onlyGET
,HEAD
, andOPTIONS
requests. - CloudFront forwardsGET, HEAD, OPTIONS, PUT, PATCH, POST
, andDELETE
requests. If you pick the third choice, you may need to restrict access to your Amazon S3 bucket or to your custom origin so users can’t perform operations that you don’t want them to. For example, you might not want users to have permissions to delete objects from your origin.cached_methods (
Optional
[Sequence
[str
]]) – A complex type that controls whether CloudFront caches the response to requests using the specified HTTP methods. There are two choices: - CloudFront caches responses toGET
andHEAD
requests. - CloudFront caches responses toGET
,HEAD
, andOPTIONS
requests. If you pick the second choice for your Amazon S3 Origin, you may need to forward Access-Control-Request-Method, Access-Control-Request-Headers, and Origin headers for the responses to be cached correctly.cache_policy_id (
Optional
[str
]) – The unique identifier of the cache policy that is attached to this cache behavior. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide . ACacheBehavior
must include either aCachePolicyId
orForwardedValues
. We recommend that you use aCachePolicyId
.compress (
Union
[bool
,IResolvable
,None
]) – Whether you want CloudFront to automatically compress certain files for this cache behavior. If so, specify true; if not, specify false. For more information, see Serving Compressed Files in the Amazon CloudFront Developer Guide .default_ttl (
Union
[int
,float
,None
]) –This field is deprecated. We recommend that you use the
DefaultTTL
field in a cache policy instead of this field. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide . The default amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin does not add HTTP headers such asCache-Control max-age
,Cache-Control s-maxage
, andExpires
to objects. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .field_level_encryption_id (
Optional
[str
]) – The value ofID
for the field-level encryption configuration that you want CloudFront to use for encrypting specific fields of data for this cache behavior.forwarded_values (
Union
[ForwardedValuesProperty
,Dict
[str
,Any
],IResolvable
,None
]) –This field is deprecated. We recommend that you use a cache policy or an origin request policy instead of this field. For more information, see Working with policies in the Amazon CloudFront Developer Guide . If you want to include values in the cache key, use a cache policy. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide . If you want to send values to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies or Using the managed origin request policies in the Amazon CloudFront Developer Guide . A
CacheBehavior
must include either aCachePolicyId
orForwardedValues
. We recommend that you use aCachePolicyId
. A complex type that specifies how CloudFront handles query strings, cookies, and HTTP headers.function_associations (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,FunctionAssociationProperty
,Dict
[str
,Any
]]],None
]) – A list of CloudFront functions that are associated with this cache behavior. CloudFront functions must be published to theLIVE
stage to associate them with a cache behavior.lambda_function_associations (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,LambdaFunctionAssociationProperty
,Dict
[str
,Any
]]],None
]) – A complex type that contains zero or more Lambda@Edge function associations for a cache behavior.max_ttl (
Union
[int
,float
,None
]) –This field is deprecated. We recommend that you use the
MaxTTL
field in a cache policy instead of this field. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide . The maximum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin adds HTTP headers such asCache-Control max-age
,Cache-Control s-maxage
, andExpires
to objects. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .min_ttl (
Union
[int
,float
,None
]) –This field is deprecated. We recommend that you use the
MinTTL
field in a cache policy instead of this field. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide . The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide . You must specify0
forMinTTL
if you configure CloudFront to forward all headers to your origin (underHeaders
, if you specify1
forQuantity
and*
forName
).origin_request_policy_id (
Optional
[str
]) –The unique identifier of the origin request policy that is attached to this cache behavior. For more information, see Creating origin request policies or Using the managed origin request policies in the Amazon CloudFront Developer Guide .
realtime_log_config_arn (
Optional
[str
]) – The Amazon Resource Name (ARN) of the real-time log configuration that is attached to this cache behavior. For more information, see Real-time logs in the Amazon CloudFront Developer Guide .response_headers_policy_id (
Optional
[str
]) – The identifier for a response headers policy.smooth_streaming (
Union
[bool
,IResolvable
,None
]) – Indicates whether you want to distribute media files in the Microsoft Smooth Streaming format using the origin that is associated with this cache behavior. If so, specifytrue
; if not, specifyfalse
. If you specifytrue
forSmoothStreaming
, you can still distribute other content using this cache behavior if the content matches the value ofPathPattern
.trusted_key_groups (
Optional
[Sequence
[str
]]) – A list of key groups that CloudFront can use to validate signed URLs or signed cookies. When a cache behavior contains trusted key groups, CloudFront requires signed URLs or signed cookies for all requests that match the cache behavior. The URLs or cookies must be signed with a private key whose corresponding public key is in the key group. The signed URL or cookie contains information about which public key CloudFront should use to verify the signature. For more information, see Serving private content in the Amazon CloudFront Developer Guide .trusted_signers (
Optional
[Sequence
[str
]]) –We recommend using
TrustedKeyGroups
instead ofTrustedSigners
. A list of AWS account IDs whose public keys CloudFront can use to validate signed URLs or signed cookies. When a cache behavior contains trusted signers, CloudFront requires signed URLs or signed cookies for all requests that match the cache behavior. The URLs or cookies must be signed with the private key of a CloudFront key pair in the trusted signer’s AWS account . The signed URL or cookie contains information about which public key CloudFront should use to verify the signature. For more information, see Serving private content in the Amazon CloudFront Developer Guide .
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront cache_behavior_property = cloudfront.CfnDistribution.CacheBehaviorProperty( path_pattern="pathPattern", target_origin_id="targetOriginId", viewer_protocol_policy="viewerProtocolPolicy", # the properties below are optional allowed_methods=["allowedMethods"], cached_methods=["cachedMethods"], cache_policy_id="cachePolicyId", compress=False, default_ttl=123, field_level_encryption_id="fieldLevelEncryptionId", forwarded_values=cloudfront.CfnDistribution.ForwardedValuesProperty( query_string=False, # the properties below are optional cookies=cloudfront.CfnDistribution.CookiesProperty( forward="forward", # the properties below are optional whitelisted_names=["whitelistedNames"] ), headers=["headers"], query_string_cache_keys=["queryStringCacheKeys"] ), function_associations=[cloudfront.CfnDistribution.FunctionAssociationProperty( event_type="eventType", function_arn="functionArn" )], lambda_function_associations=[cloudfront.CfnDistribution.LambdaFunctionAssociationProperty( event_type="eventType", include_body=False, lambda_function_arn="lambdaFunctionArn" )], max_ttl=123, min_ttl=123, origin_request_policy_id="originRequestPolicyId", realtime_log_config_arn="realtimeLogConfigArn", response_headers_policy_id="responseHeadersPolicyId", smooth_streaming=False, trusted_key_groups=["trustedKeyGroups"], trusted_signers=["trustedSigners"] )
Attributes
- allowed_methods
A complex type that controls which HTTP methods CloudFront processes and forwards to your Amazon S3 bucket or your custom origin.
There are three choices:
CloudFront forwards only
GET
andHEAD
requests.CloudFront forwards only
GET
,HEAD
, andOPTIONS
requests.CloudFront forwards
GET, HEAD, OPTIONS, PUT, PATCH, POST
, andDELETE
requests.
If you pick the third choice, you may need to restrict access to your Amazon S3 bucket or to your custom origin so users can’t perform operations that you don’t want them to. For example, you might not want users to have permissions to delete objects from your origin.
- cache_policy_id
The unique identifier of the cache policy that is attached to this cache behavior.
For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide .
A
CacheBehavior
must include either aCachePolicyId
orForwardedValues
. We recommend that you use aCachePolicyId
.
- cached_methods
A complex type that controls whether CloudFront caches the response to requests using the specified HTTP methods.
There are two choices:
CloudFront caches responses to
GET
andHEAD
requests.CloudFront caches responses to
GET
,HEAD
, andOPTIONS
requests.
If you pick the second choice for your Amazon S3 Origin, you may need to forward Access-Control-Request-Method, Access-Control-Request-Headers, and Origin headers for the responses to be cached correctly.
- compress
Whether you want CloudFront to automatically compress certain files for this cache behavior.
If so, specify true; if not, specify false. For more information, see Serving Compressed Files in the Amazon CloudFront Developer Guide .
- default_ttl
This field is deprecated.
We recommend that you use the
DefaultTTL
field in a cache policy instead of this field. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide .The default amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin does not add HTTP headers such as
Cache-Control max-age
,Cache-Control s-maxage
, andExpires
to objects. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
- field_level_encryption_id
The value of
ID
for the field-level encryption configuration that you want CloudFront to use for encrypting specific fields of data for this cache behavior.
- forwarded_values
This field is deprecated.
We recommend that you use a cache policy or an origin request policy instead of this field. For more information, see Working with policies in the Amazon CloudFront Developer Guide .
If you want to include values in the cache key, use a cache policy. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide .
If you want to send values to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies or Using the managed origin request policies in the Amazon CloudFront Developer Guide .
A
CacheBehavior
must include either aCachePolicyId
orForwardedValues
. We recommend that you use aCachePolicyId
.A complex type that specifies how CloudFront handles query strings, cookies, and HTTP headers.
- function_associations
A list of CloudFront functions that are associated with this cache behavior.
CloudFront functions must be published to the
LIVE
stage to associate them with a cache behavior.
- lambda_function_associations
A complex type that contains zero or more Lambda@Edge function associations for a cache behavior.
- max_ttl
This field is deprecated.
We recommend that you use the
MaxTTL
field in a cache policy instead of this field. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide .The maximum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin adds HTTP headers such as
Cache-Control max-age
,Cache-Control s-maxage
, andExpires
to objects. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
- min_ttl
This field is deprecated.
We recommend that you use the
MinTTL
field in a cache policy instead of this field. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide .The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
You must specify
0
forMinTTL
if you configure CloudFront to forward all headers to your origin (underHeaders
, if you specify1
forQuantity
and*
forName
).
- origin_request_policy_id
The unique identifier of the origin request policy that is attached to this cache behavior.
For more information, see Creating origin request policies or Using the managed origin request policies in the Amazon CloudFront Developer Guide .
- path_pattern
The pattern (for example,
images/*.jpg
) that specifies which requests to apply the behavior to. When CloudFront receives a viewer request, the requested path is compared with path patterns in the order in which cache behaviors are listed in the distribution.You can optionally include a slash (
/
) at the beginning of the path pattern. For example,/images/*.jpg
. CloudFront behavior is the same with or without the leading/
.The path pattern for the default cache behavior is
*
and cannot be changed. If the request for an object does not match the path pattern for any cache behaviors, CloudFront applies the behavior in the default cache behavior.For more information, see Path Pattern in the Amazon CloudFront Developer Guide .
- realtime_log_config_arn
The Amazon Resource Name (ARN) of the real-time log configuration that is attached to this cache behavior.
For more information, see Real-time logs in the Amazon CloudFront Developer Guide .
- response_headers_policy_id
The identifier for a response headers policy.
- smooth_streaming
Indicates whether you want to distribute media files in the Microsoft Smooth Streaming format using the origin that is associated with this cache behavior.
If so, specify
true
; if not, specifyfalse
. If you specifytrue
forSmoothStreaming
, you can still distribute other content using this cache behavior if the content matches the value ofPathPattern
.
- target_origin_id
The value of
ID
for the origin that you want CloudFront to route requests to when they match this cache behavior.
- trusted_key_groups
A list of key groups that CloudFront can use to validate signed URLs or signed cookies.
When a cache behavior contains trusted key groups, CloudFront requires signed URLs or signed cookies for all requests that match the cache behavior. The URLs or cookies must be signed with a private key whose corresponding public key is in the key group. The signed URL or cookie contains information about which public key CloudFront should use to verify the signature. For more information, see Serving private content in the Amazon CloudFront Developer Guide .
- trusted_signers
We recommend using
TrustedKeyGroups
instead ofTrustedSigners
.A list of AWS account IDs whose public keys CloudFront can use to validate signed URLs or signed cookies.
When a cache behavior contains trusted signers, CloudFront requires signed URLs or signed cookies for all requests that match the cache behavior. The URLs or cookies must be signed with the private key of a CloudFront key pair in the trusted signer’s AWS account . The signed URL or cookie contains information about which public key CloudFront should use to verify the signature. For more information, see Serving private content in the Amazon CloudFront Developer Guide .
- viewer_protocol_policy
The protocol that viewers can use to access the files in the origin specified by
TargetOriginId
when a request matches the path pattern inPathPattern
.You can specify the following options:
allow-all
: Viewers can use HTTP or HTTPS.redirect-to-https
: If a viewer submits an HTTP request, CloudFront returns an HTTP status code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the new URL.https-only
: If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403 (Forbidden).
For more information about requiring the HTTPS protocol, see Requiring HTTPS Between Viewers and CloudFront in the Amazon CloudFront Developer Guide . .. epigraph:
The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that you clear your objects' cache because cached objects are protocol agnostic. That means that an edge location will return an object from the cache regardless of whether the current request protocol matches the protocol used previously. For more information, see `Managing Cache Expiration <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html>`_ in the *Amazon CloudFront Developer Guide* .
CustomErrorResponseProperty
- class CfnDistribution.CustomErrorResponseProperty(*, error_code, error_caching_min_ttl=None, response_code=None, response_page_path=None)
Bases:
object
A complex type that controls:.
Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer.
How long CloudFront caches HTTP status codes in the 4xx and 5xx range.
For more information about custom error pages, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
- Parameters:
error_code (
Union
[int
,float
]) – The HTTP status code for which you want to specify a custom error page and/or a caching duration.error_caching_min_ttl (
Union
[int
,float
,None
]) –The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in
ErrorCode
. When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available. For more information, see Customizing Error Responses in the Amazon CloudFront Developer Guide .response_code (
Union
[int
,float
,None
]) – The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example: - Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute200
, the response typically won’t be intercepted. - If you don’t care about distinguishing among different client errors or server errors, you can specify400
or500
as theResponseCode
for all 4xx or 5xx errors. - You might want to return a200
status code (OK) and static website so your customers don’t know that your website is down. If you specify a value forResponseCode
, you must also specify a value forResponsePagePath
.response_page_path (
Optional
[str
]) – The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified byErrorCode
, for example,/4xx-errors/403-forbidden.html
. If you want to store your objects and your custom error pages in different locations, your distribution must include a cache behavior for which the following is true:. - The value ofPathPattern
matches the path to your custom error messages. For example, suppose you saved custom error pages for 4xx errors in an Amazon S3 bucket in a directory named/4xx-errors
. Your distribution must include a cache behavior for which the path pattern routes requests for your custom error pages to that location, for example,/4xx-errors/*
. - The value ofTargetOriginId
specifies the value of theID
element for the origin that contains your custom error pages. If you specify a value forResponsePagePath
, you must also specify a value forResponseCode
. We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can’t get the files that you want to return to viewers because the origin server is unavailable.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront custom_error_response_property = cloudfront.CfnDistribution.CustomErrorResponseProperty( error_code=123, # the properties below are optional error_caching_min_ttl=123, response_code=123, response_page_path="responsePagePath" )
Attributes
- error_caching_min_ttl
The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in
ErrorCode
.When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available.
For more information, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
- error_code
The HTTP status code for which you want to specify a custom error page and/or a caching duration.
- response_code
The HTTP status code that you want CloudFront to return to the viewer along with the custom error page.
There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:
Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute
200
, the response typically won’t be intercepted.If you don’t care about distinguishing among different client errors or server errors, you can specify
400
or500
as theResponseCode
for all 4xx or 5xx errors.You might want to return a
200
status code (OK) and static website so your customers don’t know that your website is down.
If you specify a value for
ResponseCode
, you must also specify a value forResponsePagePath
.
- response_page_path
.
The value of
PathPattern
matches the path to your custom error messages. For example, suppose you saved custom error pages for 4xx errors in an Amazon S3 bucket in a directory named/4xx-errors
. Your distribution must include a cache behavior for which the path pattern routes requests for your custom error pages to that location, for example,/4xx-errors/*
.The value of
TargetOriginId
specifies the value of theID
element for the origin that contains your custom error pages.
If you specify a value for
ResponsePagePath
, you must also specify a value forResponseCode
.We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can’t get the files that you want to return to viewers because the origin server is unavailable.
- Link:
- Type:
The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by
ErrorCode
, for example,/4xx-errors/403-forbidden.html
. If you want to store your objects and your custom error pages in different locations, your distribution must include a cache behavior for which the following is true
CustomOriginConfigProperty
- class CfnDistribution.CustomOriginConfigProperty(*, origin_protocol_policy, http_port=None, https_port=None, origin_keepalive_timeout=None, origin_read_timeout=None, origin_ssl_protocols=None)
Bases:
object
A custom origin.
A custom origin is any origin that is not an Amazon S3 bucket, with one exception. An Amazon S3 bucket that is configured with static website hosting is a custom origin.
- Parameters:
origin_protocol_policy (
str
) – Specifies the protocol (HTTP or HTTPS) that CloudFront uses to connect to the origin. Valid values are:. -http-only
– CloudFront always uses HTTP to connect to the origin. -match-viewer
– CloudFront connects to the origin using the same protocol that the viewer used to connect to CloudFront. -https-only
– CloudFront always uses HTTPS to connect to the origin.http_port (
Union
[int
,float
,None
]) – The HTTP port that CloudFront uses to connect to the origin. Specify the HTTP port that the origin listens on.https_port (
Union
[int
,float
,None
]) – The HTTPS port that CloudFront uses to connect to the origin. Specify the HTTPS port that the origin listens on.origin_keepalive_timeout (
Union
[int
,float
,None
]) – Specifies how long, in seconds, CloudFront persists its connection to the origin. The minimum timeout is 1 second, the maximum is 60 seconds, and the default (if you don’t specify otherwise) is 5 seconds. For more information, see Origin Keep-alive Timeout in the Amazon CloudFront Developer Guide .origin_read_timeout (
Union
[int
,float
,None
]) – Specifies how long, in seconds, CloudFront waits for a response from the origin. This is also known as the origin response timeout . The minimum timeout is 1 second, the maximum is 60 seconds, and the default (if you don’t specify otherwise) is 30 seconds. For more information, see Origin Response Timeout in the Amazon CloudFront Developer Guide .origin_ssl_protocols (
Optional
[Sequence
[str
]]) – Specifies the minimum SSL/TLS protocol that CloudFront uses when connecting to your origin over HTTPS. Valid values includeSSLv3
,TLSv1
,TLSv1.1
, andTLSv1.2
. For more information, see Minimum Origin SSL Protocol in the Amazon CloudFront Developer Guide .
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront custom_origin_config_property = cloudfront.CfnDistribution.CustomOriginConfigProperty( origin_protocol_policy="originProtocolPolicy", # the properties below are optional http_port=123, https_port=123, origin_keepalive_timeout=123, origin_read_timeout=123, origin_ssl_protocols=["originSslProtocols"] )
Attributes
- http_port
The HTTP port that CloudFront uses to connect to the origin.
Specify the HTTP port that the origin listens on.
- https_port
The HTTPS port that CloudFront uses to connect to the origin.
Specify the HTTPS port that the origin listens on.
- origin_keepalive_timeout
Specifies how long, in seconds, CloudFront persists its connection to the origin.
The minimum timeout is 1 second, the maximum is 60 seconds, and the default (if you don’t specify otherwise) is 5 seconds.
For more information, see Origin Keep-alive Timeout in the Amazon CloudFront Developer Guide .
- origin_protocol_policy
.
http-only
– CloudFront always uses HTTP to connect to the origin.match-viewer
– CloudFront connects to the origin using the same protocol that the viewer used to connect to CloudFront.https-only
– CloudFront always uses HTTPS to connect to the origin.
- Link:
- Type:
Specifies the protocol (HTTP or HTTPS) that CloudFront uses to connect to the origin. Valid values are
- origin_read_timeout
Specifies how long, in seconds, CloudFront waits for a response from the origin.
This is also known as the origin response timeout . The minimum timeout is 1 second, the maximum is 60 seconds, and the default (if you don’t specify otherwise) is 30 seconds.
For more information, see Origin Response Timeout in the Amazon CloudFront Developer Guide .
- origin_ssl_protocols
Specifies the minimum SSL/TLS protocol that CloudFront uses when connecting to your origin over HTTPS.
Valid values include
SSLv3
,TLSv1
,TLSv1.1
, andTLSv1.2
.For more information, see Minimum Origin SSL Protocol in the Amazon CloudFront Developer Guide .
DefaultCacheBehaviorProperty
- class CfnDistribution.DefaultCacheBehaviorProperty(*, target_origin_id, viewer_protocol_policy, allowed_methods=None, cached_methods=None, cache_policy_id=None, compress=None, default_ttl=None, field_level_encryption_id=None, forwarded_values=None, function_associations=None, lambda_function_associations=None, max_ttl=None, min_ttl=None, origin_request_policy_id=None, realtime_log_config_arn=None, response_headers_policy_id=None, smooth_streaming=None, trusted_key_groups=None, trusted_signers=None)
Bases:
object
A complex type that describes the default cache behavior if you don’t specify a
CacheBehavior
element or if request URLs don’t match any of the values ofPathPattern
inCacheBehavior
elements.You must create exactly one default cache behavior.
- Parameters:
target_origin_id (
str
) – The value ofID
for the origin that you want CloudFront to route requests to when they use the default cache behavior.viewer_protocol_policy (
str
) –The protocol that viewers can use to access the files in the origin specified by
TargetOriginId
when a request matches the path pattern inPathPattern
. You can specify the following options: -allow-all
: Viewers can use HTTP or HTTPS. -redirect-to-https
: If a viewer submits an HTTP request, CloudFront returns an HTTP status code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the new URL. -https-only
: If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403 (Forbidden). For more information about requiring the HTTPS protocol, see Requiring HTTPS Between Viewers and CloudFront in the Amazon CloudFront Developer Guide . .. epigraph:: The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that you clear your objects’ cache because cached objects are protocol agnostic. That means that an edge location will return an object from the cache regardless of whether the current request protocol matches the protocol used previously. For more information, see Managing Cache Expiration in the Amazon CloudFront Developer Guide .allowed_methods (
Optional
[Sequence
[str
]]) – A complex type that controls which HTTP methods CloudFront processes and forwards to your Amazon S3 bucket or your custom origin. There are three choices: - CloudFront forwards onlyGET
andHEAD
requests. - CloudFront forwards onlyGET
,HEAD
, andOPTIONS
requests. - CloudFront forwardsGET, HEAD, OPTIONS, PUT, PATCH, POST
, andDELETE
requests. If you pick the third choice, you may need to restrict access to your Amazon S3 bucket or to your custom origin so users can’t perform operations that you don’t want them to. For example, you might not want users to have permissions to delete objects from your origin.cached_methods (
Optional
[Sequence
[str
]]) – A complex type that controls whether CloudFront caches the response to requests using the specified HTTP methods. There are two choices: - CloudFront caches responses toGET
andHEAD
requests. - CloudFront caches responses toGET
,HEAD
, andOPTIONS
requests. If you pick the second choice for your Amazon S3 Origin, you may need to forward Access-Control-Request-Method, Access-Control-Request-Headers, and Origin headers for the responses to be cached correctly.cache_policy_id (
Optional
[str
]) –The unique identifier of the cache policy that is attached to the default cache behavior. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide . A
DefaultCacheBehavior
must include either aCachePolicyId
orForwardedValues
. We recommend that you use aCachePolicyId
.compress (
Union
[bool
,IResolvable
,None
]) –Whether you want CloudFront to automatically compress certain files for this cache behavior. If so, specify
true
; if not, specifyfalse
. For more information, see Serving Compressed Files in the Amazon CloudFront Developer Guide .default_ttl (
Union
[int
,float
,None
]) –This field is deprecated. We recommend that you use the
DefaultTTL
field in a cache policy instead of this field. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide . The default amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin does not add HTTP headers such asCache-Control max-age
,Cache-Control s-maxage
, andExpires
to objects. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .field_level_encryption_id (
Optional
[str
]) – The value ofID
for the field-level encryption configuration that you want CloudFront to use for encrypting specific fields of data for the default cache behavior.forwarded_values (
Union
[ForwardedValuesProperty
,Dict
[str
,Any
],IResolvable
,None
]) –This field is deprecated. We recommend that you use a cache policy or an origin request policy instead of this field. For more information, see Working with policies in the Amazon CloudFront Developer Guide . If you want to include values in the cache key, use a cache policy. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide . If you want to send values to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies or Using the managed origin request policies in the Amazon CloudFront Developer Guide . A
DefaultCacheBehavior
must include either aCachePolicyId
orForwardedValues
. We recommend that you use aCachePolicyId
. A complex type that specifies how CloudFront handles query strings, cookies, and HTTP headers.function_associations (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,FunctionAssociationProperty
,Dict
[str
,Any
]]],None
]) – A list of CloudFront functions that are associated with this cache behavior. CloudFront functions must be published to theLIVE
stage to associate them with a cache behavior.lambda_function_associations (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,LambdaFunctionAssociationProperty
,Dict
[str
,Any
]]],None
]) – A complex type that contains zero or more Lambda@Edge function associations for a cache behavior.max_ttl (
Union
[int
,float
,None
]) –This field is deprecated. We recommend that you use the
MaxTTL
field in a cache policy instead of this field. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide . The maximum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin adds HTTP headers such asCache-Control max-age
,Cache-Control s-maxage
, andExpires
to objects. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .min_ttl (
Union
[int
,float
,None
]) –This field is deprecated. We recommend that you use the
MinTTL
field in a cache policy instead of this field. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide . The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide . You must specify0
forMinTTL
if you configure CloudFront to forward all headers to your origin (underHeaders
, if you specify1
forQuantity
and*
forName
).origin_request_policy_id (
Optional
[str
]) –The unique identifier of the origin request policy that is attached to the default cache behavior. For more information, see Creating origin request policies or Using the managed origin request policies in the Amazon CloudFront Developer Guide .
realtime_log_config_arn (
Optional
[str
]) –The Amazon Resource Name (ARN) of the real-time log configuration that is attached to this cache behavior. For more information, see Real-time logs in the Amazon CloudFront Developer Guide .
response_headers_policy_id (
Optional
[str
]) – The identifier for a response headers policy.smooth_streaming (
Union
[bool
,IResolvable
,None
]) – Indicates whether you want to distribute media files in the Microsoft Smooth Streaming format using the origin that is associated with this cache behavior. If so, specifytrue
; if not, specifyfalse
. If you specifytrue
forSmoothStreaming
, you can still distribute other content using this cache behavior if the content matches the value ofPathPattern
.trusted_key_groups (
Optional
[Sequence
[str
]]) –A list of key groups that CloudFront can use to validate signed URLs or signed cookies. When a cache behavior contains trusted key groups, CloudFront requires signed URLs or signed cookies for all requests that match the cache behavior. The URLs or cookies must be signed with a private key whose corresponding public key is in the key group. The signed URL or cookie contains information about which public key CloudFront should use to verify the signature. For more information, see Serving private content in the Amazon CloudFront Developer Guide .
trusted_signers (
Optional
[Sequence
[str
]]) –We recommend using
TrustedKeyGroups
instead ofTrustedSigners
. A list of AWS account IDs whose public keys CloudFront can use to validate signed URLs or signed cookies. When a cache behavior contains trusted signers, CloudFront requires signed URLs or signed cookies for all requests that match the cache behavior. The URLs or cookies must be signed with the private key of a CloudFront key pair in a trusted signer’s AWS account . The signed URL or cookie contains information about which public key CloudFront should use to verify the signature. For more information, see Serving private content in the Amazon CloudFront Developer Guide .
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront default_cache_behavior_property = cloudfront.CfnDistribution.DefaultCacheBehaviorProperty( target_origin_id="targetOriginId", viewer_protocol_policy="viewerProtocolPolicy", # the properties below are optional allowed_methods=["allowedMethods"], cached_methods=["cachedMethods"], cache_policy_id="cachePolicyId", compress=False, default_ttl=123, field_level_encryption_id="fieldLevelEncryptionId", forwarded_values=cloudfront.CfnDistribution.ForwardedValuesProperty( query_string=False, # the properties below are optional cookies=cloudfront.CfnDistribution.CookiesProperty( forward="forward", # the properties below are optional whitelisted_names=["whitelistedNames"] ), headers=["headers"], query_string_cache_keys=["queryStringCacheKeys"] ), function_associations=[cloudfront.CfnDistribution.FunctionAssociationProperty( event_type="eventType", function_arn="functionArn" )], lambda_function_associations=[cloudfront.CfnDistribution.LambdaFunctionAssociationProperty( event_type="eventType", include_body=False, lambda_function_arn="lambdaFunctionArn" )], max_ttl=123, min_ttl=123, origin_request_policy_id="originRequestPolicyId", realtime_log_config_arn="realtimeLogConfigArn", response_headers_policy_id="responseHeadersPolicyId", smooth_streaming=False, trusted_key_groups=["trustedKeyGroups"], trusted_signers=["trustedSigners"] )
Attributes
- allowed_methods
A complex type that controls which HTTP methods CloudFront processes and forwards to your Amazon S3 bucket or your custom origin.
There are three choices:
CloudFront forwards only
GET
andHEAD
requests.CloudFront forwards only
GET
,HEAD
, andOPTIONS
requests.CloudFront forwards
GET, HEAD, OPTIONS, PUT, PATCH, POST
, andDELETE
requests.
If you pick the third choice, you may need to restrict access to your Amazon S3 bucket or to your custom origin so users can’t perform operations that you don’t want them to. For example, you might not want users to have permissions to delete objects from your origin.
- cache_policy_id
The unique identifier of the cache policy that is attached to the default cache behavior.
For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide .
A
DefaultCacheBehavior
must include either aCachePolicyId
orForwardedValues
. We recommend that you use aCachePolicyId
.
- cached_methods
A complex type that controls whether CloudFront caches the response to requests using the specified HTTP methods.
There are two choices:
CloudFront caches responses to
GET
andHEAD
requests.CloudFront caches responses to
GET
,HEAD
, andOPTIONS
requests.
If you pick the second choice for your Amazon S3 Origin, you may need to forward Access-Control-Request-Method, Access-Control-Request-Headers, and Origin headers for the responses to be cached correctly.
- compress
Whether you want CloudFront to automatically compress certain files for this cache behavior.
If so, specify
true
; if not, specifyfalse
. For more information, see Serving Compressed Files in the Amazon CloudFront Developer Guide .
- default_ttl
This field is deprecated.
We recommend that you use the
DefaultTTL
field in a cache policy instead of this field. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide .The default amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin does not add HTTP headers such as
Cache-Control max-age
,Cache-Control s-maxage
, andExpires
to objects. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
- field_level_encryption_id
The value of
ID
for the field-level encryption configuration that you want CloudFront to use for encrypting specific fields of data for the default cache behavior.
- forwarded_values
This field is deprecated.
We recommend that you use a cache policy or an origin request policy instead of this field. For more information, see Working with policies in the Amazon CloudFront Developer Guide .
If you want to include values in the cache key, use a cache policy. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide .
If you want to send values to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies or Using the managed origin request policies in the Amazon CloudFront Developer Guide .
A
DefaultCacheBehavior
must include either aCachePolicyId
orForwardedValues
. We recommend that you use aCachePolicyId
.A complex type that specifies how CloudFront handles query strings, cookies, and HTTP headers.
- function_associations
A list of CloudFront functions that are associated with this cache behavior.
CloudFront functions must be published to the
LIVE
stage to associate them with a cache behavior.
- lambda_function_associations
A complex type that contains zero or more Lambda@Edge function associations for a cache behavior.
- max_ttl
This field is deprecated.
We recommend that you use the
MaxTTL
field in a cache policy instead of this field. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide .The maximum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin adds HTTP headers such as
Cache-Control max-age
,Cache-Control s-maxage
, andExpires
to objects. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
- min_ttl
This field is deprecated.
We recommend that you use the
MinTTL
field in a cache policy instead of this field. For more information, see Creating cache policies or Using the managed cache policies in the Amazon CloudFront Developer Guide .The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
You must specify
0
forMinTTL
if you configure CloudFront to forward all headers to your origin (underHeaders
, if you specify1
forQuantity
and*
forName
).
- origin_request_policy_id
The unique identifier of the origin request policy that is attached to the default cache behavior.
For more information, see Creating origin request policies or Using the managed origin request policies in the Amazon CloudFront Developer Guide .
- realtime_log_config_arn
The Amazon Resource Name (ARN) of the real-time log configuration that is attached to this cache behavior.
For more information, see Real-time logs in the Amazon CloudFront Developer Guide .
- response_headers_policy_id
The identifier for a response headers policy.
- smooth_streaming
Indicates whether you want to distribute media files in the Microsoft Smooth Streaming format using the origin that is associated with this cache behavior.
If so, specify
true
; if not, specifyfalse
. If you specifytrue
forSmoothStreaming
, you can still distribute other content using this cache behavior if the content matches the value ofPathPattern
.
- target_origin_id
The value of
ID
for the origin that you want CloudFront to route requests to when they use the default cache behavior.
- trusted_key_groups
A list of key groups that CloudFront can use to validate signed URLs or signed cookies.
When a cache behavior contains trusted key groups, CloudFront requires signed URLs or signed cookies for all requests that match the cache behavior. The URLs or cookies must be signed with a private key whose corresponding public key is in the key group. The signed URL or cookie contains information about which public key CloudFront should use to verify the signature. For more information, see Serving private content in the Amazon CloudFront Developer Guide .
- trusted_signers
We recommend using
TrustedKeyGroups
instead ofTrustedSigners
.A list of AWS account IDs whose public keys CloudFront can use to validate signed URLs or signed cookies.
When a cache behavior contains trusted signers, CloudFront requires signed URLs or signed cookies for all requests that match the cache behavior. The URLs or cookies must be signed with the private key of a CloudFront key pair in a trusted signer’s AWS account . The signed URL or cookie contains information about which public key CloudFront should use to verify the signature. For more information, see Serving private content in the Amazon CloudFront Developer Guide .
- viewer_protocol_policy
The protocol that viewers can use to access the files in the origin specified by
TargetOriginId
when a request matches the path pattern inPathPattern
.You can specify the following options:
allow-all
: Viewers can use HTTP or HTTPS.redirect-to-https
: If a viewer submits an HTTP request, CloudFront returns an HTTP status code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the new URL.https-only
: If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403 (Forbidden).
For more information about requiring the HTTPS protocol, see Requiring HTTPS Between Viewers and CloudFront in the Amazon CloudFront Developer Guide . .. epigraph:
The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that you clear your objects' cache because cached objects are protocol agnostic. That means that an edge location will return an object from the cache regardless of whether the current request protocol matches the protocol used previously. For more information, see `Managing Cache Expiration <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html>`_ in the *Amazon CloudFront Developer Guide* .
DistributionConfigProperty
- class CfnDistribution.DistributionConfigProperty(*, default_cache_behavior, enabled, aliases=None, cache_behaviors=None, cnam_es=None, comment=None, continuous_deployment_policy_id=None, custom_error_responses=None, custom_origin=None, default_root_object=None, http_version=None, ipv6_enabled=None, logging=None, origin_groups=None, origins=None, price_class=None, restrictions=None, s3_origin=None, staging=None, viewer_certificate=None, web_acl_id=None)
Bases:
object
A distribution configuration.
- Parameters:
default_cache_behavior (
Union
[IResolvable
,DefaultCacheBehaviorProperty
,Dict
[str
,Any
]]) – A complex type that describes the default cache behavior if you don’t specify aCacheBehavior
element or if files don’t match any of the values ofPathPattern
inCacheBehavior
elements. You must create exactly one default cache behavior.enabled (
Union
[bool
,IResolvable
]) – From this field, you can enable or disable the selected distribution.aliases (
Optional
[Sequence
[str
]]) – A complex type that contains information about CNAMEs (alternate domain names), if any, for this distribution.cache_behaviors (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,CacheBehaviorProperty
,Dict
[str
,Any
]]],None
]) – A complex type that contains zero or moreCacheBehavior
elements.cnam_es (
Optional
[Sequence
[str
]]) –CfnDistribution.DistributionConfigProperty.CNAMEs
.comment (
Optional
[str
]) – A comment to describe the distribution. The comment cannot be longer than 128 characters.continuous_deployment_policy_id (
Optional
[str
]) – The identifier of a continuous deployment policy. For more information, seeCreateContinuousDeploymentPolicy
.custom_error_responses (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,CustomErrorResponseProperty
,Dict
[str
,Any
]]],None
]) –A complex type that controls the following:. - Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer. - How long CloudFront caches HTTP status codes in the 4xx and 5xx range. For more information about custom error pages, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
custom_origin (
Union
[IResolvable
,LegacyCustomOriginProperty
,Dict
[str
,Any
],None
]) –CfnDistribution.DistributionConfigProperty.CustomOrigin
.default_root_object (
Optional
[str
]) – The object that you want CloudFront to request from your origin (for example,index.html
) when a viewer requests the root URL for your distribution (https://www.example.com
) instead of an object in your distribution (https://www.example.com/product-description.html
). Specifying a default root object avoids exposing the contents of your distribution. Specify only the object name, for example,index.html
. Don’t add a/
before the object name. If you don’t want to specify a default root object when you create a distribution, include an emptyDefaultRootObject
element. To delete the default root object from an existing distribution, update the distribution configuration and include an emptyDefaultRootObject
element. To replace the default root object, update the distribution configuration and specify the new object. For more information about the default root object, see Creating a Default Root Object in the Amazon CloudFront Developer Guide .http_version (
Optional
[str
]) – (Optional) Specify the maximum HTTP version(s) that you want viewers to use to communicate with CloudFront . The default value for new distributions ishttp1.1
. For viewers and CloudFront to use HTTP/2, viewers must support TLSv1.2 or later, and must support Server Name Indication (SNI). For viewers and CloudFront to use HTTP/3, viewers must support TLSv1.3 and Server Name Indication (SNI). CloudFront supports HTTP/3 connection migration to allow the viewer to switch networks without losing connection. For more information about connection migration, see Connection Migration at RFC 9000. For more information about supported TLSv1.3 ciphers, see Supported protocols and ciphers between viewers and CloudFront .ipv6_enabled (
Union
[bool
,IResolvable
,None
]) – If you want CloudFront to respond to IPv6 DNS requests with an IPv6 address for your distribution, specifytrue
. If you specifyfalse
, CloudFront responds to IPv6 DNS requests with the DNS response codeNOERROR
and with no IP addresses. This allows viewers to submit a second request, for an IPv4 address for your distribution. In general, you should enable IPv6 if you have users on IPv6 networks who want to access your content. However, if you’re using signed URLs or signed cookies to restrict access to your content, and if you’re using a custom policy that includes theIpAddress
parameter to restrict the IP addresses that can access your content, don’t enable IPv6. If you want to restrict access to some content by IP address and not restrict access to other content (or restrict access but not by IP address), you can create two distributions. For more information, see Creating a Signed URL Using a Custom Policy in the Amazon CloudFront Developer Guide . If you’re using an Amazon Route 53 AWS Integration alias resource record set to route traffic to your CloudFront distribution, you need to create a second alias resource record set when both of the following are true: - You enable IPv6 for the distribution - You’re using alternate domain names in the URLs for your objects For more information, see Routing Traffic to an Amazon CloudFront Web Distribution by Using Your Domain Name in the Amazon Route 53 AWS Integration Developer Guide . If you created a CNAME resource record set, either with Amazon Route 53 AWS Integration or with another DNS service, you don’t need to make any changes. A CNAME record will route traffic to your distribution regardless of the IP address format of the viewer request.logging (
Union
[IResolvable
,LoggingProperty
,Dict
[str
,Any
],None
]) – A complex type that controls whether access logs are written for the distribution. For more information about logging, see Access Logs in the Amazon CloudFront Developer Guide .origin_groups (
Union
[IResolvable
,OriginGroupsProperty
,Dict
[str
,Any
],None
]) – A complex type that contains information about origin groups for this distribution.origins (
Union
[IResolvable
,Sequence
[Union
[OriginProperty
,Dict
[str
,Any
],IResolvable
]],None
]) – A complex type that contains information about origins for this distribution.price_class (
Optional
[str
]) – The price class that corresponds with the maximum price that you want to pay for CloudFront service. If you specifyPriceClass_All
, CloudFront responds to requests for your objects from all CloudFront edge locations. If you specify a price class other thanPriceClass_All
, CloudFront serves your objects from the CloudFront edge location that has the lowest latency among the edge locations in your price class. Viewers who are in or near regions that are excluded from your specified price class may encounter slower performance. For more information about price classes, see Choosing the Price Class for a CloudFront Distribution in the Amazon CloudFront Developer Guide . For information about CloudFront pricing, including how price classes (such as Price Class 100) map to CloudFront regions, see Amazon CloudFront Pricing .restrictions (
Union
[IResolvable
,RestrictionsProperty
,Dict
[str
,Any
],None
]) – A complex type that identifies ways in which you want to restrict distribution of your content.s3_origin (
Union
[IResolvable
,LegacyS3OriginProperty
,Dict
[str
,Any
],None
]) –CfnDistribution.DistributionConfigProperty.S3Origin
.staging (
Union
[bool
,IResolvable
,None
]) – A Boolean that indicates whether this is a staging distribution. When this value istrue
, this is a staging distribution. When this value isfalse
, this is not a staging distribution.viewer_certificate (
Union
[ViewerCertificateProperty
,Dict
[str
,Any
],IResolvable
,None
]) – A complex type that determines the distribution’s SSL/TLS configuration for communicating with viewers.web_acl_id (
Optional
[str
]) – A unique identifier that specifies the AWS WAF web ACL, if any, to associate with this distribution. To specify a web ACL created using the latest version of AWS WAF , use the ACL ARN, for examplearn:aws:wafv2:us-east-1:123456789012:global/webacl/ExampleWebACL/473e64fd-f30b-4765-81a0-62ad96dd167a
. To specify a web ACL created using AWS WAF Classic, use the ACL ID, for example473e64fd-f30b-4765-81a0-62ad96dd167a
. AWS WAF is a web application firewall that lets you monitor the HTTP and HTTPS requests that are forwarded to CloudFront, and lets you control access to your content. Based on conditions that you specify, such as the IP addresses that requests originate from or the values of query strings, CloudFront responds to requests either with the requested content or with an HTTP 403 status code (Forbidden). You can also configure CloudFront to return a custom error page when a request is blocked. For more information about AWS WAF , see the AWS WAF Developer Guide .
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront distribution_config_property = cloudfront.CfnDistribution.DistributionConfigProperty( default_cache_behavior=cloudfront.CfnDistribution.DefaultCacheBehaviorProperty( target_origin_id="targetOriginId", viewer_protocol_policy="viewerProtocolPolicy", # the properties below are optional allowed_methods=["allowedMethods"], cached_methods=["cachedMethods"], cache_policy_id="cachePolicyId", compress=False, default_ttl=123, field_level_encryption_id="fieldLevelEncryptionId", forwarded_values=cloudfront.CfnDistribution.ForwardedValuesProperty( query_string=False, # the properties below are optional cookies=cloudfront.CfnDistribution.CookiesProperty( forward="forward", # the properties below are optional whitelisted_names=["whitelistedNames"] ), headers=["headers"], query_string_cache_keys=["queryStringCacheKeys"] ), function_associations=[cloudfront.CfnDistribution.FunctionAssociationProperty( event_type="eventType", function_arn="functionArn" )], lambda_function_associations=[cloudfront.CfnDistribution.LambdaFunctionAssociationProperty( event_type="eventType", include_body=False, lambda_function_arn="lambdaFunctionArn" )], max_ttl=123, min_ttl=123, origin_request_policy_id="originRequestPolicyId", realtime_log_config_arn="realtimeLogConfigArn", response_headers_policy_id="responseHeadersPolicyId", smooth_streaming=False, trusted_key_groups=["trustedKeyGroups"], trusted_signers=["trustedSigners"] ), enabled=False, # the properties below are optional aliases=["aliases"], cache_behaviors=[cloudfront.CfnDistribution.CacheBehaviorProperty( path_pattern="pathPattern", target_origin_id="targetOriginId", viewer_protocol_policy="viewerProtocolPolicy", # the properties below are optional allowed_methods=["allowedMethods"], cached_methods=["cachedMethods"], cache_policy_id="cachePolicyId", compress=False, default_ttl=123, field_level_encryption_id="fieldLevelEncryptionId", forwarded_values=cloudfront.CfnDistribution.ForwardedValuesProperty( query_string=False, # the properties below are optional cookies=cloudfront.CfnDistribution.CookiesProperty( forward="forward", # the properties below are optional whitelisted_names=["whitelistedNames"] ), headers=["headers"], query_string_cache_keys=["queryStringCacheKeys"] ), function_associations=[cloudfront.CfnDistribution.FunctionAssociationProperty( event_type="eventType", function_arn="functionArn" )], lambda_function_associations=[cloudfront.CfnDistribution.LambdaFunctionAssociationProperty( event_type="eventType", include_body=False, lambda_function_arn="lambdaFunctionArn" )], max_ttl=123, min_ttl=123, origin_request_policy_id="originRequestPolicyId", realtime_log_config_arn="realtimeLogConfigArn", response_headers_policy_id="responseHeadersPolicyId", smooth_streaming=False, trusted_key_groups=["trustedKeyGroups"], trusted_signers=["trustedSigners"] )], cnam_es=["cnamEs"], comment="comment", continuous_deployment_policy_id="continuousDeploymentPolicyId", custom_error_responses=[cloudfront.CfnDistribution.CustomErrorResponseProperty( error_code=123, # the properties below are optional error_caching_min_ttl=123, response_code=123, response_page_path="responsePagePath" )], custom_origin=cloudfront.CfnDistribution.LegacyCustomOriginProperty( dns_name="dnsName", origin_protocol_policy="originProtocolPolicy", origin_ssl_protocols=["originSslProtocols"], # the properties below are optional http_port=123, https_port=123 ), default_root_object="defaultRootObject", http_version="httpVersion", ipv6_enabled=False, logging=cloudfront.CfnDistribution.LoggingProperty( bucket="bucket", # the properties below are optional include_cookies=False, prefix="prefix" ), origin_groups=cloudfront.CfnDistribution.OriginGroupsProperty( quantity=123, # the properties below are optional items=[cloudfront.CfnDistribution.OriginGroupProperty( failover_criteria=cloudfront.CfnDistribution.OriginGroupFailoverCriteriaProperty( status_codes=cloudfront.CfnDistribution.StatusCodesProperty( items=[123], quantity=123 ) ), id="id", members=cloudfront.CfnDistribution.OriginGroupMembersProperty( items=[cloudfront.CfnDistribution.OriginGroupMemberProperty( origin_id="originId" )], quantity=123 ) )] ), origins=[cloudfront.CfnDistribution.OriginProperty( domain_name="domainName", id="id", # the properties below are optional connection_attempts=123, connection_timeout=123, custom_origin_config=cloudfront.CfnDistribution.CustomOriginConfigProperty( origin_protocol_policy="originProtocolPolicy", # the properties below are optional http_port=123, https_port=123, origin_keepalive_timeout=123, origin_read_timeout=123, origin_ssl_protocols=["originSslProtocols"] ), origin_access_control_id="originAccessControlId", origin_custom_headers=[cloudfront.CfnDistribution.OriginCustomHeaderProperty( header_name="headerName", header_value="headerValue" )], origin_path="originPath", origin_shield=cloudfront.CfnDistribution.OriginShieldProperty( enabled=False, origin_shield_region="originShieldRegion" ), s3_origin_config=cloudfront.CfnDistribution.S3OriginConfigProperty( origin_access_identity="originAccessIdentity" ) )], price_class="priceClass", restrictions=cloudfront.CfnDistribution.RestrictionsProperty( geo_restriction=cloudfront.CfnDistribution.GeoRestrictionProperty( restriction_type="restrictionType", # the properties below are optional locations=["locations"] ) ), s3_origin=cloudfront.CfnDistribution.LegacyS3OriginProperty( dns_name="dnsName", # the properties below are optional origin_access_identity="originAccessIdentity" ), staging=False, viewer_certificate=cloudfront.CfnDistribution.ViewerCertificateProperty( acm_certificate_arn="acmCertificateArn", cloud_front_default_certificate=False, iam_certificate_id="iamCertificateId", minimum_protocol_version="minimumProtocolVersion", ssl_support_method="sslSupportMethod" ), web_acl_id="webAclId" )
Attributes
- aliases
A complex type that contains information about CNAMEs (alternate domain names), if any, for this distribution.
- cache_behaviors
A complex type that contains zero or more
CacheBehavior
elements.
- cnam_es
CfnDistribution.DistributionConfigProperty.CNAMEs
.
- comment
A comment to describe the distribution.
The comment cannot be longer than 128 characters.
- continuous_deployment_policy_id
The identifier of a continuous deployment policy.
For more information, see
CreateContinuousDeploymentPolicy
.
- custom_error_responses
.
Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer.
How long CloudFront caches HTTP status codes in the 4xx and 5xx range.
For more information about custom error pages, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
- Link:
- Type:
A complex type that controls the following
- custom_origin
CfnDistribution.DistributionConfigProperty.CustomOrigin
.
- default_cache_behavior
A complex type that describes the default cache behavior if you don’t specify a
CacheBehavior
element or if files don’t match any of the values ofPathPattern
inCacheBehavior
elements.You must create exactly one default cache behavior.
- default_root_object
The object that you want CloudFront to request from your origin (for example,
index.html
) when a viewer requests the root URL for your distribution (https://www.example.com
) instead of an object in your distribution (https://www.example.com/product-description.html
). Specifying a default root object avoids exposing the contents of your distribution.Specify only the object name, for example,
index.html
. Don’t add a/
before the object name.If you don’t want to specify a default root object when you create a distribution, include an empty
DefaultRootObject
element.To delete the default root object from an existing distribution, update the distribution configuration and include an empty
DefaultRootObject
element.To replace the default root object, update the distribution configuration and specify the new object.
For more information about the default root object, see Creating a Default Root Object in the Amazon CloudFront Developer Guide .
- enabled
From this field, you can enable or disable the selected distribution.
- http_version
(Optional) Specify the maximum HTTP version(s) that you want viewers to use to communicate with CloudFront .
The default value for new distributions is
http1.1
.For viewers and CloudFront to use HTTP/2, viewers must support TLSv1.2 or later, and must support Server Name Indication (SNI).
For viewers and CloudFront to use HTTP/3, viewers must support TLSv1.3 and Server Name Indication (SNI). CloudFront supports HTTP/3 connection migration to allow the viewer to switch networks without losing connection. For more information about connection migration, see Connection Migration at RFC 9000. For more information about supported TLSv1.3 ciphers, see Supported protocols and ciphers between viewers and CloudFront .
- ipv6_enabled
If you want CloudFront to respond to IPv6 DNS requests with an IPv6 address for your distribution, specify
true
.If you specify
false
, CloudFront responds to IPv6 DNS requests with the DNS response codeNOERROR
and with no IP addresses. This allows viewers to submit a second request, for an IPv4 address for your distribution.In general, you should enable IPv6 if you have users on IPv6 networks who want to access your content. However, if you’re using signed URLs or signed cookies to restrict access to your content, and if you’re using a custom policy that includes the
IpAddress
parameter to restrict the IP addresses that can access your content, don’t enable IPv6. If you want to restrict access to some content by IP address and not restrict access to other content (or restrict access but not by IP address), you can create two distributions. For more information, see Creating a Signed URL Using a Custom Policy in the Amazon CloudFront Developer Guide .If you’re using an Amazon Route 53 AWS Integration alias resource record set to route traffic to your CloudFront distribution, you need to create a second alias resource record set when both of the following are true:
You enable IPv6 for the distribution
You’re using alternate domain names in the URLs for your objects
For more information, see Routing Traffic to an Amazon CloudFront Web Distribution by Using Your Domain Name in the Amazon Route 53 AWS Integration Developer Guide .
If you created a CNAME resource record set, either with Amazon Route 53 AWS Integration or with another DNS service, you don’t need to make any changes. A CNAME record will route traffic to your distribution regardless of the IP address format of the viewer request.
- logging
A complex type that controls whether access logs are written for the distribution.
For more information about logging, see Access Logs in the Amazon CloudFront Developer Guide .
- origin_groups
A complex type that contains information about origin groups for this distribution.
- origins
A complex type that contains information about origins for this distribution.
- price_class
The price class that corresponds with the maximum price that you want to pay for CloudFront service.
If you specify
PriceClass_All
, CloudFront responds to requests for your objects from all CloudFront edge locations.If you specify a price class other than
PriceClass_All
, CloudFront serves your objects from the CloudFront edge location that has the lowest latency among the edge locations in your price class. Viewers who are in or near regions that are excluded from your specified price class may encounter slower performance.For more information about price classes, see Choosing the Price Class for a CloudFront Distribution in the Amazon CloudFront Developer Guide . For information about CloudFront pricing, including how price classes (such as Price Class 100) map to CloudFront regions, see Amazon CloudFront Pricing .
- restrictions
A complex type that identifies ways in which you want to restrict distribution of your content.
- s3_origin
CfnDistribution.DistributionConfigProperty.S3Origin
.
- staging
A Boolean that indicates whether this is a staging distribution.
When this value is
true
, this is a staging distribution. When this value isfalse
, this is not a staging distribution.
- viewer_certificate
A complex type that determines the distribution’s SSL/TLS configuration for communicating with viewers.
- web_acl_id
A unique identifier that specifies the AWS WAF web ACL, if any, to associate with this distribution.
To specify a web ACL created using the latest version of AWS WAF , use the ACL ARN, for example
arn:aws:wafv2:us-east-1:123456789012:global/webacl/ExampleWebACL/473e64fd-f30b-4765-81a0-62ad96dd167a
. To specify a web ACL created using AWS WAF Classic, use the ACL ID, for example473e64fd-f30b-4765-81a0-62ad96dd167a
.AWS WAF is a web application firewall that lets you monitor the HTTP and HTTPS requests that are forwarded to CloudFront, and lets you control access to your content. Based on conditions that you specify, such as the IP addresses that requests originate from or the values of query strings, CloudFront responds to requests either with the requested content or with an HTTP 403 status code (Forbidden). You can also configure CloudFront to return a custom error page when a request is blocked. For more information about AWS WAF , see the AWS WAF Developer Guide .
ForwardedValuesProperty
- class CfnDistribution.ForwardedValuesProperty(*, query_string, cookies=None, headers=None, query_string_cache_keys=None)
Bases:
object
This field is deprecated.
We recommend that you use a cache policy or an origin request policy instead of this field.
If you want to include values in the cache key, use a cache policy. For more information, see Creating cache policies in the Amazon CloudFront Developer Guide .
If you want to send values to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies in the Amazon CloudFront Developer Guide .
A complex type that specifies how CloudFront handles query strings, cookies, and HTTP headers.
- Parameters:
query_string (
Union
[bool
,IResolvable
]) –This field is deprecated. We recommend that you use a cache policy or an origin request policy instead of this field. If you want to include query strings in the cache key, use a cache policy. For more information, see Creating cache policies in the Amazon CloudFront Developer Guide . If you want to send query strings to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies in the Amazon CloudFront Developer Guide . Indicates whether you want CloudFront to forward query strings to the origin that is associated with this cache behavior and cache based on the query string parameters. CloudFront behavior depends on the value of
QueryString
and on the values that you specify forQueryStringCacheKeys
, if any: If you specify true forQueryString
and you don’t specify any values forQueryStringCacheKeys
, CloudFront forwards all query string parameters to the origin and caches based on all query string parameters. Depending on how many query string parameters and values you have, this can adversely affect performance because CloudFront must forward more requests to the origin. If you specify true forQueryString
and you specify one or more values forQueryStringCacheKeys
, CloudFront forwards all query string parameters to the origin, but it only caches based on the query string parameters that you specify. If you specify false forQueryString
, CloudFront doesn’t forward any query string parameters to the origin, and doesn’t cache based on query string parameters. For more information, see Configuring CloudFront to Cache Based on Query String Parameters in the Amazon CloudFront Developer Guide .cookies (
Union
[IResolvable
,CookiesProperty
,Dict
[str
,Any
],None
]) –This field is deprecated. We recommend that you use a cache policy or an origin request policy instead of this field. If you want to include cookies in the cache key, use a cache policy. For more information, see Creating cache policies in the Amazon CloudFront Developer Guide . If you want to send cookies to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies in the Amazon CloudFront Developer Guide . A complex type that specifies whether you want CloudFront to forward cookies to the origin and, if so, which ones. For more information about forwarding cookies to the origin, see How CloudFront Forwards, Caches, and Logs Cookies in the Amazon CloudFront Developer Guide .
headers (
Optional
[Sequence
[str
]]) –This field is deprecated. We recommend that you use a cache policy or an origin request policy instead of this field. If you want to include headers in the cache key, use a cache policy. For more information, see Creating cache policies in the Amazon CloudFront Developer Guide . If you want to send headers to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies in the Amazon CloudFront Developer Guide . A complex type that specifies the
Headers
, if any, that you want CloudFront to forward to the origin for this cache behavior (whitelisted headers). For the headers that you specify, CloudFront also caches separate versions of a specified object that is based on the header values in viewer requests. For more information, see Caching Content Based on Request Headers in the Amazon CloudFront Developer Guide .query_string_cache_keys (
Optional
[Sequence
[str
]]) –This field is deprecated. We recommend that you use a cache policy or an origin request policy instead of this field. If you want to include query strings in the cache key, use a cache policy. For more information, see Creating cache policies in the Amazon CloudFront Developer Guide . If you want to send query strings to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies in the Amazon CloudFront Developer Guide . A complex type that contains information about the query string parameters that you want CloudFront to use for caching for this cache behavior.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront forwarded_values_property = cloudfront.CfnDistribution.ForwardedValuesProperty( query_string=False, # the properties below are optional cookies=cloudfront.CfnDistribution.CookiesProperty( forward="forward", # the properties below are optional whitelisted_names=["whitelistedNames"] ), headers=["headers"], query_string_cache_keys=["queryStringCacheKeys"] )
Attributes
- cookies
This field is deprecated.
We recommend that you use a cache policy or an origin request policy instead of this field.
If you want to include cookies in the cache key, use a cache policy. For more information, see Creating cache policies in the Amazon CloudFront Developer Guide .
If you want to send cookies to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies in the Amazon CloudFront Developer Guide .
A complex type that specifies whether you want CloudFront to forward cookies to the origin and, if so, which ones. For more information about forwarding cookies to the origin, see How CloudFront Forwards, Caches, and Logs Cookies in the Amazon CloudFront Developer Guide .
- headers
This field is deprecated.
We recommend that you use a cache policy or an origin request policy instead of this field.
If you want to include headers in the cache key, use a cache policy. For more information, see Creating cache policies in the Amazon CloudFront Developer Guide .
If you want to send headers to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies in the Amazon CloudFront Developer Guide .
A complex type that specifies the
Headers
, if any, that you want CloudFront to forward to the origin for this cache behavior (whitelisted headers). For the headers that you specify, CloudFront also caches separate versions of a specified object that is based on the header values in viewer requests.For more information, see Caching Content Based on Request Headers in the Amazon CloudFront Developer Guide .
- query_string
This field is deprecated.
We recommend that you use a cache policy or an origin request policy instead of this field.
If you want to include query strings in the cache key, use a cache policy. For more information, see Creating cache policies in the Amazon CloudFront Developer Guide .
If you want to send query strings to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies in the Amazon CloudFront Developer Guide .
Indicates whether you want CloudFront to forward query strings to the origin that is associated with this cache behavior and cache based on the query string parameters. CloudFront behavior depends on the value of
QueryString
and on the values that you specify forQueryStringCacheKeys
, if any:If you specify true for
QueryString
and you don’t specify any values forQueryStringCacheKeys
, CloudFront forwards all query string parameters to the origin and caches based on all query string parameters. Depending on how many query string parameters and values you have, this can adversely affect performance because CloudFront must forward more requests to the origin.If you specify true for
QueryString
and you specify one or more values forQueryStringCacheKeys
, CloudFront forwards all query string parameters to the origin, but it only caches based on the query string parameters that you specify.If you specify false for
QueryString
, CloudFront doesn’t forward any query string parameters to the origin, and doesn’t cache based on query string parameters.For more information, see Configuring CloudFront to Cache Based on Query String Parameters in the Amazon CloudFront Developer Guide .
- query_string_cache_keys
This field is deprecated.
We recommend that you use a cache policy or an origin request policy instead of this field.
If you want to include query strings in the cache key, use a cache policy. For more information, see Creating cache policies in the Amazon CloudFront Developer Guide .
If you want to send query strings to the origin but not include them in the cache key, use an origin request policy. For more information, see Creating origin request policies in the Amazon CloudFront Developer Guide .
A complex type that contains information about the query string parameters that you want CloudFront to use for caching for this cache behavior.
FunctionAssociationProperty
- class CfnDistribution.FunctionAssociationProperty(*, event_type=None, function_arn=None)
Bases:
object
A CloudFront function that is associated with a cache behavior in a CloudFront distribution.
- Parameters:
event_type (
Optional
[str
]) – The event type of the function, eitherviewer-request
orviewer-response
. You cannot use origin-facing event types (origin-request
andorigin-response
) with a CloudFront function.function_arn (
Optional
[str
]) – The Amazon Resource Name (ARN) of the function.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront function_association_property = cloudfront.CfnDistribution.FunctionAssociationProperty( event_type="eventType", function_arn="functionArn" )
Attributes
- event_type
The event type of the function, either
viewer-request
orviewer-response
.You cannot use origin-facing event types (
origin-request
andorigin-response
) with a CloudFront function.
- function_arn
The Amazon Resource Name (ARN) of the function.
GeoRestrictionProperty
- class CfnDistribution.GeoRestrictionProperty(*, restriction_type, locations=None)
Bases:
object
A complex type that controls the countries in which your content is distributed.
CloudFront determines the location of your users using
MaxMind
GeoIP databases. To disable geo restriction, remove the Restrictions property from your stack template.- Parameters:
restriction_type (
str
) – The method that you want to use to restrict distribution of your content by country:. -none
: No geo restriction is enabled, meaning access to content is not restricted by client geo location. -blacklist
: TheLocation
elements specify the countries in which you don’t want CloudFront to distribute your content. -whitelist
: TheLocation
elements specify the countries in which you want CloudFront to distribute your content.locations (
Optional
[Sequence
[str
]]) – A complex type that contains aLocation
element for each country in which you want CloudFront either to distribute your content (whitelist
) or not distribute your content (blacklist
). TheLocation
element is a two-letter, uppercase country code for a country that you want to include in yourblacklist
orwhitelist
. Include oneLocation
element for each country. CloudFront andMaxMind
both useISO 3166
country codes. For the current list of countries and the corresponding codes, seeISO 3166-1-alpha-2
code on the International Organization for Standardization website. You can also refer to the country list on the CloudFront console, which includes both country names and codes.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront geo_restriction_property = cloudfront.CfnDistribution.GeoRestrictionProperty( restriction_type="restrictionType", # the properties below are optional locations=["locations"] )
Attributes
- locations
A complex type that contains a
Location
element for each country in which you want CloudFront either to distribute your content (whitelist
) or not distribute your content (blacklist
).The
Location
element is a two-letter, uppercase country code for a country that you want to include in yourblacklist
orwhitelist
. Include oneLocation
element for each country.CloudFront and
MaxMind
both useISO 3166
country codes. For the current list of countries and the corresponding codes, seeISO 3166-1-alpha-2
code on the International Organization for Standardization website. You can also refer to the country list on the CloudFront console, which includes both country names and codes.
- restriction_type
.
none
: No geo restriction is enabled, meaning access to content is not restricted by client geo location.blacklist
: TheLocation
elements specify the countries in which you don’t want CloudFront to distribute your content.whitelist
: TheLocation
elements specify the countries in which you want CloudFront to distribute your content.
- Link:
- Type:
The method that you want to use to restrict distribution of your content by country
LambdaFunctionAssociationProperty
- class CfnDistribution.LambdaFunctionAssociationProperty(*, event_type=None, include_body=None, lambda_function_arn=None)
Bases:
object
A complex type that contains a Lambda@Edge function association.
- Parameters:
event_type (
Optional
[str
]) – Specifies the event type that triggers a Lambda@Edge function invocation. You can specify the following values:. -viewer-request
: The function executes when CloudFront receives a request from a viewer and before it checks to see whether the requested object is in the edge cache. -origin-request
: The function executes only when CloudFront sends a request to your origin. When the requested object is in the edge cache, the function doesn’t execute. -origin-response
: The function executes after CloudFront receives a response from the origin and before it caches the object in the response. When the requested object is in the edge cache, the function doesn’t execute. -viewer-response
: The function executes before CloudFront returns the requested object to the viewer. The function executes regardless of whether the object was already in the edge cache. If the origin returns an HTTP status code other than HTTP 200 (OK), the function doesn’t execute.include_body (
Union
[bool
,IResolvable
,None
]) – A flag that allows a Lambda@Edge function to have read access to the body content. For more information, see Accessing the Request Body by Choosing the Include Body Option in the Amazon CloudFront Developer Guide.lambda_function_arn (
Optional
[str
]) – The ARN of the Lambda@Edge function. You must specify the ARN of a function version; you can’t specify an alias or $LATEST.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront lambda_function_association_property = cloudfront.CfnDistribution.LambdaFunctionAssociationProperty( event_type="eventType", include_body=False, lambda_function_arn="lambdaFunctionArn" )
Attributes
- event_type
.
viewer-request
: The function executes when CloudFront receives a request from a viewer and before it checks to see whether the requested object is in the edge cache.origin-request
: The function executes only when CloudFront sends a request to your origin. When the requested object is in the edge cache, the function doesn’t execute.origin-response
: The function executes after CloudFront receives a response from the origin and before it caches the object in the response. When the requested object is in the edge cache, the function doesn’t execute.viewer-response
: The function executes before CloudFront returns the requested object to the viewer. The function executes regardless of whether the object was already in the edge cache.
If the origin returns an HTTP status code other than HTTP 200 (OK), the function doesn’t execute.
- Link:
- Type:
Specifies the event type that triggers a Lambda@Edge function invocation. You can specify the following values
- include_body
A flag that allows a Lambda@Edge function to have read access to the body content.
For more information, see Accessing the Request Body by Choosing the Include Body Option in the Amazon CloudFront Developer Guide.
- lambda_function_arn
The ARN of the Lambda@Edge function.
You must specify the ARN of a function version; you can’t specify an alias or $LATEST.
LegacyCustomOriginProperty
- class CfnDistribution.LegacyCustomOriginProperty(*, dns_name, origin_protocol_policy, origin_ssl_protocols, http_port=None, https_port=None)
Bases:
object
- Parameters:
dns_name (
str
) –CfnDistribution.LegacyCustomOriginProperty.DNSName
.origin_protocol_policy (
str
) –CfnDistribution.LegacyCustomOriginProperty.OriginProtocolPolicy
.origin_ssl_protocols (
Sequence
[str
]) –CfnDistribution.LegacyCustomOriginProperty.OriginSSLProtocols
.http_port (
Union
[int
,float
,None
]) –CfnDistribution.LegacyCustomOriginProperty.HTTPPort
.https_port (
Union
[int
,float
,None
]) –CfnDistribution.LegacyCustomOriginProperty.HTTPSPort
.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront legacy_custom_origin_property = cloudfront.CfnDistribution.LegacyCustomOriginProperty( dns_name="dnsName", origin_protocol_policy="originProtocolPolicy", origin_ssl_protocols=["originSslProtocols"], # the properties below are optional http_port=123, https_port=123 )
Attributes
- dns_name
CfnDistribution.LegacyCustomOriginProperty.DNSName
.
- http_port
CfnDistribution.LegacyCustomOriginProperty.HTTPPort
.
- https_port
CfnDistribution.LegacyCustomOriginProperty.HTTPSPort
.
- origin_protocol_policy
CfnDistribution.LegacyCustomOriginProperty.OriginProtocolPolicy
.
- origin_ssl_protocols
CfnDistribution.LegacyCustomOriginProperty.OriginSSLProtocols
.
LegacyS3OriginProperty
- class CfnDistribution.LegacyS3OriginProperty(*, dns_name, origin_access_identity=None)
Bases:
object
- Parameters:
dns_name (
str
) –CfnDistribution.LegacyS3OriginProperty.DNSName
.origin_access_identity (
Optional
[str
]) –CfnDistribution.LegacyS3OriginProperty.OriginAccessIdentity
.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront legacy_s3_origin_property = cloudfront.CfnDistribution.LegacyS3OriginProperty( dns_name="dnsName", # the properties below are optional origin_access_identity="originAccessIdentity" )
Attributes
- dns_name
CfnDistribution.LegacyS3OriginProperty.DNSName
.
- origin_access_identity
CfnDistribution.LegacyS3OriginProperty.OriginAccessIdentity
.
LoggingProperty
- class CfnDistribution.LoggingProperty(*, bucket, include_cookies=None, prefix=None)
Bases:
object
A complex type that controls whether access logs are written for the distribution.
- Parameters:
bucket (
str
) – The Amazon S3 bucket to store the access logs in, for example,myawslogbucket.s3.amazonaws.com
.include_cookies (
Union
[bool
,IResolvable
,None
]) – Specifies whether you want CloudFront to include cookies in access logs, specifytrue
forIncludeCookies
. If you choose to include cookies in logs, CloudFront logs all cookies regardless of how you configure the cache behaviors for this distribution. If you don’t want to include cookies when you create a distribution or if you want to disable include cookies for an existing distribution, specifyfalse
forIncludeCookies
.prefix (
Optional
[str
]) – An optional string that you want CloudFront to prefix to the access logfilenames
for this distribution, for example,myprefix/
. If you want to enable logging, but you don’t want to specify a prefix, you still must include an emptyPrefix
element in theLogging
element.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront logging_property = cloudfront.CfnDistribution.LoggingProperty( bucket="bucket", # the properties below are optional include_cookies=False, prefix="prefix" )
Attributes
- bucket
The Amazon S3 bucket to store the access logs in, for example,
myawslogbucket.s3.amazonaws.com
.
- include_cookies
Specifies whether you want CloudFront to include cookies in access logs, specify
true
forIncludeCookies
.If you choose to include cookies in logs, CloudFront logs all cookies regardless of how you configure the cache behaviors for this distribution. If you don’t want to include cookies when you create a distribution or if you want to disable include cookies for an existing distribution, specify
false
forIncludeCookies
.
- prefix
An optional string that you want CloudFront to prefix to the access log
filenames
for this distribution, for example,myprefix/
.If you want to enable logging, but you don’t want to specify a prefix, you still must include an empty
Prefix
element in theLogging
element.
OriginCustomHeaderProperty
- class CfnDistribution.OriginCustomHeaderProperty(*, header_name, header_value)
Bases:
object
A complex type that contains
HeaderName
andHeaderValue
elements, if any, for this distribution.- Parameters:
header_name (
str
) – The name of a header that you want CloudFront to send to your origin. For more information, see Adding Custom Headers to Origin Requests in the Amazon CloudFront Developer Guide .header_value (
str
) – The value for the header that you specified in theHeaderName
field.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront origin_custom_header_property = cloudfront.CfnDistribution.OriginCustomHeaderProperty( header_name="headerName", header_value="headerValue" )
Attributes
- header_name
The name of a header that you want CloudFront to send to your origin.
For more information, see Adding Custom Headers to Origin Requests in the Amazon CloudFront Developer Guide .
- header_value
The value for the header that you specified in the
HeaderName
field.
OriginGroupFailoverCriteriaProperty
- class CfnDistribution.OriginGroupFailoverCriteriaProperty(*, status_codes)
Bases:
object
A complex data type that includes information about the failover criteria for an origin group, including the status codes for which CloudFront will failover from the primary origin to the second origin.
- Parameters:
status_codes (
Union
[IResolvable
,StatusCodesProperty
,Dict
[str
,Any
]]) – The status codes that, when returned from the primary origin, will trigger CloudFront to failover to the second origin.- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront origin_group_failover_criteria_property = cloudfront.CfnDistribution.OriginGroupFailoverCriteriaProperty( status_codes=cloudfront.CfnDistribution.StatusCodesProperty( items=[123], quantity=123 ) )
Attributes
- status_codes
The status codes that, when returned from the primary origin, will trigger CloudFront to failover to the second origin.
OriginGroupMemberProperty
- class CfnDistribution.OriginGroupMemberProperty(*, origin_id)
Bases:
object
An origin in an origin group.
- Parameters:
origin_id (
str
) – The ID for an origin in an origin group.- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront origin_group_member_property = cloudfront.CfnDistribution.OriginGroupMemberProperty( origin_id="originId" )
Attributes
- origin_id
The ID for an origin in an origin group.
OriginGroupMembersProperty
- class CfnDistribution.OriginGroupMembersProperty(*, items, quantity)
Bases:
object
A complex data type for the origins included in an origin group.
- Parameters:
items (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,OriginGroupMemberProperty
,Dict
[str
,Any
]]]]) – Items (origins) in an origin group.quantity (
Union
[int
,float
]) – The number of origins in an origin group.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront origin_group_members_property = cloudfront.CfnDistribution.OriginGroupMembersProperty( items=[cloudfront.CfnDistribution.OriginGroupMemberProperty( origin_id="originId" )], quantity=123 )
Attributes
- items
Items (origins) in an origin group.
- quantity
The number of origins in an origin group.
OriginGroupProperty
- class CfnDistribution.OriginGroupProperty(*, failover_criteria, id, members)
Bases:
object
An origin group includes two origins (a primary origin and a second origin to failover to) and a failover criteria that you specify.
You create an origin group to support origin failover in CloudFront. When you create or update a distribution, you can specifiy the origin group instead of a single origin, and CloudFront will failover from the primary origin to the second origin under the failover conditions that you’ve chosen.
- Parameters:
failover_criteria (
Union
[IResolvable
,OriginGroupFailoverCriteriaProperty
,Dict
[str
,Any
]]) – A complex type that contains information about the failover criteria for an origin group.id (
str
) – The origin group’s ID.members (
Union
[IResolvable
,OriginGroupMembersProperty
,Dict
[str
,Any
]]) – A complex type that contains information about the origins in an origin group.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront origin_group_property = cloudfront.CfnDistribution.OriginGroupProperty( failover_criteria=cloudfront.CfnDistribution.OriginGroupFailoverCriteriaProperty( status_codes=cloudfront.CfnDistribution.StatusCodesProperty( items=[123], quantity=123 ) ), id="id", members=cloudfront.CfnDistribution.OriginGroupMembersProperty( items=[cloudfront.CfnDistribution.OriginGroupMemberProperty( origin_id="originId" )], quantity=123 ) )
Attributes
- failover_criteria
A complex type that contains information about the failover criteria for an origin group.
- id
The origin group’s ID.
- members
A complex type that contains information about the origins in an origin group.
OriginGroupsProperty
- class CfnDistribution.OriginGroupsProperty(*, quantity, items=None)
Bases:
object
A complex data type for the origin groups specified for a distribution.
- Parameters:
quantity (
Union
[int
,float
]) – The number of origin groups.items (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,OriginGroupProperty
,Dict
[str
,Any
]]],None
]) – The items (origin groups) in a distribution.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront origin_groups_property = cloudfront.CfnDistribution.OriginGroupsProperty( quantity=123, # the properties below are optional items=[cloudfront.CfnDistribution.OriginGroupProperty( failover_criteria=cloudfront.CfnDistribution.OriginGroupFailoverCriteriaProperty( status_codes=cloudfront.CfnDistribution.StatusCodesProperty( items=[123], quantity=123 ) ), id="id", members=cloudfront.CfnDistribution.OriginGroupMembersProperty( items=[cloudfront.CfnDistribution.OriginGroupMemberProperty( origin_id="originId" )], quantity=123 ) )] )
Attributes
- items
The items (origin groups) in a distribution.
- quantity
The number of origin groups.
OriginProperty
- class CfnDistribution.OriginProperty(*, domain_name, id, connection_attempts=None, connection_timeout=None, custom_origin_config=None, origin_access_control_id=None, origin_custom_headers=None, origin_path=None, origin_shield=None, s3_origin_config=None)
Bases:
object
An origin.
An origin is the location where content is stored, and from which CloudFront gets content to serve to viewers. To specify an origin:
Use
S3OriginConfig
to specify an Amazon S3 bucket that is not configured with static website hosting.Use
CustomOriginConfig
to specify all other kinds of origins, including:An Amazon S3 bucket that is configured with static website hosting
An Elastic Load Balancing load balancer
An AWS Elemental MediaPackage endpoint
An AWS Elemental MediaStore container
Any other HTTP server, running on an Amazon EC2 instance or any other kind of host
For the current maximum number of origins that you can specify per distribution, see General Quotas on Web Distributions in the Amazon CloudFront Developer Guide (quotas were formerly referred to as limits).
- Parameters:
domain_name (
str
) – The domain name for the origin. For more information, see Origin Domain Name in the Amazon CloudFront Developer Guide .id (
str
) – A unique identifier for the origin. This value must be unique within the distribution. Use this value to specify theTargetOriginId
in aCacheBehavior
orDefaultCacheBehavior
.connection_attempts (
Union
[int
,float
,None
]) –The number of times that CloudFront attempts to connect to the origin. The minimum number is 1, the maximum is 3, and the default (if you don’t specify otherwise) is 3. For a custom origin (including an Amazon S3 bucket that’s configured with static website hosting), this value also specifies the number of times that CloudFront attempts to get a response from the origin, in the case of an Origin Response Timeout . For more information, see Origin Connection Attempts in the Amazon CloudFront Developer Guide .
connection_timeout (
Union
[int
,float
,None
]) – The number of seconds that CloudFront waits when trying to establish a connection to the origin. The minimum timeout is 1 second, the maximum is 10 seconds, and the default (if you don’t specify otherwise) is 10 seconds. For more information, see Origin Connection Timeout in the Amazon CloudFront Developer Guide .custom_origin_config (
Union
[CustomOriginConfigProperty
,Dict
[str
,Any
],IResolvable
,None
]) – Use this type to specify an origin that is not an Amazon S3 bucket, with one exception. If the Amazon S3 bucket is configured with static website hosting, use this type. If the Amazon S3 bucket is not configured with static website hosting, use theS3OriginConfig
type instead.origin_access_control_id (
Optional
[str
]) – The unique identifier of an origin access control for this origin. For more information, see Restricting access to an Amazon S3 origin in the Amazon CloudFront Developer Guide .origin_custom_headers (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,OriginCustomHeaderProperty
,Dict
[str
,Any
]]],None
]) –A list of HTTP header names and values that CloudFront adds to the requests that it sends to the origin. For more information, see Adding Custom Headers to Origin Requests in the Amazon CloudFront Developer Guide .
origin_path (
Optional
[str
]) – An optional path that CloudFront appends to the origin domain name when CloudFront requests content from the origin. For more information, see Origin Path in the Amazon CloudFront Developer Guide .origin_shield (
Union
[IResolvable
,OriginShieldProperty
,Dict
[str
,Any
],None
]) – CloudFront Origin Shield. Using Origin Shield can help reduce the load on your origin. For more information, see Using Origin Shield in the Amazon CloudFront Developer Guide .s3_origin_config (
Union
[S3OriginConfigProperty
,Dict
[str
,Any
],IResolvable
,None
]) – Use this type to specify an origin that is an Amazon S3 bucket that is not configured with static website hosting. To specify any other type of origin, including an Amazon S3 bucket that is configured with static website hosting, use theCustomOriginConfig
type instead.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront origin_property = cloudfront.CfnDistribution.OriginProperty( domain_name="domainName", id="id", # the properties below are optional connection_attempts=123, connection_timeout=123, custom_origin_config=cloudfront.CfnDistribution.CustomOriginConfigProperty( origin_protocol_policy="originProtocolPolicy", # the properties below are optional http_port=123, https_port=123, origin_keepalive_timeout=123, origin_read_timeout=123, origin_ssl_protocols=["originSslProtocols"] ), origin_access_control_id="originAccessControlId", origin_custom_headers=[cloudfront.CfnDistribution.OriginCustomHeaderProperty( header_name="headerName", header_value="headerValue" )], origin_path="originPath", origin_shield=cloudfront.CfnDistribution.OriginShieldProperty( enabled=False, origin_shield_region="originShieldRegion" ), s3_origin_config=cloudfront.CfnDistribution.S3OriginConfigProperty( origin_access_identity="originAccessIdentity" ) )
Attributes
- connection_attempts
The number of times that CloudFront attempts to connect to the origin.
The minimum number is 1, the maximum is 3, and the default (if you don’t specify otherwise) is 3.
For a custom origin (including an Amazon S3 bucket that’s configured with static website hosting), this value also specifies the number of times that CloudFront attempts to get a response from the origin, in the case of an Origin Response Timeout .
For more information, see Origin Connection Attempts in the Amazon CloudFront Developer Guide .
- connection_timeout
The number of seconds that CloudFront waits when trying to establish a connection to the origin.
The minimum timeout is 1 second, the maximum is 10 seconds, and the default (if you don’t specify otherwise) is 10 seconds.
For more information, see Origin Connection Timeout in the Amazon CloudFront Developer Guide .
- custom_origin_config
Use this type to specify an origin that is not an Amazon S3 bucket, with one exception.
If the Amazon S3 bucket is configured with static website hosting, use this type. If the Amazon S3 bucket is not configured with static website hosting, use the
S3OriginConfig
type instead.
- domain_name
The domain name for the origin.
For more information, see Origin Domain Name in the Amazon CloudFront Developer Guide .
- id
A unique identifier for the origin. This value must be unique within the distribution.
Use this value to specify the
TargetOriginId
in aCacheBehavior
orDefaultCacheBehavior
.
- origin_access_control_id
The unique identifier of an origin access control for this origin.
For more information, see Restricting access to an Amazon S3 origin in the Amazon CloudFront Developer Guide .
- origin_custom_headers
A list of HTTP header names and values that CloudFront adds to the requests that it sends to the origin.
For more information, see Adding Custom Headers to Origin Requests in the Amazon CloudFront Developer Guide .
- origin_path
An optional path that CloudFront appends to the origin domain name when CloudFront requests content from the origin.
For more information, see Origin Path in the Amazon CloudFront Developer Guide .
- origin_shield
CloudFront Origin Shield. Using Origin Shield can help reduce the load on your origin.
For more information, see Using Origin Shield in the Amazon CloudFront Developer Guide .
- s3_origin_config
Use this type to specify an origin that is an Amazon S3 bucket that is not configured with static website hosting.
To specify any other type of origin, including an Amazon S3 bucket that is configured with static website hosting, use the
CustomOriginConfig
type instead.
OriginShieldProperty
- class CfnDistribution.OriginShieldProperty(*, enabled=None, origin_shield_region=None)
Bases:
object
CloudFront Origin Shield.
Using Origin Shield can help reduce the load on your origin. For more information, see Using Origin Shield in the Amazon CloudFront Developer Guide .
- Parameters:
enabled (
Union
[bool
,IResolvable
,None
]) – A flag that specifies whether Origin Shield is enabled. When it’s enabled, CloudFront routes all requests through Origin Shield, which can help protect your origin. When it’s disabled, CloudFront might send requests directly to your origin from multiple edge locations or regional edge caches.origin_shield_region (
Optional
[str
]) – The AWS Region for Origin Shield. Specify the AWS Region that has the lowest latency to your origin. To specify a region, use the region code, not the region name. For example, specify the US East (Ohio) region asus-east-2
. When you enable CloudFront Origin Shield, you must specify the AWS Region for Origin Shield. For the list of AWS Regions that you can specify, and for help choosing the best Region for your origin, see Choosing the AWS Region for Origin Shield in the Amazon CloudFront Developer Guide .
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront origin_shield_property = cloudfront.CfnDistribution.OriginShieldProperty( enabled=False, origin_shield_region="originShieldRegion" )
Attributes
- enabled
A flag that specifies whether Origin Shield is enabled.
When it’s enabled, CloudFront routes all requests through Origin Shield, which can help protect your origin. When it’s disabled, CloudFront might send requests directly to your origin from multiple edge locations or regional edge caches.
- origin_shield_region
The AWS Region for Origin Shield.
Specify the AWS Region that has the lowest latency to your origin. To specify a region, use the region code, not the region name. For example, specify the US East (Ohio) region as
us-east-2
.When you enable CloudFront Origin Shield, you must specify the AWS Region for Origin Shield. For the list of AWS Regions that you can specify, and for help choosing the best Region for your origin, see Choosing the AWS Region for Origin Shield in the Amazon CloudFront Developer Guide .
RestrictionsProperty
- class CfnDistribution.RestrictionsProperty(*, geo_restriction)
Bases:
object
A complex type that identifies ways in which you want to restrict distribution of your content.
- Parameters:
geo_restriction (
Union
[IResolvable
,GeoRestrictionProperty
,Dict
[str
,Any
]]) –A complex type that controls the countries in which your content is distributed. CloudFront determines the location of your users using
MaxMind
GeoIP databases. To disable geo restriction, remove the Restrictions property from your stack template.- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront restrictions_property = cloudfront.CfnDistribution.RestrictionsProperty( geo_restriction=cloudfront.CfnDistribution.GeoRestrictionProperty( restriction_type="restrictionType", # the properties below are optional locations=["locations"] ) )
Attributes
- geo_restriction
A complex type that controls the countries in which your content is distributed.
CloudFront determines the location of your users using
MaxMind
GeoIP databases. To disable geo restriction, remove the Restrictions property from your stack template.
S3OriginConfigProperty
- class CfnDistribution.S3OriginConfigProperty(*, origin_access_identity=None)
Bases:
object
A complex type that contains information about the Amazon S3 origin.
If the origin is a custom origin or an S3 bucket that is configured as a website endpoint, use the
CustomOriginConfig
element instead.- Parameters:
origin_access_identity (
Optional
[str
]) – The CloudFront origin access identity to associate with the origin. Use an origin access identity to configure the origin so that viewers can only access objects in an Amazon S3 bucket through CloudFront. The format of the value is: origin-access-identity/cloudfront/ ID-of-origin-access-identity where*ID-of-origin-access-identity*
is the value that CloudFront returned in theID
element when you created the origin access identity. If you want viewers to be able to access objects using either the CloudFront URL or the Amazon S3 URL, specify an emptyOriginAccessIdentity
element. To delete the origin access identity from an existing distribution, update the distribution configuration and include an emptyOriginAccessIdentity
element. To replace the origin access identity, update the distribution configuration and specify the new origin access identity. For more information about the origin access identity, see Serving Private Content through CloudFront in the Amazon CloudFront Developer Guide .- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront s3_origin_config_property = cloudfront.CfnDistribution.S3OriginConfigProperty( origin_access_identity="originAccessIdentity" )
Attributes
- origin_access_identity
The CloudFront origin access identity to associate with the origin.
Use an origin access identity to configure the origin so that viewers can only access objects in an Amazon S3 bucket through CloudFront. The format of the value is:
origin-access-identity/cloudfront/ ID-of-origin-access-identity
where
*ID-of-origin-access-identity*
is the value that CloudFront returned in theID
element when you created the origin access identity.If you want viewers to be able to access objects using either the CloudFront URL or the Amazon S3 URL, specify an empty
OriginAccessIdentity
element.To delete the origin access identity from an existing distribution, update the distribution configuration and include an empty
OriginAccessIdentity
element.To replace the origin access identity, update the distribution configuration and specify the new origin access identity.
For more information about the origin access identity, see Serving Private Content through CloudFront in the Amazon CloudFront Developer Guide .
StatusCodesProperty
- class CfnDistribution.StatusCodesProperty(*, items, quantity)
Bases:
object
A complex data type for the status codes that you specify that, when returned by a primary origin, trigger CloudFront to failover to a second origin.
- Parameters:
items (
Union
[Sequence
[Union
[int
,float
]],IResolvable
]) – The items (status codes) for an origin group.quantity (
Union
[int
,float
]) – The number of status codes.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront status_codes_property = cloudfront.CfnDistribution.StatusCodesProperty( items=[123], quantity=123 )
Attributes
- items
The items (status codes) for an origin group.
- quantity
The number of status codes.
ViewerCertificateProperty
- class CfnDistribution.ViewerCertificateProperty(*, acm_certificate_arn=None, cloud_front_default_certificate=None, iam_certificate_id=None, minimum_protocol_version=None, ssl_support_method=None)
Bases:
object
A complex type that determines the distribution’s SSL/TLS configuration for communicating with viewers.
If the distribution doesn’t use
Aliases
(also known as alternate domain names or CNAMEs)—that is, if the distribution uses the CloudFront domain name such asd111111abcdef8.cloudfront.net
—setCloudFrontDefaultCertificate
totrue
and leave all other fields empty.If the distribution uses
Aliases
(alternate domain names or CNAMEs), use the fields in this type to specify the following settings:Which viewers the distribution accepts HTTPS connections from: only viewers that support server name indication (SNI) (recommended), or all viewers including those that don’t support SNI.
To accept HTTPS connections from only viewers that support SNI, set
SSLSupportMethod
tosni-only
. This is recommended. Most browsers and clients support SNI. (In CloudFormation, the field name isSslSupportMethod
. Note the different capitalization.)To accept HTTPS connections from all viewers, including those that don’t support SNI, set
SSLSupportMethod
tovip
. This is not recommended, and results in additional monthly charges from CloudFront. (In CloudFormation, the field name isSslSupportMethod
. Note the different capitalization.)The minimum SSL/TLS protocol version that the distribution can use to communicate with viewers. To specify a minimum version, choose a value for
MinimumProtocolVersion
. For more information, see Security Policy in the Amazon CloudFront Developer Guide .The location of the SSL/TLS certificate, AWS Certificate Manager (ACM) (recommended) or AWS Identity and Access Management (IAM) . You specify the location by setting a value in one of the following fields (not both):
ACMCertificateArn
(In CloudFormation, this field name isAcmCertificateArn
. Note the different capitalization.)IAMCertificateId
(In CloudFormation, this field name isIamCertificateId
. Note the different capitalization.)
All distributions support HTTPS connections from viewers. To require viewers to use HTTPS only, or to redirect them from HTTP to HTTPS, use
ViewerProtocolPolicy
in theCacheBehavior
orDefaultCacheBehavior
. To specify how CloudFront should use SSL/TLS to communicate with your custom origin, useCustomOriginConfig
.For more information, see Using HTTPS with CloudFront and Using Alternate Domain Names and HTTPS in the Amazon CloudFront Developer Guide .
- Parameters:
acm_certificate_arn (
Optional
[str
]) –In CloudFormation, this field name is
AcmCertificateArn
. Note the different capitalization. If the distribution usesAliases
(alternate domain names or CNAMEs) and the SSL/TLS certificate is stored in AWS Certificate Manager (ACM) , provide the Amazon Resource Name (ARN) of the ACM certificate. CloudFront only supports ACM certificates in the US East (N. Virginia) Region (us-east-1
). If you specify an ACM certificate ARN, you must also specify values forMinimumProtocolVersion
andSSLSupportMethod
. (In CloudFormation, the field name isSslSupportMethod
. Note the different capitalization.)cloud_front_default_certificate (
Union
[bool
,IResolvable
,None
]) – If the distribution uses the CloudFront domain name such asd111111abcdef8.cloudfront.net
, set this field totrue
. If the distribution usesAliases
(alternate domain names or CNAMEs), set this field tofalse
and specify values for the following fields: -ACMCertificateArn
orIAMCertificateId
(specify a value for one, not both) In CloudFormation, these field names areAcmCertificateArn
andIamCertificateId
. Note the different capitalization. -MinimumProtocolVersion
-SSLSupportMethod
(In CloudFormation, this field name isSslSupportMethod
. Note the different capitalization.)iam_certificate_id (
Optional
[str
]) –In CloudFormation, this field name is
IamCertificateId
. Note the different capitalization. If the distribution usesAliases
(alternate domain names or CNAMEs) and the SSL/TLS certificate is stored in AWS Identity and Access Management (IAM) , provide the ID of the IAM certificate. If you specify an IAM certificate ID, you must also specify values forMinimumProtocolVersion
andSSLSupportMethod
. (In CloudFormation, the field name isSslSupportMethod
. Note the different capitalization.)minimum_protocol_version (
Optional
[str
]) –If the distribution uses
Aliases
(alternate domain names or CNAMEs), specify the security policy that you want CloudFront to use for HTTPS connections with viewers. The security policy determines two settings: - The minimum SSL/TLS protocol that CloudFront can use to communicate with viewers. - The ciphers that CloudFront can use to encrypt the content that it returns to viewers. For more information, see Security Policy and Supported Protocols and Ciphers Between Viewers and CloudFront in the Amazon CloudFront Developer Guide . .. epigraph:: On the CloudFront console, this setting is called Security Policy . When you’re using SNI only (you setSSLSupportMethod
tosni-only
), you must specifyTLSv1
or higher. (In CloudFormation, the field name isSslSupportMethod
. Note the different capitalization.) If the distribution uses the CloudFront domain name such asd111111abcdef8.cloudfront.net
(you setCloudFrontDefaultCertificate
totrue
), CloudFront automatically sets the security policy toTLSv1
regardless of the value that you set here.ssl_support_method (
Optional
[str
]) –In CloudFormation, this field name is
SslSupportMethod
. Note the different capitalization. If the distribution usesAliases
(alternate domain names or CNAMEs), specify which viewers the distribution accepts HTTPS connections from. -sni-only
– The distribution accepts HTTPS connections from only viewers that support server name indication (SNI) . This is recommended. Most browsers and clients support SNI. -vip
– The distribution accepts HTTPS connections from all viewers including those that don’t support SNI. This is not recommended, and results in additional monthly charges from CloudFront. -static-ip
- Do not specify this value unless your distribution has been enabled for this feature by the CloudFront team. If you have a use case that requires static IP addresses for a distribution, contact CloudFront through the AWS Support Center . If the distribution uses the CloudFront domain name such asd111111abcdef8.cloudfront.net
, don’t set a value for this field.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront viewer_certificate_property = cloudfront.CfnDistribution.ViewerCertificateProperty( acm_certificate_arn="acmCertificateArn", cloud_front_default_certificate=False, iam_certificate_id="iamCertificateId", minimum_protocol_version="minimumProtocolVersion", ssl_support_method="sslSupportMethod" )
Attributes
- acm_certificate_arn
In CloudFormation, this field name is
AcmCertificateArn
. Note the different capitalization.If the distribution uses
Aliases
(alternate domain names or CNAMEs) and the SSL/TLS certificate is stored in AWS Certificate Manager (ACM) , provide the Amazon Resource Name (ARN) of the ACM certificate. CloudFront only supports ACM certificates in the US East (N. Virginia) Region (us-east-1
).If you specify an ACM certificate ARN, you must also specify values for
MinimumProtocolVersion
andSSLSupportMethod
. (In CloudFormation, the field name isSslSupportMethod
. Note the different capitalization.)
- cloud_front_default_certificate
If the distribution uses the CloudFront domain name such as
d111111abcdef8.cloudfront.net
, set this field totrue
.If the distribution uses
Aliases
(alternate domain names or CNAMEs), set this field tofalse
and specify values for the following fields:ACMCertificateArn
orIAMCertificateId
(specify a value for one, not both)
In CloudFormation, these field names are
AcmCertificateArn
andIamCertificateId
. Note the different capitalization.MinimumProtocolVersion
SSLSupportMethod
(In CloudFormation, this field name isSslSupportMethod
. Note the different capitalization.)
- iam_certificate_id
In CloudFormation, this field name is
IamCertificateId
. Note the different capitalization.If the distribution uses
Aliases
(alternate domain names or CNAMEs) and the SSL/TLS certificate is stored in AWS Identity and Access Management (IAM) , provide the ID of the IAM certificate.If you specify an IAM certificate ID, you must also specify values for
MinimumProtocolVersion
andSSLSupportMethod
. (In CloudFormation, the field name isSslSupportMethod
. Note the different capitalization.)
- minimum_protocol_version
If the distribution uses
Aliases
(alternate domain names or CNAMEs), specify the security policy that you want CloudFront to use for HTTPS connections with viewers.The security policy determines two settings:
The minimum SSL/TLS protocol that CloudFront can use to communicate with viewers.
The ciphers that CloudFront can use to encrypt the content that it returns to viewers.
For more information, see Security Policy and Supported Protocols and Ciphers Between Viewers and CloudFront in the Amazon CloudFront Developer Guide . .. epigraph:
On the CloudFront console, this setting is called *Security Policy* .
When you’re using SNI only (you set
SSLSupportMethod
tosni-only
), you must specifyTLSv1
or higher. (In CloudFormation, the field name isSslSupportMethod
. Note the different capitalization.)If the distribution uses the CloudFront domain name such as
d111111abcdef8.cloudfront.net
(you setCloudFrontDefaultCertificate
totrue
), CloudFront automatically sets the security policy toTLSv1
regardless of the value that you set here.
- ssl_support_method
In CloudFormation, this field name is
SslSupportMethod
. Note the different capitalization.If the distribution uses
Aliases
(alternate domain names or CNAMEs), specify which viewers the distribution accepts HTTPS connections from.sni-only
– The distribution accepts HTTPS connections from only viewers that support server name indication (SNI) . This is recommended. Most browsers and clients support SNI.vip
– The distribution accepts HTTPS connections from all viewers including those that don’t support SNI. This is not recommended, and results in additional monthly charges from CloudFront.static-ip
- Do not specify this value unless your distribution has been enabled for this feature by the CloudFront team. If you have a use case that requires static IP addresses for a distribution, contact CloudFront through the AWS Support Center .
If the distribution uses the CloudFront domain name such as
d111111abcdef8.cloudfront.net
, don’t set a value for this field.