@@ -20,7 +20,8 @@ const defaults = {
20
20
] ,
21
21
globalSecondaryIndexes : [ ] ,
22
22
name : null ,
23
- region : 'us-east-1'
23
+ region : 'us-east-1' ,
24
+ deletionPolicy : 'delete'
24
25
}
25
26
26
27
class AwsDynamoDb extends Component {
@@ -32,7 +33,7 @@ class AwsDynamoDb extends Component {
32
33
}
33
34
34
35
const config = mergeDeepRight ( defaults , inputs )
35
- config . name = this . name
36
+ config . name = config . name || this . name
36
37
37
38
// If first deploy and no name is found, set default name..
38
39
if ( ! config . name && ! this . state . name ) {
@@ -73,7 +74,7 @@ class AwsDynamoDb extends Component {
73
74
console . log ( `Table ${ config . name } already exists. Comparing config changes...` )
74
75
75
76
// Check region
76
- if ( config . region !== this . state . region ) {
77
+ if ( config . region && this . state . region && config . reion !== this . state . region ) {
77
78
throw new Error (
78
79
'You cannot change the region of a DynamoDB Table. Please remove it and redeploy in your desired region.'
79
80
)
@@ -103,8 +104,9 @@ class AwsDynamoDb extends Component {
103
104
console . log ( 'Removing' )
104
105
105
106
// 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 = { }
108
110
return { }
109
111
}
110
112
0 commit comments