AWS SDK for JavaScript Cloudfront Client for Node.js, Browser and React Native
npm install @aws-sdk/client-cloudfrontAWS SDK for JavaScript CloudFront Client for Node.js, Browser and React Native.
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.
npm install @aws-sdk/client-cloudfrontyarn add @aws-sdk/client-cloudfrontpnpm add @aws-sdk/client-cloudfrontThe 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:
``js`
// ES5 example
const { CloudFrontClient, ListCachePoliciesCommand } = require("@aws-sdk/client-cloudfront");
`ts`
// ES6+ example
import { CloudFrontClient, ListCachePoliciesCommand } from "@aws-sdk/client-cloudfront";
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.destroy()
- If you are using a custom http handler, you may call to close open connections.
`js
// 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:
`js`
// 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.
`js`
client.send(command).then(
(data) => {
// process data.
},
(error) => {
// error handling.
}
);
Promises can also be called using .catch() and .finally() as follows:
`js`
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.
`js`
// 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
`ts
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.
});
`
When the service returns an exception, the error will include the exception information,
as well as response metadata (e.g. request id).
`js`
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;
* }
*/
}
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.
- Visit Developer Guide
or API Reference.
- Check out the blog posts tagged with aws-sdk-js
on AWS Developer Blog.
- Ask a question on StackOverflow and tag it with aws-sdk-js.
- Join the AWS JavaScript community on gitter.
- If it turns out that you may have found a bug, please open an issue.
To test your universal JavaScript code in Node.js, browser and react-native environments,
visit our code samples repo.
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.
This SDK is distributed under the
Apache License, Version 2.0,
see LICENSE for more information.
AssociateAlias
Command API Reference / Input / Output
AssociateDistributionTenantWebACL
Command API Reference / Input / Output
AssociateDistributionWebACL
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
CreateConnectionFunction
Command API Reference / Input / Output
CreateConnectionGroup
Command API Reference / Input / Output
CreateContinuousDeploymentPolicy
Command API Reference / Input / Output
CreateDistribution
Command API Reference / Input / Output
CreateDistributionTenant
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
CreateInvalidationForDistributionTenant
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
CreateTrustStore
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
DeleteConnectionFunction
Command API Reference / Input / Output
DeleteConnectionGroup
Command API Reference / Input / Output
DeleteContinuousDeploymentPolicy
Command API Reference / Input / Output
DeleteDistribution
Command API Reference / Input / Output
DeleteDistributionTenant
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
DeleteResourcePolicy
Command API Reference / Input / Output
DeleteResponseHeadersPolicy
Command API Reference / Input / Output
DeleteStreamingDistribution
Command API Reference / Input / Output
DeleteTrustStore
Command API Reference / Input / Output
DeleteVpcOrigin
Command API Reference / Input / Output
DescribeConnectionFunction
Command API Reference / Input / Output
DescribeFunction
Command API Reference / Input / Output
DescribeKeyValueStore
Command API Reference / Input / Output
DisassociateDistributionTenantWebACL
Command API Reference / Input / Output
DisassociateDistributionWebACL
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
GetConnectionFunction
Command API Reference / Input / Output
GetConnectionGroup
Command API Reference / Input / Output
GetConnectionGroupByRoutingEndpoint
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
GetDistributionTenant
Command API Reference / Input / Output
GetDistributionTenantByDomain
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
GetInvalidationForDistributionTenant
Command API Reference / Input / Output
GetKeyGroup
Command API Reference / Input / Output
GetKeyGroupConfig
Command API Reference / Input / Output
GetManagedCertificateDetails
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
GetResourcePolicy
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
GetTrustStore
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
ListConnectionFunctions
Command API Reference / Input / Output
ListConnectionGroups
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
ListDistributionsByConnectionFunction
Command API Reference / Input / Output
ListDistributionsByConnectionMode
Command API Reference / Input / Output
ListDistributionsByKeyGroup
Command API Reference / Input / Output
ListDistributionsByOriginRequestPolicyId
Command API Reference / Input / Output
ListDistributionsByOwnedResource
Command API Reference / Input / Output
ListDistributionsByRealtimeLogConfig
Command API Reference / Input / Output
ListDistributionsByResponseHeadersPolicyId
Command API Reference / Input / Output
ListDistributionsByTrustStore
Command API Reference / Input / Output
ListDistributionsByVpcOriginId
Command API Reference / Input / Output
ListDistributionsByWebACLId
Command API Reference / Input / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cloudfront/Interface/ListDistributionsByWebAC