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

r/neptune_cluster - support delete protection #11731

Merged
merged 4 commits into from
Feb 11, 2020
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
19 changes: 17 additions & 2 deletions aws/resource_aws_neptune_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func resourceAwsNeptuneCluster() *schema.Resource {

"availability_zones": {
Type: schema.TypeSet,
MaxItems: 3,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
ForceNew: true,
Expand Down Expand Up @@ -157,8 +158,11 @@ func resourceAwsNeptuneCluster() *schema.Resource {
"iam_roles": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validateArn,
},
Set: schema.HashString,
},

"iam_database_authentication_enabled": {
Expand Down Expand Up @@ -252,6 +256,10 @@ func resourceAwsNeptuneCluster() *schema.Resource {
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
},
"deletion_protection": {
Type: schema.TypeBool,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -282,13 +290,15 @@ func resourceAwsNeptuneClusterCreate(d *schema.ResourceData, meta interface{}) e
Engine: aws.String(d.Get("engine").(string)),
Port: aws.Int64(int64(d.Get("port").(int))),
StorageEncrypted: aws.Bool(d.Get("storage_encrypted").(bool)),
DeletionProtection: aws.Bool(d.Get("deletion_protection").(bool)),
Tags: tags,
}
restoreDBClusterFromSnapshotInput := &neptune.RestoreDBClusterFromSnapshotInput{
DBClusterIdentifier: aws.String(d.Get("cluster_identifier").(string)),
Engine: aws.String(d.Get("engine").(string)),
Port: aws.Int64(int64(d.Get("port").(int))),
SnapshotIdentifier: aws.String(d.Get("snapshot_identifier").(string)),
DeletionProtection: aws.Bool(d.Get("deletion_protection").(bool)),
Tags: tags,
}

Expand Down Expand Up @@ -486,6 +496,7 @@ func flattenAwsNeptuneClusterResource(d *schema.ResourceData, meta interface{},
d.Set("reader_endpoint", dbc.ReaderEndpoint)
d.Set("replication_source_identifier", dbc.ReplicationSourceIdentifier)
d.Set("storage_encrypted", dbc.StorageEncrypted)
d.Set("deletion_protection", dbc.DeletionProtection)

var sg []string
for _, g := range dbc.VpcSecurityGroups {
Expand Down Expand Up @@ -592,6 +603,10 @@ func resourceAwsNeptuneClusterUpdate(d *schema.ResourceData, meta interface{}) e
req.EnableIAMDatabaseAuthentication = aws.Bool(d.Get("iam_database_authentication_enabled").(bool))
requestUpdate = true
}
if d.HasChange("deletion_protection") {
req.DeletionProtection = aws.Bool(d.Get("deletion_protection").(bool))
requestUpdate = true
}

if requestUpdate {
err := resource.Retry(5*time.Minute, func() *resource.RetryError {
Expand Down
Loading