Robin
10/19/2021, 8:04 AMimport * as sst from "@serverless-stack/resources";
import { RemovalPolicy } from "@aws-cdk/core";
export default class MyStack extends sst.Stack {
constructor(scope, id, props) {
super(scope, id, props);
// Counter table - DynamoDB
const table = new sst.Table(this, "Counter", {
fields: {
counter: sst.TableFieldType.STRING
},
primaryIndex: { partitionKey: "counter" },
dynamodbTable: { removalPolicy: RemovalPolicy.DESTROY }
});
// Next.js app
const site = new sst.NextjsSite(this, "Site", {
path: "frontend",
environment: {
// Pass the table details
REGION: scope.region,
TABLE_NAME: table.tableName
}
});
// NextJS access perms
site.attachPermissions([table]);
// Display site URL
this.addOutputs({
URL: site.url
});
}
}
Tomasz Sobczyk
10/19/2021, 12:34 PMFrank
Frank
setDefaultRemovalPolicy
in all the SST example, or set it by default. What do u think?Robin
10/19/2021, 3:57 PMFrank
Tomasz Sobczyk
10/19/2021, 4:25 PMJay
Tomasz Sobczyk
10/19/2021, 9:48 PMRobin
10/20/2021, 1:06 PMTomasz Sobczyk
10/20/2021, 1:41 PMTomasz Sobczyk
10/20/2021, 1:41 PMTomasz Sobczyk
10/20/2021, 1:42 PMTomasz Sobczyk
10/20/2021, 1:43 PMJay
Joe Kendal
10/20/2021, 7:13 PMJoe Kendal
10/20/2021, 7:15 PMJoe Kendal
10/20/2021, 7:15 PMTomasz Sobczyk
10/20/2021, 8:05 PMTomasz Sobczyk
10/20/2021, 8:07 PMJoe Kendal
10/20/2021, 8:08 PMJoe Kendal
10/20/2021, 8:08 PMJoe Kendal
10/20/2021, 8:09 PMJoe Kendal
10/20/2021, 8:10 PMFrank
can you set removal policies per stage?Yup, you set the removal policy if
this.stage !== "prod"
, where this
is the <http://sst.App|sst.App>
object if you are doing this inside index