Skip to content

CloudFront

Bases: DuploResourceV3

Manage CloudFront Distributions

Configuring a CloudFront distributions in DuploCloud are content delivery network (CDN) configurations that help you improve the performance of your web applications.

See more details at: https://docs.duplocloud.com/docs/overview/aws-services/cloudfront

Commands

apply

Apply a CloudFront

Create or Update a CloudFront resource with Duplocloud cli.

CLI Usage

duploctl cloudfront apply -f 'cloudfront.yaml'
Contents of the cloudfront.yaml file

Returns:

Name Type Description
message dict

Success message.

Parameters:

--file, -f, --cli-input
A file to read the input from
FileType('r') action: YamlAction
--patches, --add, --remove, --copy, --replace, --test, --move
The json patch to apply
str action: JsonPatchAction

create

Create a CloudFront distribution.

Creates a new CloudFront distribution with the specified configuration.

Basic CLI Use
duploctl cloudfront create -f cloudfront.yaml

Example cloudfront.yaml:

# Origin DomainName, Id, and TargetOriginId are replaced at test runtime
# with the actual S3 bucket domain created by TestS3.
UseOAIIdentity: true
DistributionConfig:
  DefaultRootObject: index.html
  Aliases:
    Items: []
    Quantity: 0
  ViewerCertificate:
    CloudFrontDefaultCertificate: true
  Origins:
    Items:
    - DomainName: placeholder.s3.amazonaws.com
      Id: placeholder.s3.amazonaws.com
      S3OriginConfig:
        OriginAccessIdentity: ""
    Quantity: 1
  CacheBehaviors:
    Items: []
    Quantity: 0
  CustomErrorResponses:
    Items: []
    Quantity: 0
  Logging:
    Enabled: false
  DefaultCacheBehavior:
    ViewerProtocolPolicy:
      Value: redirect-to-https
    LambdaFunctionAssociations:
      Items: []
      Quantity: 0
    Compress: true
    TargetOriginId: placeholder.s3.amazonaws.com
    # CachingOptimized managed policy — works for S3 origins without requiring ForwardedValues/MinTTL
    CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6
  Comment: duplo-cloudfront
CorsAllowedHostNames: []

Returns:

Name Type Description
dict

The created distribution details including the distribution ID.

Raises:

Type Description
DuploError

If the distribution could not be created or the configuration is invalid.

DuploFailedResource

If the distribution creation process fails.

Model: AmazonCloudFrontRequest
{
  "description": "AmazonCloudFrontRequest",
  "properties": {},
  "title": "AmazonCloudFrontRequest",
  "type": "object"
}

Parameters:

--file, -f, --cli-input
A file to read the input from
AmazonCloudFrontRequest action: YamlAction

delete

Delete a CloudFront distribution.

Permanently removes a CloudFront distribution. This operation is irreversible and will remove all distribution settings and cached content. The distribution must be disabled before it can be deleted.

Basic CLI Use
duploctl cloudfront delete <distribution-id>

Returns:

Name Type Description
dict

Success message confirming the deletion.

Raises:

Type Description
DuploError

If the distribution could not be deleted or is not in a deletable state.

Parameters:

distribution_id positional
The distribution id
str

disable

Disable a CloudFront distribution.

Disables content delivery for a CloudFront distribution. When disabled, the distribution will stop serving content but will retain its configuration.

Basic CLI Use
duploctl cloudfront disable <distribution-id>

Returns:

Name Type Description
dict

The updated distribution details.

Raises:

Type Description
DuploError

If the distribution could not be disabled.

DuploFailedResource

If the disable process fails.

Parameters:

distribution_id positional
The distribution id
str

enable

Enable a CloudFront distribution.

Enables content delivery for a previously disabled CloudFront distribution. When enabled, the distribution will start serving content using its current configuration.

Basic CLI Use
duploctl cloudfront enable <distribution-id>

Returns:

Name Type Description
dict

The updated distribution details.

Raises:

Type Description
DuploError

If the distribution could not be enabled.

DuploFailedResource

If the enable process fails.

