Devin
10/28/2021, 6:32 PMnpx sst depoy --stage prod
once. After than I get barrels of cloud formation errors.Garret Harp
10/28/2021, 6:35 PMDevin
10/28/2021, 6:36 PMDevin
10/28/2021, 6:37 PMprod-hallofabandonedideas-ideasStack failed: prod-hallofabandonedideas-Ideas already exists
and errors that look like
prod-yourdomain-ideasStack | CREATE_FAILED | AWS::DynamoDB::Table | IdeasTable5FC50FD8 prod-yourdomain-Ideas already exists
Devin
10/28/2021, 6:38 PMGarret Harp
10/28/2021, 6:41 PMDevin
10/28/2021, 6:41 PMDevin
10/28/2021, 6:45 PMGarret Harp
10/28/2021, 6:49 PMimport * as sst from '@serverless-stack/resources'
import * as cdk from '@aws-cdk/core'
import * as dynamo from '@aws-cdk/aws-dynamodb'
const getFieldsAndIndexes = (input: [number, number, sst.TableFieldType][]) => {
const output: {
primaryIndex: sst.TableIndexProps
globalIndexes: Record<string, sst.TableGlobalIndexProps>
fields: Record<string, sst.TableFieldType>
} = {
primaryIndex: {
partitionKey: 'pk',
sortKey: 'sk'
},
fields: {
pk: sst.TableFieldType.STRING,
sk: sst.TableFieldType.STRING
},
globalIndexes: {}
}
for (const [start, end, fieldType] of input)
for (let i = start; i <= end; i++) {
output.globalIndexes[`gsi${i}`] = {
partitionKey: `gsi${i}pk`,
sortKey: `gsi${i}sk`
}
output.fields[`gsi${i}pk`] = sst.TableFieldType.STRING
output.fields[`gsi${i}sk`] = fieldType
}
return output
}
export default function createTable (scope: sst.Stack, fieldsAndIndexes: [number, number, sst.TableFieldType][] = []) {
return new sst.Table(scope, 'Table', {
...getFieldsAndIndexes(fieldsAndIndexes),
stream: true,
dynamodbTable: {
billingMode: dynamo.BillingMode.PAY_PER_REQUEST,
pointInTimeRecovery: scope.stage === 'production',
timeToLiveAttribute: 'ttl',
removalPolicy: scope.stage === 'production' ? cdk.RemovalPolicy.RETAIN : cdk.RemovalPolicy.DESTROY
}
})
}
Garret Harp
10/28/2021, 6:51 PMDevin
10/28/2021, 6:51 PMDevin
10/28/2021, 6:53 PMDevin
10/28/2021, 6:53 PM// Create the DynamoDB table
this.table = new sst.Table(this, "Ideas", {
fields: {
count: sst.TableFieldType.STRING,
},
primaryIndex: { partitionKey: "pk", sortKey: "sk" },
});
Devin
10/28/2021, 6:53 PMGarret Harp
10/28/2021, 6:57 PM// Create the DynamoDB table
this.table = new sst.Table(this, "Ideas", {
fields: {
pk: sst.TableFieldType.STRING,
sk: sst.TableFieldType.STRING,
count: sst.TableFieldType.STRING,
},
primaryIndex: { partitionKey: "pk", sortKey: "sk" },
});
Devin
10/28/2021, 7:26 PMDevin
10/28/2021, 8:54 PMnpx sst deploy --stage prod
and got a failure around route53
So I went in and manually removed all records for that. And then when i tried again
presto the table error is backFrank
Devin
10/28/2021, 8:58 PMDevin
10/28/2021, 8:58 PMFrank
Frank
Frank
Frank
Devin
10/28/2021, 9:02 PMI built an app that has a bucket, a table, auth, next to a custom domain. It works locally. The next app renders... Hello World
I deploy the app using sst deploy stage --prod
I decide to change the next app to say
Hello Frank
I cannot deploy because of a variety of errors. Different each time.Devin
10/28/2021, 9:03 PMFrank
Frank
Devin
10/28/2021, 9:05 PMFrank
sst build
locally and go into .build/cdk.out
and look up the newly generated template
Diff the two templates and see what changed.Devin
10/28/2021, 9:06 PMFrank
Frank
Devin
10/28/2021, 9:09 PM