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

Updated lambda_layer_version resource #1

Merged
merged 1 commit into from
Feb 10, 2020
Merged
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
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