Created
February 10, 2023 04:51
-
-
Save leegilmorecode/cb0c750c98fd280aa9c30d3a990ce8ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as cdk from 'aws-cdk-lib'; | |
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'; | |
import * as s3 from 'aws-cdk-lib/aws-s3'; | |
import { Construct } from 'constructs'; | |
import { RemovalPolicy } from 'aws-cdk-lib'; | |
export interface StatefulStackProps extends cdk.StackProps { | |
bucketName: string; | |
} | |
export class StatefulStack extends cdk.Stack { | |
public readonly bucket: s3.Bucket; | |
public readonly table: dynamodb.Table; | |
constructor(scope: Construct, id: string, props: StatefulStackProps) { | |
super(scope, id, props); | |
// create the s3 bucket for invoices | |
this.bucket = new s3.Bucket(this, 'Bucket', { | |
bucketName: props.bucketName, // this is passed through per env from config | |
}); | |
// create the dynamodb table | |
this.table = new dynamodb.Table(this, 'Table', { | |
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST, | |
encryption: dynamodb.TableEncryption.AWS_MANAGED, | |
pointInTimeRecovery: false, | |
contributorInsightsEnabled: true, | |
removalPolicy: RemovalPolicy.DESTROY, | |
partitionKey: { | |
name: 'id', | |
type: dynamodb.AttributeType.STRING, | |
}, | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment