Skip to content

Commit

Permalink
Merge pull request #1 from CGreenburg/patch-1
Browse files Browse the repository at this point in the history
Updated lambda_layer_version resource
  • Loading branch information
Chad Greenburg authored Feb 10, 2020
2 parents b7f3bd2 + ef3dd30 commit 77cba27
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion aws/resource_aws_lambda_layer_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ func resourceAwsLambdaLayerVersion() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"retain": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
}
}
Expand Down Expand Up @@ -225,6 +230,12 @@ func resourceAwsLambdaLayerVersionRead(d *schema.ResourceData, meta interface{})
}

func resourceAwsLambdaLayerVersionDelete(d *schema.ResourceData, meta interface{}) error {
retain := d.Get("retain").(bool)
if retain {
log.Printf("[DEBUG] Retaining Lambda Layer %q", d.Get("arn").(string))
return nil
}

conn := meta.(*AWSClient).lambdaconn

version, err := strconv.ParseInt(d.Get("version").(string), 10, 64)
Expand All @@ -237,7 +248,7 @@ func resourceAwsLambdaLayerVersionDelete(d *schema.ResourceData, meta interface{
VersionNumber: aws.Int64(version),
})
if err != nil {
return fmt.Errorf("error deleting Lambda Layer Version (%s): %s", d.Id(), err)
return fmt.Errorf("Error deleting Lambda Layer Version (%s): %s", d.Id(), err)
}

log.Printf("[DEBUG] Lambda layer %q deleted", d.Get("arn").(string))
Expand Down

0 comments on commit 77cba27

Please sign in to comment.