Skip to content

Commit c4d962e

Browse files
committed
fix inputs.name, cahnge deletionPolicy to use "retain", clear state w/ "retain"
1 parent eddf0b6 commit c4d962e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

serverless.component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: aws-dynamodb
2-
version: 0.0.2
2+
version: 1.0.0
33
author: ac360
44
org: serverlessinc
55
description: Deploys A AWS DynamoDB Table

src/serverless.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const defaults = {
2020
],
2121
globalSecondaryIndexes: [],
2222
name: null,
23-
region: 'us-east-1'
23+
region: 'us-east-1',
24+
deletionPolicy: 'delete'
2425
}
2526

2627
class AwsDynamoDb extends Component {
@@ -32,7 +33,7 @@ class AwsDynamoDb extends Component {
3233
}
3334

3435
const config = mergeDeepRight(defaults, inputs)
35-
config.name = this.name
36+
config.name = config.name || this.name
3637

3738
// If first deploy and no name is found, set default name..
3839
if (!config.name && !this.state.name) {
@@ -73,7 +74,7 @@ class AwsDynamoDb extends Component {
7374
console.log(`Table ${config.name} already exists. Comparing config changes...`)
7475

7576
// Check region
76-
if (config.region !== this.state.region) {
77+
if (config.region && this.state.region && config.reion !== this.state.region) {
7778
throw new Error(
7879
'You cannot change the region of a DynamoDB Table. Please remove it and redeploy in your desired region.'
7980
)
@@ -103,8 +104,9 @@ class AwsDynamoDb extends Component {
103104
console.log('Removing')
104105

105106
// If "delete: false", don't delete the table, and warn instead
106-
if (!this.state.deletionPolicy || this.state.deletionPolicy !== 'delete') {
107-
console.log(`Skipping table removal because "deletionPolicy" is not set to "delete".`)
107+
if (this.state.deletionPolicy && this.state.deletionPolicy === 'retain') {
108+
console.log(`Skipping table removal because "deletionPolicy" is set to "retain".`)
109+
this.state = {}
108110
return {}
109111
}
110112

0 commit comments

Comments
 (0)