Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sets removal policy on S3 and DynamoDB to DESTROY #100

Merged
merged 1 commit into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion typescript/api-cors-lambda-crud-dynamodb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export class ApiLambdaCrudDynamoDBStack extends cdk.Stack {
name: 'itemId',
type: dynamodb.AttributeType.STRING
},
tableName: 'items'
tableName: 'items',

// The default removal policy is RETAIN, which means that cdk destroy will not attempt to delete
// the new table, and it will remain in your account until manually deleted. By setting the policy to
// DESTROY, cdk destroy will delete the table (even if it has data in it)
removalPolicy: cdk.RemovalPolicy.DESTROY, // NOT recommended for production code
});

const getOneLambda = new lambda.Function(this, 'getOneItemFunction', {
Expand Down
7 changes: 6 additions & 1 deletion typescript/appsync-graphql-dynamodb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ export class AppSyncCdkStack extends cdk.Stack {
type: AttributeType.STRING
},
billingMode: BillingMode.PAY_PER_REQUEST,
stream: StreamViewType.NEW_IMAGE
stream: StreamViewType.NEW_IMAGE,

// The default removal policy is RETAIN, which means that cdk destroy will not attempt to delete
// the new table, and it will remain in your account until manually deleted. By setting the policy to
// DESTROY, cdk destroy will delete the table (even if it has data in it)
removalPolicy: cdk.RemovalPolicy.DESTROY, // NOT recommended for production code
});

const itemsTableRole = new Role(this, 'ItemsDynamoDBRole', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ export class CdkStack extends cdk.Stack {
const green_env = node.tryGetContext("green_env");
const app_name = node.tryGetContext("app_name");

const bucket = new s3.Bucket(this, 'BlueGreenBucket');
const bucket = new s3.Bucket(this, 'BlueGreenBucket', {
// The default removal policy is RETAIN, which means that cdk destroy will not attempt to delete
// the new bucket, and it will remain in your account until manually deleted. By setting the policy to
// DESTROY, cdk destroy will attempt to delete the bucket, but will error if the bucket is not empty.
removalPolicy: cdk.RemovalPolicy.DESTROY, // NOT recommended for production code
});

const handler = new lambda.Function(this, 'BlueGreenLambda', {
runtime: lambda.Runtime.PYTHON_3_6,
Expand Down
7 changes: 6 additions & 1 deletion typescript/my-widget-service/widget_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ export class WidgetService extends cdk.Construct {
constructor(scope: cdk.Construct, id: string) {
super(scope, id);

const bucket = new s3.Bucket(this, "WidgetStore");
const bucket = new s3.Bucket(this, "WidgetStore", {
// The default removal policy is RETAIN, which means that cdk destroy will not attempt to delete
// the new bucket, and it will remain in your account until manually deleted. By setting the policy to
// DESTROY, cdk destroy will attempt to delete the bucket, but will error if the bucket is not empty.
removalPolicy: cdk.RemovalPolicy.DESTROY, // NOT recommended for production code
});

const handler = new lambda.Function(this, "WidgetHandler", {
runtime: lambda.Runtime.NODEJS_8_10, // So we can use async in widget.js
Expand Down
7 changes: 6 additions & 1 deletion typescript/static-site/static-site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ export class StaticSite extends Construct {
bucketName: siteDomain,
websiteIndexDocument: 'index.html',
websiteErrorDocument: 'error.html',
publicReadAccess: true
publicReadAccess: true,

// The default removal policy is RETAIN, which means that cdk destroy will not attempt to delete
// the new bucket, and it will remain in your account until manually deleted. By setting the policy to
// DESTROY, cdk destroy will attempt to delete the bucket, but will error if the bucket is not empty.
removalPolicy: cdk.RemovalPolicy.DESTROY, // NOT recommended for production code
});
new cdk.CfnOutput(this, 'Bucket', { value: siteBucket.bucketName });

Expand Down