Skip to main content

distributions

Creates, updates, deletes, gets or lists a distributions resource.

Overview

Namedistributions
TypeResource
Idaws.cloudfront.distributions

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
arnstringThe distribution's Amazon Resource Name (ARN).
active_trusted_key_groupsstringThis field contains a list of key groups and the public keys in each key group that CloudFront can use to verify the signatures of signed URLs or signed cookies.
active_trusted_signersstringWe recommend using TrustedKeyGroups instead of TrustedSigners. This field contains a list of Amazon Web Services account IDs and the active CloudFront key pairs in each account that CloudFront can use to verify the signatures of signed URLs or signed cookies.
alias_icp_recordalsstringAmazon Web Services services in China customers must file for an Internet Content Provider (ICP) recordal if they want to serve content publicly on an alternate domain name, also known as a CNAME, that they've added to CloudFront. AliasICPRecordal provides the ICP recordal status for CNAMEs associated with distributions. For more information about ICP recordals, see Signup, Accounts, and Credentials in Getting Started with Amazon Web Services services in China.
distribution_configstringThe distribution's configuration.
domain_namestringThe distribution's CloudFront domain name. For example: d111111abcdef8.cloudfront.net.
idstringThe distribution's identifier. For example: E1U5RQF7T870K0.
in_progress_invalidation_batchesintegerThe number of invalidation batches currently in progress.
last_modified_timestringThe date and time when the distribution was last modified.
statusstringThe distribution's status. When the status is Deployed, the distribution's information is fully propagated to all CloudFront edge locations.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_distributionselectid, regionGet the information about a distribution.
list_distributionsselectregionMarker, MaxItemsList CloudFront distributions.
create_distributioninsertregion, DistributionConfigCreates a CloudFront distribution.
associate_distribution_web_aclupdateid, region, WebACLArnIf-MatchAssociates the WAF web ACL with a distribution.
update_distributionupdateid, region, DistributionConfigIf-MatchUpdates the configuration for a CloudFront distribution. The update process includes getting the current distribution configuration, updating it to make your changes, and then submitting an UpdateDistribution request to make the updates. To update a web distribution using the CloudFront API Use GetDistributionConfig to get the current configuration, including the version identifier (ETag). Update the distribution configuration that was returned in the response. Note the following important requirements and restrictions: You must copy the ETag field value from the response. (You'll use it for the IfMatch parameter in your request.) Then, remove the ETag field from the distribution configuration. You can't change the value of CallerReference. Submit an UpdateDistribution request, providing the updated distribution configuration. The new configuration replaces the existing configuration. The values that you specify in an UpdateDistribution request are not merged into your existing configuration. Make sure to include all fields: the ones that you modified and also the ones that you didn't.
disassociate_distribution_web_aclupdateid, regionIf-MatchDisassociates a distribution from the WAF web ACL.
delete_distributiondeleteid, regionIf-MatchDelete a distribution. Before you can delete a distribution, you must disable it, which requires permission to update the distribution. Once deleted, a distribution cannot be recovered.
update_distribution_with_staging_configexecid, regionStagingDistributionId, If-MatchCopies the staging distribution's configuration to its corresponding primary distribution. The primary distribution retains its Aliases (also known as alternate domain names or CNAMEs) and ContinuousDeploymentPolicyId value, but otherwise its configuration is overwritten to match the staging distribution. You can use this operation in a continuous deployment workflow after you have tested configuration changes on the staging distribution. After using a continuous deployment policy to move a portion of your domain name's traffic to the staging distribution and verifying that it works as intended, you can use this operation to copy the staging distribution's configuration to the primary distribution. This action will disable the continuous deployment policy and move your domain's traffic back to the primary distribution. This API operation requires the following IAM permissions: GetDistribution UpdateDistribution

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
idstringThe identifier of the primary distribution to which you are copying a staging distribution's configuration.
regionstringAWS region (default: us-east-1)
If-MatchstringThe current versions (ETag values) of both primary and staging distributions. Provide these in the following format: <primary ETag>, <staging ETag>
MarkerstringUse this when paginating results to indicate where to begin in your list of distributions. The results include distributions in the list that occur after the marker. To get the next page of results, set the Marker to the value of the NextMarker from the current page's response (which is also the ID of the last distribution on that page).
MaxItemsstringThe maximum number of distributions you want in the response body.
StagingDistributionIdstringThe identifier of the staging distribution whose configuration you are copying to the primary distribution.

SELECT examples

Get the information about a distribution.

SELECT
arn,
active_trusted_key_groups,
active_trusted_signers,
alias_icp_recordals,
distribution_config,
domain_name,
id,
in_progress_invalidation_batches,
last_modified_time,
status
FROM aws.cloudfront.distributions
WHERE id = '{{ id }}' -- required
AND region = '{{ region }}' -- required
;

INSERT examples

Creates a CloudFront distribution.

INSERT INTO aws.cloudfront.distributions (
DistributionConfig,
region
)
SELECT
'{{ DistributionConfig }}' /* required */,
'{{ region }}'
RETURNING
arn,
active_trusted_key_groups,
active_trusted_signers,
alias_icp_recordals,
distribution_config,
domain_name,
id,
in_progress_invalidation_batches,
last_modified_time,
status
;

UPDATE examples

Associates the WAF web ACL with a distribution.

UPDATE aws.cloudfront.distributions
SET
WebACLArn = '{{ WebACLArn }}'
WHERE
id = '{{ id }}' --required
AND region = '{{ region }}' --required
AND WebACLArn = '{{ WebACLArn }}' --required
AND `If-Match` = '{{ If-Match}}'
RETURNING
e_tag,
id,
web_acl_arn;

DELETE examples

Delete a distribution. Before you can delete a distribution, you must disable it, which requires permission to update the distribution. Once deleted, a distribution cannot be recovered.

DELETE FROM aws.cloudfront.distributions
WHERE id = '{{ id }}' --required
AND region = '{{ region }}' --required
AND `If-Match` = '{{ If-Match }}'
;

Lifecycle Methods

Copies the staging distribution's configuration to its corresponding primary distribution. The primary distribution retains its Aliases (also known as alternate domain names or CNAMEs) and ContinuousDeploymentPolicyId value, but otherwise its configuration is overwritten to match the staging distribution. You can use this operation in a continuous deployment workflow after you have tested configuration changes on the staging distribution. After using a continuous deployment policy to move a portion of your domain name's traffic to the staging distribution and verifying that it works as intended, you can use this operation to copy the staging distribution's configuration to the primary distribution. This action will disable the continuous deployment policy and move your domain's traffic back to the primary distribution. This API operation requires the following IAM permissions: GetDistribution UpdateDistribution

EXEC aws.cloudfront.distributions.update_distribution_with_staging_config
@id='{{ id }}' --required,
@region='{{ region }}' --required,
@StagingDistributionId='{{ StagingDistributionId }}',
@If-Match='{{ If-Match }}'
;