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

data.aws_iam_policy_document.override_policy_documents causes panic if [""] used #24847

Closed
patdowney opened this issue May 18, 2022 · 3 comments · Fixed by #27055
Closed

data.aws_iam_policy_document.override_policy_documents causes panic if [""] used #24847

patdowney opened this issue May 18, 2022 · 3 comments · Fixed by #27055
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/iam Issues and PRs that pertain to the iam service.

Comments

@patdowney
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

 terraform-iam-test % terraform -v
Terraform v1.1.8
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v4.14.0

Affected Resource(s)

  • aws_iam_policy_document

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

provider "aws" {
  skip_metadata_api_check = true
  skip_get_ec2_platforms = true
  skip_credentials_validation = true
  skip_region_validation = true
  skip_requesting_account_id = true
}

data "aws_iam_policy_document" "test" {
  override_policy_documents = [""]
}

(Also available at https://gist.github.com/patdowney/a6f9355b7e50253116ca67f2fe4d8977#file-test-tf)

Debug Output

https://gist.github.com/patdowney/a6f9355b7e50253116ca67f2fe4d8977#file-debug-log

Panic Output

https://gist.github.com/patdowney/a6f9355b7e50253116ca67f2fe4d8977#file-crash-log

Expected Behavior

terraform should have responded with an error, like it does if [null] is used

e.g.

Error: Null value found in list
│
│   with data.aws_iam_policy_document.test,
│   on test.tf line 3, in data "aws_iam_policy_document" "test":
│    3:   override_policy_documents = [null]
│
│ Null values are not allowed for this attribute value.

Actual Behavior

terraform AWS provider crashes

Steps to Reproduce

  1. terraform plan

Important Factoids

References

  • #0000
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/iam Issues and PRs that pertain to the iam service. labels May 18, 2022
@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels May 18, 2022
@ewbankkit
Copy link
Contributor

Stack trace from the terraform-provider-aws_v4.14.0_x5 plugin:

panic: interface conversion: interface {} is nil, not string

goroutine 83 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/iam.dataSourcePolicyDocumentRead(0x68, {0x80, 0x136005b8})
data "aws_iam_policy_document" "test" {
	github.com/hashicorp/terraform-provider-aws/internal/service/iam/policy_document_data_source.go:253 +0x605
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xb0b6f00, {0xb0b6f00, 0xc002b1c330}, 0xd, {0x8b67260, 0xc000ca6000})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.16.0/helper/schema/resource.go:712 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0xc0006d0700, {0xb0b6f00, 0xc002b1c330}, 0xc002f5c980, {0x8b67260, 0xc000ca6000})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.16.0/helper/schema/resource.go:943 +0x145
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0xc00012b128, {0xb0b6e58, 0xc001192cc0}, 0xc002f20520)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.16.0/helper/schema/grpc_provider.go:1179 +0x408
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadDataSource(0xc00190edc0, {0xb0b6f00, 0xc002c8db90}, 0xc002f220a0)
	github.com/hashicorp/terraform-plugin-go@v0.9.0/tfprotov5/tf5server/server.go:657 +0x45f
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadDataSource_Handler({0x9d61ee0, 0xc00190edc0}, {0xb0b6f00, 0xc002c8db90}, 0xc002ca7020, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.9.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:421 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001fe540, {0xb1c2510, 0xc0000b2340}, 0xc002f66000, 0xc00191ac90, 0x10dafe90, 0x0)
	google.golang.org/grpc@v1.45.0/server.go:1282 +0xccf
google.golang.org/grpc.(*Server).handleStream(0xc0001fe540, {0xb1c2510, 0xc0000b2340}, 0xc002f66000, 0x0)
	google.golang.org/grpc@v1.45.0/server.go:1619 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/grpc@v1.45.0/server.go:921 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.45.0/server.go:919 +0x294

@ewbankkit ewbankkit added the crash Results from or addresses a Terraform crash or kernel panic. label May 19, 2022
@jar-b
Copy link
Member

jar-b commented Oct 3, 2022

closed by #27055

@jar-b jar-b closed this as completed Oct 3, 2022
@github-actions
Copy link

github-actions bot commented Nov 3, 2022

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 3, 2022
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/iam Issues and PRs that pertain to the iam service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants