@aws-sdk/client-cloudfront
TypeScript icon, indicating that this package has built-in type declarations

3.709.0 • Public • Published

@aws-sdk/client-cloudfront

Description

AWS SDK for JavaScript CloudFront Client for Node.js, Browser and React Native.

Amazon CloudFront

This is the Amazon CloudFront API Reference. This guide is for developers who need detailed information about CloudFront API actions, data types, and errors. For detailed information about CloudFront features, see the Amazon CloudFront Developer Guide.

Installing

To install this package, simply type add or install @aws-sdk/client-cloudfront using your favorite package manager:

  • npm install @aws-sdk/client-cloudfront
  • yarn add @aws-sdk/client-cloudfront
  • pnpm add @aws-sdk/client-cloudfront

Getting Started

Import

The AWS SDK is modulized by clients and commands. To send a request, you only need to import the CloudFrontClient and the commands you need, for example ListCachePoliciesCommand:

// ES5 example
const { CloudFrontClient, ListCachePoliciesCommand } = require("@aws-sdk/client-cloudfront");
// ES6+ example
import { CloudFrontClient, ListCachePoliciesCommand } from "@aws-sdk/client-cloudfront";

Usage

To send a request, you:

  • Initiate client with configuration (e.g. credentials, region).
  • Initiate command with input parameters.
  • Call send operation on client with command object as input.
  • If you are using a custom http handler, you may call destroy() to close open connections.
// a client can be shared by different commands.
const client = new CloudFrontClient({ region: "REGION" });

const params = {
  /** input parameters */
};
const command = new ListCachePoliciesCommand(params);

Async/await

We recommend using await operator to wait for the promise returned by send operation as follows:

// async/await.
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  // error handling.
} finally {
  // finally.
}

Async-await is clean, concise, intuitive, easy to debug and has better error handling as compared to using Promise chains or callbacks.

Promises

You can also use Promise chaining to execute send operation.

client.send(command).then(
  (data) => {
    // process data.
  },
  (error) => {
    // error handling.
  }
);

Promises can also be called using .catch() and .finally() as follows:

client
  .send(command)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  })
  .finally(() => {
    // finally.
  });

Callbacks

We do not recommend using callbacks because of callback hell, but they are supported by the send operation.

// callbacks.
client.send(command, (err, data) => {
  // process err and data.
});

v2 compatible style

The client can also send requests using v2 compatible style. However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post on modular packages in AWS SDK for JavaScript

import * as AWS from "@aws-sdk/client-cloudfront";
const client = new AWS.CloudFront({ region: "REGION" });

// async/await.
try {
  const data = await client.listCachePolicies(params);
  // process data.
} catch (error) {
  // error handling.
}

// Promises.
client
  .listCachePolicies(params)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  });

// callbacks.
client.listCachePolicies(params, (err, data) => {
  // process err and data.
});

Troubleshooting

When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).

try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  const { requestId, cfId, extendedRequestId } = error.$metadata;
  console.log({ requestId, cfId, extendedRequestId });
  /**
   * The keys within exceptions are also parsed.
   * You can access them by specifying exception names:
   * if (error.name === 'SomeServiceException') {
   *     const value = error.specialKeyInException;
   * }
   */
}

Getting Help

Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.

To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.

Contributing

This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-cloudfront package is updated. To contribute to client you can check our generate clients scripts.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

Client Commands (Operations List)

AssociateAlias

Command API Reference / Input / Output

CopyDistribution

Command API Reference / Input / Output

CreateAnycastIpList

Command API Reference / Input / Output

CreateCachePolicy

Command API Reference / Input / Output

CreateCloudFrontOriginAccessIdentity

Command API Reference / Input / Output

CreateContinuousDeploymentPolicy

Command API Reference / Input / Output

CreateDistribution

Command API Reference / Input / Output

CreateDistributionWithTags

Command API Reference / Input / Output

CreateFieldLevelEncryptionConfig

Command API Reference / Input / Output

CreateFieldLevelEncryptionProfile

Command API Reference / Input / Output

CreateFunction

Command API Reference / Input / Output

CreateInvalidation

Command API Reference / Input / Output

CreateKeyGroup

Command API Reference / Input / Output

CreateKeyValueStore

Command API Reference / Input / Output

CreateMonitoringSubscription

Command API Reference / Input / Output

CreateOriginAccessControl

Command API Reference / Input / Output

CreateOriginRequestPolicy

Command API Reference / Input / Output

CreatePublicKey

Command API Reference / Input / Output

CreateRealtimeLogConfig

Command API Reference / Input / Output

CreateResponseHeadersPolicy

Command API Reference / Input / Output

CreateStreamingDistribution

Command API Reference / Input / Output

CreateStreamingDistributionWithTags

Command API Reference / Input / Output

CreateVpcOrigin

Command API Reference / Input / Output

DeleteAnycastIpList

Command API Reference / Input / Output

DeleteCachePolicy

Command API Reference / Input / Output

DeleteCloudFrontOriginAccessIdentity

Command API Reference / Input / Output

DeleteContinuousDeploymentPolicy

Command API Reference / Input / Output

DeleteDistribution

Command API Reference / Input / Output

DeleteFieldLevelEncryptionConfig

Command API Reference / Input / Output

DeleteFieldLevelEncryptionProfile

Command API Reference / Input / Output

DeleteFunction

Command API Reference / Input / Output

DeleteKeyGroup

Command API Reference / Input / Output

DeleteKeyValueStore

Command API Reference / Input / Output

DeleteMonitoringSubscription

Command API Reference / Input / Output

DeleteOriginAccessControl

Command API Reference / Input / Output

DeleteOriginRequestPolicy

Command API Reference / Input / Output

DeletePublicKey

Command API Reference / Input / Output

DeleteRealtimeLogConfig

Command API Reference / Input / Output

DeleteResponseHeadersPolicy

Command API Reference / Input / Output

DeleteStreamingDistribution

Command API Reference / Input / Output

DeleteVpcOrigin

Command API Reference / Input / Output

DescribeFunction

Command API Reference / Input / Output

DescribeKeyValueStore

Command API Reference / Input / Output

GetAnycastIpList

Command API Reference / Input / Output

GetCachePolicy

Command API Reference / Input / Output

GetCachePolicyConfig

Command API Reference / Input / Output

GetCloudFrontOriginAccessIdentity

Command API Reference / Input / Output

GetCloudFrontOriginAccessIdentityConfig

Command API Reference / Input / Output

GetContinuousDeploymentPolicy

Command API Reference / Input / Output

GetContinuousDeploymentPolicyConfig

Command API Reference / Input / Output

GetDistribution

Command API Reference / Input / Output

GetDistributionConfig

Command API Reference / Input / Output

GetFieldLevelEncryption

Command API Reference / Input / Output

GetFieldLevelEncryptionConfig

Command API Reference / Input / Output

GetFieldLevelEncryptionProfile

Command API Reference / Input / Output

GetFieldLevelEncryptionProfileConfig

Command API Reference / Input / Output

GetFunction

Command API Reference / Input / Output

GetInvalidation

Command API Reference / Input / Output

GetKeyGroup

Command API Reference / Input / Output

GetKeyGroupConfig

Command API Reference / Input / Output

GetMonitoringSubscription

Command API Reference / Input / Output

GetOriginAccessControl

Command API Reference / Input / Output

GetOriginAccessControlConfig

Command API Reference / Input / Output

GetOriginRequestPolicy

Command API Reference / Input / Output

GetOriginRequestPolicyConfig

Command API Reference / Input / Output

GetPublicKey

Command API Reference / Input / Output

GetPublicKeyConfig

Command API Reference / Input / Output

GetRealtimeLogConfig

Command API Reference / Input / Output

