CDK Constructs for AWS CloudFront
Project description
Amazon CloudFront Construct Library
---This is a developer preview (public beta) module. Releases might lack important features and might have future breaking changes.
This API is still under active development and subject to non-backward compatible changes or removal in any future version. Use of the API is not recommended in production environments. Experimental APIs are not subject to the Semantic Versioning model.
A CloudFront construct - for setting up the AWS CDN with ease!
Example usage:
# Example may have issues. See https://github.com/aws/jsii/issues/826
source_bucket = Bucket(self, "Bucket")
distribution = CloudFrontWebDistribution(self, "MyDistribution",
origin_configs=[{
"s3_origin_source": {
"s3_bucket_source": source_bucket
},
"behaviors": [{"is_default_behavior": True}]
}
]
)
Viewer certificate
By default, CloudFront Web Distributions will answer HTTPS requests with CloudFront's default certificate, only containing the distribution domainName
(e.g. d111111abcdef8.cloudfront.net).
You can customize the viewer certificate property to provide a custom certificate and/or list of domain name aliases to fit your needs.
See Using Alternate Domain Names and HTTPS in the CloudFront User Guide.
Default certificate
You can customize the default certificate aliases. This is intended to be used in combination with CNAME records in your DNS zone.
Example:
const s3BucketSource = new s3.Bucket(this, 'Bucket');
const distribution = new cloudfront.CloudFrontWebDistribution(this, 'AnAmazingWebsiteProbably', {
originConfigs: [{
s3OriginSource: { s3BucketSource },
behaviors: [{ isDefaultBehavior: true }]
}],
viewerCertificate: cloudfront.ViewerCertificate.fromCloudFrontDefaultCertificate(
'www.example.com'
),
});
ACM certificate
You can change the default certificate by one stored Amazon Certificate Manager, or ACM. Those certificate can either be generated by AWS, or purchased by another CA imported into ACM.
For more information, see the aws-certificatemanager module documentation or Importing Certificates into AWS Certificate Manager in the AWS Certificate Manager User Guide.
Example:
const s3BucketSource = new s3.Bucket(this, 'Bucket');
const certificate = new certificatemanager.Certificate(this, 'Certificate', {
domainName: 'example.com',
subjectAlternativeNames: ['*.example.com'],
});
const distribution = new cloudfront.CloudFrontWebDistribution(this, 'AnAmazingWebsiteProbably', {
originConfigs: [{
s3OriginSource: { s3BucketSource },
behaviors: [{ isDefaultBehavior: true }]
}],
viewerCertificate: cloudfront.ViewerCertificate.fromAcmCertificate(
certificate,
{
aliases: ['example.com', 'www.example.com'],
securityPolicy: cloudfront.SecurityPolicyProtocol.TLS_V1, // default
sslMethod: cloudfront.SSLMethod.SNI, // default
}
),
});
IAM certificate
You can also import a certificate into the IAM certificate store.
See Importing an SSL/TLS Certificate in the CloudFront User Guide.
Example:
const s3BucketSource = new s3.Bucket(this, 'Bucket');
const distribution = new cloudfront.CloudFrontWebDistribution(this, 'AnAmazingWebsiteProbably', {
originConfigs: [{
s3OriginSource: { s3BucketSource },
behaviors: [{ isDefaultBehavior: true }]
}],
viewerCertificate: cloudfront.ViewerCertificate.fromIamCertificate(
'certificateId',
{
aliases: ['example.com'],
securityPolicy: cloudfront.SecurityPolicyProtocol.SSL_V3, // default
sslMethod: cloudfront.SSLMethod.SNI, // default
}
),
});
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aws-cdk.aws-cloudfront-1.17.0.tar.gz
.
File metadata
- Download URL: aws-cdk.aws-cloudfront-1.17.0.tar.gz
- Upload date:
- Size: 125.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bc1400b810a2d0255efd43f49ea68bee4cdd688fe1d31f1b7dce23cb4a099e0 |
|
MD5 | d362001231e1bd57aafe11a44a828e8a |
|
BLAKE2b-256 | d0eb4d15a65f29ffb8463b419afbdff168e9ac0923ddec4813313b51e1b5603d |
File details
Details for the file aws_cdk.aws_cloudfront-1.17.0-py3-none-any.whl
.
File metadata
- Download URL: aws_cdk.aws_cloudfront-1.17.0-py3-none-any.whl
- Upload date:
- Size: 123.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de63ff1a3b20d3a104a83cd260dcb195337e51bb729fc1ddf7a72f531a120419 |
|
MD5 | 90ce4c792fe0efbd04aa32f125879b8b |
|
BLAKE2b-256 | 462208821d9fd60d617bbee0c2407aca51b80a11b3fe9477138df252df064201 |