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

Error: Invalid address to set: []string{"ebs_block_device", "0", "tags"} #17125

Closed
devonbleak opened this issue Jan 15, 2021 · 12 comments
Closed
Assignees
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@devonbleak
Copy link
Contributor

devonbleak commented Jan 15, 2021

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 version
Terraform v0.13.5

  • provider registry.terraform.io/hashicorp/archive v2.0.0
  • provider registry.terraform.io/hashicorp/aws v3.24.0
  • provider registry.terraform.io/hashicorp/null v3.0.0
  • provider registry.terraform.io/hashicorp/template v2.2.0

Affected Resource(s)

  • aws_instance

Terraform Configuration Files

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

This seems to be related to the new tags field of the ebs_block_storage block in aws_instance resource and data source (I'm getting 9 copies of the error when I plan and I have aggregate 9 aws_instance resources and data sources in this workspace).

resource "aws_instance" "test" {
  ami           = "ami-redacted"
  instance_type = "t2.micro"

  tags = {
    Name          = "redacted"
  }
}

Debug Output

Panic Output

Expected Behavior

Plan succeeds.

Actual Behavior

Plan produces a copy of the error for each aws_instance resource and data source.

Steps to Reproduce

  1. terraform init -upgrade
  2. terraform plan

terraform refresh also produces the error.

Important Factoids

This is an existing workspace with an existing state from aws provider 3.23.0.

References

@ghost ghost added the service/ec2 Issues and PRs that pertain to the ec2 service. label Jan 15, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 15, 2021
@tdmalone
Copy link
Contributor

Also affects root_block_device in the same way.

@ewbankkit
Copy link
Contributor

Given the lack of additional context in the error message, my initial guess as to the offending code is:

func readBlockDevices(d *schema.ResourceData, instance *ec2.Instance, conn *ec2.EC2) error {
ibds, err := readBlockDevicesFromInstance(d, instance, conn)
if err != nil {
return err
}
// This handles cases where the root device block is of type "EBS"
// and #readBlockDevicesFromInstance only returns 1 reference to a block-device
// stored in ibds["root"]
if _, ok := d.GetOk("ebs_block_device"); ok {
if len(ibds["ebs"].([]map[string]interface{})) == 0 {
ebs := make(map[string]interface{})
for k, v := range ibds["root"].(map[string]interface{}) {
ebs[k] = v
}
ebs["snapshot_id"] = ibds["snapshot_id"]
ibds["ebs"] = append(ibds["ebs"].([]map[string]interface{}), ebs)
}
}
if err := d.Set("ebs_block_device", ibds["ebs"]); err != nil {
return err
}
// This handles the import case which needs to be defaulted to empty
if _, ok := d.GetOk("root_block_device"); !ok {
if err := d.Set("root_block_device", []interface{}{}); err != nil {
return err
}
}
if ibds["root"] != nil {
roots := []interface{}{ibds["root"]}
if err := d.Set("root_block_device", roots); err != nil {
return err
}
}
return nil
}

@ewbankkit ewbankkit added bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. labels Jan 15, 2021
@aglarendil
Copy link

facing the same issue with 3.24.0. 3.23.0 works well.

@aglarendil
Copy link

We have simple terraform vault provider config with s3 as backend - not even managing aws resources.

@YakDriver
Copy link
Member

We apologize for the inconvenience! We are working on this now and will have more information shortly.

@YakDriver YakDriver removed the needs-triage Waiting for first response or review from a maintainer. label Jan 15, 2021
@YakDriver
Copy link
Member

@devonbleak Can you or anyone provide more complete configuration to reproduce the problem? We are having trouble reproducing with a variety of different configurations.

@ivan-ayala-mx
Copy link

Hello

I got the similar error today.

I am using TF 0.12.29, and the code was working ok yesterday and today it started to complain about it with EC2 code:

Error: Invalid address to set: []string{"root_block_device", "0", "tags"}
Error: Invalid address to set: []string{"ebs_block_device", "0", "tags"}

@YakDriver YakDriver added this to the v3.24.1 milestone Jan 15, 2021
@YakDriver
Copy link
Member

We appreciate letting us know about this and your patience!

We are planning release 3.24.1 to address this issue. We did replicate this problem with the data source and the point release fixes the data source. However, we were never able to reproduce the problem with the aws_instance resource. We will leave this open for a few days to make sure that the point release fixes all the related issues. If not, please let us know!

@YakDriver YakDriver self-assigned this Jan 15, 2021
@breathingdust
Copy link
Member

3.24.1 has been released which included the fix for the datasource. Please let is know if you continue to see issues.

@devonbleak
Copy link
Contributor Author

@breathingdust @YakDriver confirmed this solved it for us. Apologies for the wild goose chase with the resource!

@ivan-ayala-mx
Copy link

Thank you so much. issue resolved.

@ghost
Copy link

ghost commented Feb 15, 2021

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 as resolved and limited conversation to collaborators Feb 15, 2021
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. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

7 participants