
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
cdk-construct-website
Advanced tools
An AWS CDK construct for hosting websites on AWS S3
npm install --save cdk-construct-website
import * as cdk from '@aws-cdk/core';
import { Website } from 'cdk-construct-website';
import { BucketDeployment, Source } from '@aws-cdk/aws-s3-deployment';
export class ExampleStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const website = new Website(this, 'Website');
new BucketDeployment(this, 'BucketDeployment', {
sources: [Source.asset('./dist')],
destinationBucket: website.bucket,
distribution: website.distribution,
distributionPaths: ['/*'],
});
}
}
import * as cdk from '@aws-cdk/core';
import { Website } from 'cdk-construct-website';
import { BucketDeployment, Source } from '@aws-cdk/aws-s3-deployment';
import { HostedZone, ARecord, RecordTarget } from '@aws-cdk/aws-route53';
import { CloudFrontTarget } from '@aws-cdk/aws-route53-targets';
import { DnsValidatedCertificate } from '@aws-cdk/aws-certificatemanager';
export class ExampleStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const domainName = new cdk.CfnParameter(this, 'DomainName', {
type: 'String',
description: 'Domain name',
})
const hostedZoneId = new cdk.CfnParameter(this, 'HostedZoneId', {
type: 'String',
description: 'Route53 Hosted Zone Id'
})
const hostedZone = HostedZone.fromHostedZoneAttributes(this, 'HostedZone', {
hostedZoneId: hostedZoneId.valueAsString,
zoneName: domainName.valueAsString
})
const cert = new DnsValidatedCertificate(this, 'AwsManagedCertificate', {
domainName: domainName.valueAsString,
hostedZone: hostedZone,
subjectAlternativeNames: [`*.${domainName.valueAsString}`]
});
const website = new Website(this, 'Website', {
domainName: domainName.valueAsString,
certificateArn: cert.certificateArn
});
new BucketDeployment(this, 'WebDeployment', {
sources: [Source.asset('./dist')],
destinationBucket: website.bucket,
distribution: website.distribution,
distributionPaths: ['/*'],
});
new ARecord(this, 'WebAliasRecord', {
zone: hostedZone,
recordName: domainName.valueAsString,
target: RecordTarget.fromAlias(new CloudFrontTarget(website.distribution)),
});
}
}
FAQs
An AWS CDK construct for hosting websites on AWS S3
We found that cdk-construct-website demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.