Parameters:

distribution_id positional
The distribution id
str

find

Find a CloudFront distribution.

Find a CloudFront distribution by its distribution ID.

Usage
duploctl cloudfront find <distribution_id>

Returns:

Name Type Description
dict

The service object.

Parameters:

distribution_id positional
The distribution id
str

get_status

Get the current status of a CloudFront distribution.

Retrieves the current deployment status of a CloudFront distribution. The status indicates whether the distribution is deployed, in progress, or in an error state.

Basic CLI Use
duploctl cloudfront get-status <distribution-id>

Returns:

Name Type Description
str

The current status of the distribution (e.g., 'Deployed', 'InProgress').

Raises:

Type Description
DuploError

If the distribution could not be found or the status is unavailable.

Parameters:

distribution_id positional
The distribution id
str

list

Retrieve a List of CloudFront resources

cli usage
duploctl cloudfront list

Returns:

Name Type Description
list list

A list of CloudFront.

update

Update a CloudFront distribution.

Updates an existing CloudFront distribution with new configuration settings.

Basic CLI Use
duploctl cloudfront update -f cloudfront.yaml

Example cloudfront.yaml:

# Origin DomainName, Id, and TargetOriginId are replaced at test runtime
# with the actual S3 bucket domain created by TestS3.
UseOAIIdentity: true
Id:
DistributionConfig:
  Aliases:
    Items: []
    Quantity: 0
  CacheBehaviors:
    Items: []
    Quantity: 0
  CallerReference: 
  Comment: duplo-cloudfront
  ContinuousDeploymentPolicyId: ""
  CustomErrorResponses:
    Items: []
    Quantity: 0
  DefaultCacheBehavior:
    AllowedMethods:
      CachedMethods:
        Items:
        - HEAD
        - GET
        Quantity: 2
      Items:
      - HEAD
      - GET
      Quantity: 2
    CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6
    Compress: true
    FieldLevelEncryptionId: ""
    FunctionAssociations:
      Items: []
      Quantity: 0
    LambdaFunctionAssociations:
      Items: []
      Quantity: 0
    SmoothStreaming: false
    TargetOriginId: placeholder.s3.amazonaws.com
    TrustedKeyGroups:
      Enabled: false
      Items: []
      Quantity: 0
    TrustedSigners:
      Enabled: false
      Items: []
      Quantity: 0
    ViewerProtocolPolicy:
      Value: redirect-to-https
  DefaultRootObject: main.html
  Enabled: true
  HttpVersion:
    Value: http2
  IsIPV6Enabled: true
  Logging:
    Bucket: ""
    Enabled: false
    IncludeCookies: false
    Prefix: ""
  OriginGroups:
    Items: []
    Quantity: 0
  Origins:
    Items:
    - ConnectionAttempts: 3
      ConnectionTimeout: 10
      CustomHeaders:
        Items: []
        Quantity: 0
      DomainName: placeholder.s3.amazonaws.com
      Id: placeholder.s3.amazonaws.com
      OriginAccessControlId: ""
      OriginPath: ""
      OriginShield:
        Enabled: false
      S3OriginConfig:
        OriginAccessIdentity: ""
    Quantity: 1
  PriceClass:
    Value: PriceClass_All
  Restrictions:
    GeoRestriction:
      Items: []
      Quantity: 0
      RestrictionType:
        Value: none
  Staging: false
  ViewerCertificate:
    CloudFrontDefaultCertificate: true
    MinimumProtocolVersion:
      Value: TLSv1
  WebACLId: ""

Returns:

Name Type Description
dict

The updated distribution details.

Raises:

Type Description
DuploError

If the distribution could not be updated or the configuration is invalid.

DuploFailedResource

If the update process fails.

Model: AmazonCloudFrontRequest
{
  "description": "AmazonCloudFrontRequest",
  "properties": {},
  "title": "AmazonCloudFrontRequest",
  "type": "object"
}

Parameters:

--file, -f, --cli-input
A file to read the input from
AmazonCloudFrontRequest action: YamlAction

Methods

wait_check