Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #141 from aligent/feature/documentation-update
Browse files Browse the repository at this point in the history
Updates code snippet in README
  • Loading branch information
John Smith authored Feb 14, 2022
2 parents 6c72d71 + b218b65 commit 4498403
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,43 @@
## Overview

This repository defines a CDK construct for hosting a static website on AWS using S3 and CloudFront.
It can be imported and use within CDK application.
It can be imported and used within CDK applications.

## Example
The following CDK snippet can be used to provision a static hosting stack using this construct.

```
import 'source-map-support/register';
import * as cdk from '@aws-cdk/core';
import { StaticHosting } from '@aligent/aws-cdk-static-hosting'
import { Stack } from '@aws-cdk/core';
import { StaticHosting, StaticHostingProps } from '@aligent/cdk-static-hosting'
import { Construct, Stack, StackProps } from '@aws-cdk/core';
const hostingStackProps = {
env: {
region: 'ap-southeast-2',
account: 'account-id-goes-here',
},
stackName: 'stack-name',
subDomainName: 'sub.domain',
domainName: 'domain.tld',
certificateArn: 'arn:aws:acm:us-east-1:123456789:certificate/some-arn-id',
createDnsRecord: true,
createPublisherGroup: true,
createPublisherUser: true,
const HostingStackProps : StaticHostingProps = {
subDomainName: 'sub.domain',
domainName: 'domain.tld',
certificateArn: 'arn:aws:acm:us-east-1:123456789:certificate/some-arn-id',
createDnsRecord: false,
createPublisherGroup: true,
createPublisherUser: true,
enableErrorConfig: true
};
class StaticHostingStack extends Stack {
constructor(scope: Construct, id: string, props: hostingStackProps) {
super(scope, id, props);
class HostingStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps) {
super(scope, id, props);
new StaticHosting(scope, 'PWA-hosting-stack', props);
}
new StaticHosting(this, 'hosting-stack', HostingStackProps);
}
}
const app = new cdk.App();
new HostingStack(app, 'hosting-stack', {
env: {
region: 'ap-southeast-2',
account: 'account-id',
}
});
```

0 comments on commit 4498403

Please sign in to comment.