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

Add nil check for S3 bucket metric filter #8852

Merged
merged 1 commit into from
Jun 5, 2019
Merged

Conversation

ryndaniels
Copy link
Contributor

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Fixes #8344

Release note for CHANGELOG:

BUG FIXES:
* resource/aws_s3_bucket_metric: Add a nil check for `filter` to avoid
panicking if empty

Output from acceptance testing:

$ make testacc TESTARGS="-run=TestAccAWSS3BucketMetric" 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAWSS3BucketMetric -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSS3BucketMetric_basic
=== PAUSE TestAccAWSS3BucketMetric_basic
=== RUN   TestAccAWSS3BucketMetric_WithEmptyFilter
=== PAUSE TestAccAWSS3BucketMetric_WithEmptyFilter
=== RUN   TestAccAWSS3BucketMetric_WithFilterPrefix
=== PAUSE TestAccAWSS3BucketMetric_WithFilterPrefix
=== RUN   TestAccAWSS3BucketMetric_WithFilterPrefixAndMultipleTags
=== PAUSE TestAccAWSS3BucketMetric_WithFilterPrefixAndMultipleTags
=== RUN   TestAccAWSS3BucketMetric_WithFilterPrefixAndSingleTag
=== PAUSE TestAccAWSS3BucketMetric_WithFilterPrefixAndSingleTag
=== RUN   TestAccAWSS3BucketMetric_WithFilterMultipleTags
=== PAUSE TestAccAWSS3BucketMetric_WithFilterMultipleTags
=== RUN   TestAccAWSS3BucketMetric_WithFilterSingleTag
=== PAUSE TestAccAWSS3BucketMetric_WithFilterSingleTag
=== CONT  TestAccAWSS3BucketMetric_basic
=== CONT  TestAccAWSS3BucketMetric_WithFilterSingleTag
=== CONT  TestAccAWSS3BucketMetric_WithEmptyFilter
=== CONT  TestAccAWSS3BucketMetric_WithFilterPrefix
=== CONT  TestAccAWSS3BucketMetric_WithFilterPrefixAndMultipleTags
=== CONT  TestAccAWSS3BucketMetric_WithFilterMultipleTags
=== CONT  TestAccAWSS3BucketMetric_WithFilterPrefixAndSingleTag
--- PASS: TestAccAWSS3BucketMetric_basic (61.69s)
--- PASS: TestAccAWSS3BucketMetric_WithEmptyFilter (61.76s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterPrefixAndMultipleTags (105.55s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterSingleTag (106.06s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterMultipleTags (106.78s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterPrefixAndSingleTag (106.96s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterPrefix (108.08s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       108.891s

@ghost ghost added service/s3 Issues and PRs that pertain to the s3 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/S Managed by automation to categorize the size of a PR. labels Jun 4, 2019
@ryndaniels ryndaniels requested a review from bflad June 4, 2019 09:41
@bflad bflad self-assigned this Jun 4, 2019
@bflad bflad added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. labels Jun 4, 2019
@bflad bflad added this to the v2.14.0 milestone Jun 4, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix, looks great! 🚀

Output from acceptance testing prior to code fix:

=== CONT  TestAccAWSS3BucketMetric_WithEmptyFilter
panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 467 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsS3BucketMetricPut(0xc00047c070, 0x518c200, 0xc000566c00, 0x2, 0xa898420)
	/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws-deux/aws/resource_aws_s3_bucket_metric.go:65 +0x655

Output from acceptance testing after code fix:

--- PASS: TestAccAWSS3BucketMetric_WithEmptyFilter (35.63s)
--- PASS: TestAccAWSS3BucketMetric_basic (37.45s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterPrefixAndMultipleTags (46.96s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterPrefix (49.89s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterMultipleTags (51.07s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterPrefixAndSingleTag (53.37s)
--- PASS: TestAccAWSS3BucketMetric_WithFilterSingleTag (59.45s)

@bflad bflad assigned ryndaniels and unassigned bflad Jun 4, 2019
@ryndaniels ryndaniels merged commit f15c4e1 into master Jun 5, 2019
bflad added a commit that referenced this pull request Jun 6, 2019
@bflad
Copy link
Contributor

bflad commented Jun 7, 2019

This has been released in version 2.14.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@bflad bflad deleted the rfd-bucket-nil branch June 7, 2019 12:26
@ghost
Copy link

ghost commented Nov 3, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/s3 Issues and PRs that pertain to the s3 service. size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error unexpected EOF occurs when filter, prefix, tags are missing in aws_s3_bucket_metric
2 participants