-
Notifications
You must be signed in to change notification settings - Fork 0
/
cdk-stack.ts
41 lines (37 loc) · 1.58 KB
/
cdk-stack.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { SitemapsConstruct, SitemapFreshenerConstruct } from '@shutterstock/sitemaps-cdk';
/**
* Demonstration of using the SitemapsConstruct and SitemapFreshenerConstruct
*
* ⚠️ CAUTION: This uses the "Easy Button" approach where the construct will create and own
* the DynamoDB Table and S3 Bucket. This approach is not a CDK best practice.
*
* The CDK best practice is to put "durable" assets like DynamoDB Tables and S3 Buckets
* in a separate stack that is deployed once and managed separately from the application stack.
* This ensures that data is preserved if the application stack has an accidental resource
* id change that would cause the stateful resources to be deleted and recreated.
*/
export class SitemapsExampleStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const sitemaps = new SitemapsConstruct(this, 'SitemapsConstruct', {
autoDeleteEverything: true,
testBuild: false,
env: 'dev',
s3SitemapsPrefix: 'sitemaps',
});
if (sitemaps.dynamoDBTable === undefined) {
throw new Error('dynamoDBTable must be set');
}
const freshener = new SitemapFreshenerConstruct(this, 'SitemapFreshenerConstruct', {
autoDeleteEverything: true,
testBuild: false,
env: 'dev',
kinesisInputStream: sitemaps.kinesisInputStream,
s3SitemapsBucket: sitemaps.s3SitemapsBucket,
s3SitemapsPrefix: 'sitemaps',
dynamodbTable: sitemaps.dynamoDBTable,
});
}
}