GetResponseHeadersPolicy

Command API Reference / Input / Output

GetResponseHeadersPolicyConfig

Command API Reference / Input / Output

GetStreamingDistribution

Command API Reference / Input / Output

GetStreamingDistributionConfig

Command API Reference / Input / Output

GetVpcOrigin

Command API Reference / Input / Output

ListAnycastIpLists

Command API Reference / Input / Output

ListCachePolicies

Command API Reference / Input / Output

ListCloudFrontOriginAccessIdentities

Command API Reference / Input / Output

ListConflictingAliases

Command API Reference / Input / Output

ListContinuousDeploymentPolicies

Command API Reference / Input / Output

ListDistributions

Command API Reference / Input / Output

ListDistributionsByAnycastIpListId

Command API Reference / Input / Output

ListDistributionsByCachePolicyId

Command API Reference / Input / Output

ListDistributionsByKeyGroup

Command API Reference / Input / Output

ListDistributionsByOriginRequestPolicyId

Command API Reference / Input / Output

ListDistributionsByRealtimeLogConfig

Command API Reference / Input / Output

ListDistributionsByResponseHeadersPolicyId

Command API Reference / Input / Output

ListDistributionsByVpcOriginId

Command API Reference / Input / Output

ListDistributionsByWebACLId

Command API Reference / Input / Output

ListFieldLevelEncryptionConfigs

Command API Reference / Input / Output

ListFieldLevelEncryptionProfiles

Command API Reference / Input / Output

ListFunctions

Command API Reference / Input / Output

ListInvalidations

Command API Reference / Input / Output

ListKeyGroups

Command API Reference / Input / Output

ListKeyValueStores

Command API Reference / Input / Output

ListOriginAccessControls

Command API Reference / Input / Output

ListOriginRequestPolicies

Command API Reference / Input / Output

ListPublicKeys

Command API Reference / Input / Output

ListRealtimeLogConfigs

Command API Reference / Input / Output

ListResponseHeadersPolicies

Command API Reference / Input / Output

ListStreamingDistributions

Command API Reference / Input / Output

ListTagsForResource

Command API Reference / Input / Output

ListVpcOrigins

Command API Reference / Input / Output

PublishFunction

Command API Reference / Input / Output

TagResource

Command API Reference / Input / Output

TestFunction

Command API Reference / Input / Output

UntagResource

Command API Reference / Input / Output

UpdateCachePolicy

Command API Reference / Input / Output

UpdateCloudFrontOriginAccessIdentity

Command API Reference / Input / Output

UpdateContinuousDeploymentPolicy

Command API Reference / Input / Output

UpdateDistribution

Command API Reference / Input / Output

UpdateDistributionWithStagingConfig

Command API Reference / Input / Output

UpdateFieldLevelEncryptionConfig

Command API Reference / Input / Output

UpdateFieldLevelEncryptionProfile

Command API Reference / Input / Output

UpdateFunction

Command API Reference / Input / Output

UpdateKeyGroup

Command API Reference / Input / Output

UpdateKeyValueStore

Command API Reference / Input / Output

UpdateOriginAccessControl

Command API Reference / Input / Output

UpdateOriginRequestPolicy

Command API Reference / Input / Output

UpdatePublicKey

Command API Reference / Input / Output

UpdateRealtimeLogConfig

Command API Reference / Input / Output

UpdateResponseHeadersPolicy

Command API Reference / Input / Output

UpdateStreamingDistribution

Command API Reference / Input / Output

UpdateVpcOrigin

Command API Reference / Input / Output

Readme

Keywords

none

Package Sidebar

Install

npm i @aws-sdk/client-cloudfront

Weekly Downloads

360,577

Version

3.709.0

License

Apache-2.0

Unpacked Size

3.53 MB

Total Files

473

Last publish

Collaborators

  • amzn-oss
  • aws-sdk-bot
  • trivikr-aws
  • mattsb42-aws
  • kuhe