Skip to content

create_distribution async

create_distribution(
    distribution_config: DistributionConfig,
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
) -> CreateDistributionResult

Creates a CloudFront distribution.

Parameters:

  • distribution_config (DistributionConfig) –

    The distribution's configuration information.

Raises:

Source code in docs_src/capo_cloudfront/_services/async_cloud_front.py
async def create_distribution(
    self,
    distribution_config: "capo_cloudfront.types.distribution_config.DistributionConfig",
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
) -> "capo_cloudfront.types.create_distribution_result.CreateDistributionResult":
    """<p>Creates a CloudFront distribution.</p>

    Args:
        distribution_config: <p>The distribution's configuration information.</p>

    Raises:
        capo_cloudfront.errors.access_denied.AccessDenied: <p>Access denied.</p>
        capo_cloudfront.errors.cname_already_exists.CNAMEAlreadyExists: <p>The CNAME specified is already defined for CloudFront.</p>
        capo_cloudfront.errors.continuous_deployment_policy_in_use.ContinuousDeploymentPolicyInUse: <p>You cannot delete a continuous deployment policy that is associated with a primary distribution.</p>
        capo_cloudfront.errors.distribution_already_exists.DistributionAlreadyExists: <p>The caller reference you attempted to create the distribution with is associated with another distribution.</p>
        capo_cloudfront.errors.entity_limit_exceeded.EntityLimitExceeded: <p>The entity limit has been exceeded.</p>
        capo_cloudfront.errors.entity_not_found.EntityNotFound: <p>The entity was not found.</p>
        capo_cloudfront.errors.illegal_field_level_encryption_config_association_with_cache_behavior.IllegalFieldLevelEncryptionConfigAssociationWithCacheBehavior: <p>The specified configuration for field-level encryption can't be associated with the specified cache behavior.</p>
        capo_cloudfront.errors.illegal_origin_access_configuration.IllegalOriginAccessConfiguration: <p>An origin cannot contain both an origin access control (OAC) and an origin access identity (OAI).</p>
        capo_cloudfront.errors.inconsistent_quantities.InconsistentQuantities: <p>The value of <code>Quantity</code> and the size of <code>Items</code> don't match.</p>
        capo_cloudfront.errors.invalid_argument.InvalidArgument: <p>An argument is invalid.</p>
        capo_cloudfront.errors.invalid_default_root_object.InvalidDefaultRootObject: <p>The default root object file name is too big or contains an invalid character.</p>
        capo_cloudfront.errors.invalid_domain_name_for_origin_access_control.InvalidDomainNameForOriginAccessControl: <p>An origin access control is associated with an origin whose domain name is not supported.</p>
        capo_cloudfront.errors.invalid_error_code.InvalidErrorCode: <p>An invalid error code was specified.</p>
        capo_cloudfront.errors.invalid_forward_cookies.InvalidForwardCookies: <p>Your request contains forward cookies option which doesn't match with the expectation for the <code>whitelisted</code> list of cookie names. Either list of cookie names has been specified when not allowed or list of cookie names is missing when expected.</p>
        capo_cloudfront.errors.invalid_function_association.InvalidFunctionAssociation: <p>A CloudFront function association is invalid.</p>
        capo_cloudfront.errors.invalid_geo_restriction_parameter.InvalidGeoRestrictionParameter: <p>The specified geo restriction parameter is not valid.</p>
        capo_cloudfront.errors.invalid_headers_for_s3_origin.InvalidHeadersForS3Origin: <p>The headers specified are not valid for an Amazon S3 origin.</p>
        capo_cloudfront.errors.invalid_lambda_function_association.InvalidLambdaFunctionAssociation: <p>The specified Lambda@Edge function association is invalid.</p>
        capo_cloudfront.errors.invalid_location_code.InvalidLocationCode: <p>The location code specified is not valid.</p>
        capo_cloudfront.errors.invalid_minimum_protocol_version.InvalidMinimumProtocolVersion: <p>The minimum protocol version specified is not valid.</p>
        capo_cloudfront.errors.invalid_origin.InvalidOrigin: <p>The Amazon S3 origin server specified does not refer to a valid Amazon S3 bucket.</p>
        capo_cloudfront.errors.invalid_origin_access_control.InvalidOriginAccessControl: <p>The origin access control is not valid.</p>
        capo_cloudfront.errors.invalid_origin_access_identity.InvalidOriginAccessIdentity: <p>The origin access identity is not valid or doesn't exist.</p>
        capo_cloudfront.errors.invalid_origin_keepalive_timeout.InvalidOriginKeepaliveTimeout: <p>The keep alive timeout specified for the origin is not valid.</p>
        capo_cloudfront.errors.invalid_origin_read_timeout.InvalidOriginReadTimeout: <p>The read timeout specified for the origin is not valid.</p>
        capo_cloudfront.errors.invalid_protocol_settings.InvalidProtocolSettings: <p>You cannot specify SSLv3 as the minimum protocol version if you only want to support only clients that support Server Name Indication (SNI).</p>
        capo_cloudfront.errors.invalid_query_string_parameters.InvalidQueryStringParameters: <p>The query string parameters specified are not valid.</p>
        capo_cloudfront.errors.invalid_relative_path.InvalidRelativePath: <p>The relative path is too big, is not URL-encoded, or does not begin with a slash (/).</p>
        capo_cloudfront.errors.invalid_required_protocol.InvalidRequiredProtocol: <p>This operation requires the HTTPS protocol. Ensure that you specify the HTTPS protocol in your request, or omit the <code>RequiredProtocols</code> element from your distribution configuration.</p>
        capo_cloudfront.errors.invalid_response_code.InvalidResponseCode: <p>A response code is not valid.</p>
        capo_cloudfront.errors.invalid_ttl_order.InvalidTTLOrder: <p>The TTL order specified is not valid.</p>
        capo_cloudfront.errors.invalid_viewer_certificate.InvalidViewerCertificate: <p>A viewer certificate specified is not valid.</p>
        capo_cloudfront.errors.invalid_web_acl_id.InvalidWebACLId: <p>A web ACL ID specified is not valid. To specify a web ACL created using the latest version of WAF, use the ACL ARN, for example <code>arn:aws:wafv2:us-east-1:123456789012:global/webacl/ExampleWebACL/473e64fd-f30b-4765-81a0-62ad96dd167a</code>. To specify a web ACL created using WAF Classic, use the ACL ID, for example <code>473e64fd-f30b-4765-81a0-62ad96dd167a</code>.</p>
        capo_cloudfront.errors.missing_body.MissingBody: <p>This operation requires a body. Ensure that the body is present and the <code>Content-Type</code> header is set.</p>
        capo_cloudfront.errors.no_such_cache_policy.NoSuchCachePolicy: <p>The cache policy does not exist.</p>
        capo_cloudfront.errors.no_such_continuous_deployment_policy.NoSuchContinuousDeploymentPolicy: <p>The continuous deployment policy doesn't exist.</p>
        capo_cloudfront.errors.no_such_field_level_encryption_config.NoSuchFieldLevelEncryptionConfig: <p>The specified configuration for field-level encryption doesn't exist.</p>
        capo_cloudfront.errors.no_such_origin.NoSuchOrigin: <p>No origin exists with the specified <code>Origin Id</code>.</p>
        capo_cloudfront.errors.no_such_origin_request_policy.NoSuchOriginRequestPolicy: <p>The origin request policy does not exist.</p>
        capo_cloudfront.errors.no_such_realtime_log_config.NoSuchRealtimeLogConfig: <p>The real-time log configuration does not exist.</p>
        capo_cloudfront.errors.no_such_response_headers_policy.NoSuchResponseHeadersPolicy: <p>The response headers policy does not exist.</p>
        capo_cloudfront.errors.realtime_log_config_owner_mismatch.RealtimeLogConfigOwnerMismatch: <p>The specified real-time log configuration belongs to a different Amazon Web Services account.</p>
        capo_cloudfront.errors.too_many_cache_behaviors.TooManyCacheBehaviors: <p>You cannot create more cache behaviors for the distribution.</p>
        capo_cloudfront.errors.too_many_certificates.TooManyCertificates: <p>You cannot create anymore custom SSL/TLS certificates.</p>
        capo_cloudfront.errors.too_many_cookie_names_in_white_list.TooManyCookieNamesInWhiteList: <p>Your request contains more cookie names in the whitelist than are allowed per cache behavior.</p>
        capo_cloudfront.errors.too_many_distribution_cnam_es.TooManyDistributionCNAMEs: <p>Your request contains more CNAMEs than are allowed per distribution.</p>
        capo_cloudfront.errors.too_many_distributions.TooManyDistributions: <p>Processing your request would cause you to exceed the maximum number of distributions allowed.</p>
        capo_cloudfront.errors.too_many_distributions_associated_to_cache_policy.TooManyDistributionsAssociatedToCachePolicy: <p>The maximum number of distributions have been associated with the specified cache policy. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.too_many_distributions_associated_to_field_level_encryption_config.TooManyDistributionsAssociatedToFieldLevelEncryptionConfig: <p>The maximum number of distributions have been associated with the specified configuration for field-level encryption.</p>
        capo_cloudfront.errors.too_many_distributions_associated_to_key_group.TooManyDistributionsAssociatedToKeyGroup: <p>The number of distributions that reference this key group is more than the maximum allowed. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.too_many_distributions_associated_to_origin_access_control.TooManyDistributionsAssociatedToOriginAccessControl: <p>The maximum number of distributions have been associated with the specified origin access control.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.too_many_distributions_associated_to_origin_request_policy.TooManyDistributionsAssociatedToOriginRequestPolicy: <p>The maximum number of distributions have been associated with the specified origin request policy. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.too_many_distributions_associated_to_response_headers_policy.TooManyDistributionsAssociatedToResponseHeadersPolicy: <p>The maximum number of distributions have been associated with the specified response headers policy.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.too_many_distributions_with_function_associations.TooManyDistributionsWithFunctionAssociations: <p>You have reached the maximum number of distributions that are associated with a CloudFront function. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.too_many_distributions_with_lambda_associations.TooManyDistributionsWithLambdaAssociations: <p>Processing your request would cause the maximum number of distributions with Lambda@Edge function associations per owner to be exceeded.</p>
        capo_cloudfront.errors.too_many_distributions_with_single_function_arn.TooManyDistributionsWithSingleFunctionARN: <p>The maximum number of distributions have been associated with the specified Lambda@Edge function.</p>
        capo_cloudfront.errors.too_many_function_associations.TooManyFunctionAssociations: <p>You have reached the maximum number of CloudFront function associations for this distribution. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.too_many_headers_in_forwarded_values.TooManyHeadersInForwardedValues: <p>Your request contains too many headers in forwarded values.</p>
        capo_cloudfront.errors.too_many_key_groups_associated_to_distribution.TooManyKeyGroupsAssociatedToDistribution: <p>The number of key groups referenced by this distribution is more than the maximum allowed. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.too_many_lambda_function_associations.TooManyLambdaFunctionAssociations: <p>Your request contains more Lambda@Edge function associations than are allowed per distribution.</p>
        capo_cloudfront.errors.too_many_origin_custom_headers.TooManyOriginCustomHeaders: <p>Your request contains too many origin custom headers.</p>
        capo_cloudfront.errors.too_many_origin_groups_per_distribution.TooManyOriginGroupsPerDistribution: <p>Processing your request would cause you to exceed the maximum number of origin groups allowed.</p>
        capo_cloudfront.errors.too_many_origins.TooManyOrigins: <p>You cannot create more origins for the distribution.</p>
        capo_cloudfront.errors.too_many_query_string_parameters.TooManyQueryStringParameters: <p>Your request contains too many query string parameters.</p>
        capo_cloudfront.errors.too_many_trusted_signers.TooManyTrustedSigners: <p>Your request contains more trusted signers than are allowed per distribution.</p>
        capo_cloudfront.errors.trusted_key_group_does_not_exist.TrustedKeyGroupDoesNotExist: <p>The specified key group does not exist.</p>
        capo_cloudfront.errors.trusted_signer_does_not_exist.TrustedSignerDoesNotExist: <p>One or more of your trusted signers don't exist.</p>
        capo_cloudfront.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudfront.types.create_distribution_request.CreateDistributionRequest]",
    ) -> AsyncOperationResponse[
        "capo_cloudfront.types.create_distribution_result.CreateDistributionResult"
    ]:
        import capo_cloudfront._operations.cloudfront2020_05_31.create_distribution

        (
            output,
            http_response,
        ) = await capo_cloudfront._operations.cloudfront2020_05_31.create_distribution.async_create_distribution(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_cloudfront.types.create_distribution_request.CreateDistributionRequest",
    ) -> dict[str, Any]:
        import capo_cloudfront.types.create_distribution_request

        return capo_cloudfront.types.create_distribution_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_cloudfront.types.create_distribution_result.CreateDistributionResult",
    ) -> dict[str, Any]:
        import capo_cloudfront.types.create_distribution_result

        return capo_cloudfront.types.create_distribution_result.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateDistribution",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_cloudfront.types.create_distribution_request.CreateDistributionRequest = {
        "distribution_config": distribution_config
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output