Skip to content

Commit

Permalink
Fix a panic
Browse files Browse the repository at this point in the history
Fixes hashicorp/terraform#15706. Fixes hashicorp#1314. A recent pull request hashicorp#899) accessed `lifecycleRule.Filter` without first ensuring that it is not a `nil` pointer.
  • Loading branch information
Joshua Spence authored and jocgir committed Aug 28, 2017
1 parent 7cbb808 commit 10f6d3f
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,21 +784,24 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
rule["id"] = *lifecycleRule.ID
}
filter := lifecycleRule.Filter
if filter.And != nil {
// Prefix
if filter.And.Prefix != nil && *filter.And.Prefix != "" {
rule["prefix"] = *filter.And.Prefix
}
// Tag
if len(filter.And.Tags) > 0 {
rule["tags"] = tagsToMapS3(filter.And.Tags)
}
} else {
// Prefix
if filter.Prefix != nil && *filter.Prefix != "" {
rule["prefix"] = *filter.Prefix
if filter != nil {
if filter.And != nil {
// Prefix
if filter.And.Prefix != nil && *filter.And.Prefix != "" {
rule["prefix"] = *filter.And.Prefix
}
// Tag
if len(filter.And.Tags) > 0 {
rule["tags"] = tagsToMapS3(filter.And.Tags)
}
} else {
// Prefix
if filter.Prefix != nil && *filter.Prefix != "" {
rule["prefix"] = *filter.Prefix
}
}
}

// Enabled
if lifecycleRule.Status != nil {
if *lifecycleRule.Status == s3.ExpirationStatusEnabled {
Expand Down

0 comments on commit 10f6d3f

Please sign in to comment.