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

r/aws_lightsail_instance: Crash when adding tag with empty value #12368

Closed
ewbankkit opened this issue Mar 12, 2020 · 4 comments · Fixed by #12346 or #13868
Closed

r/aws_lightsail_instance: Crash when adding tag with empty value #12368

ewbankkit opened this issue Mar 12, 2020 · 4 comments · Fixed by #12346 or #13868
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/lightsail Issues and PRs that pertain to the lightsail service.
Milestone

Comments

@ewbankkit
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 Version

AWS provider v2.52.0.

Affected Resource(s)

  • aws_lightsail_instance

Terraform Configuration Files

resource "aws_lightsail_instance" "lightsail_instance_test" {
  name              = "terraform-test"
  availability_zone = "${data.aws_availability_zones.available.names[0]}"
  blueprint_id      = "amazon_linux"
  bundle_id         = "nano_1_0"

  tags = {
    Name = "terraform-test"
    KeyOnlyTag = ""
  }
}

Debug Output

Panic Output

aws_lightsail_instance.lightsail_instance_test: Still creating... (10s elapsed)
aws_lightsail_instance.lightsail_instance_test: Still creating... (20s elapsed)

Error: Error applying plan:

1 error occurred:
	* aws_lightsail_instance.lightsail_instance_test: 1 error occurred:
	* aws_lightsail_instance.lightsail_instance_test: unexpected EOF





Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.


panic: runtime error: invalid memory address or nil pointer dereference
2020-03-12T09:27:00.257-0400 [DEBUG] plugin.terraform-provider-aws: [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x384f82a]
2020-03-12T09:27:00.257-0400 [DEBUG] plugin.terraform-provider-aws: 
2020-03-12T09:27:00.257-0400 [DEBUG] plugin.terraform-provider-aws: goroutine 257 [running]:
2020-03-12T09:27:00.257-0400 [DEBUG] plugin.terraform-provider-aws: github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags.KeyValueTags.Map(0xc000a679b0, 0xc000a679b0)
2020-03-12T09:27:00.257-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/src/github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags/key_value_tags.go:138 +0xda
2020-03-12T09:27:00.257-0400 [DEBUG] plugin.terraform-provider-aws: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLightsailInstanceRead(0xc00039e150, 0x4df1960, 0xc000ee2500, 0x0, 0x0)
2020-03-12T09:27:00.257-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lightsail_instance.go:216 +0x6eb
2020-03-12T09:27:00.257-0400 [DEBUG] plugin.terraform-provider-aws: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLightsailInstanceCreate(0xc00039e150, 0x4df1960, 0xc000ee2500, 0xc00039e150, 0x0)
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lightsail_instance.go:170 +0x723
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc000a34b00, 0xc0001cd860, 0xc0005c1a60, 0x4df1960, 0xc000ee2500, 0xc0006ce001, 0xc000075ba8, 0x40da86)
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.7.0/helper/schema/resource.go:305 +0x365
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc000c19480, 0xc000bb8040, 0xc0001cd860, 0xc0005c1a60, 0xc000d15a70, 0xc000ce7ef0, 0x18)
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.7.0/helper/schema/provider.go:294 +0x99
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/plugin.(*ResourceProviderServer).Apply(0xc00052bd20, 0xc0005c14a0, 0xc000530400, 0x0, 0x0)
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.7.0/plugin/resource_provider.go:530 +0x57
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: reflect.Value.call(0xc000550cc0, 0xc000bcdfe8, 0x13, 0x58b4395, 0x4, 0xc000075f18, 0x3, 0x3, 0x406e9a, 0xc0003b7560, ...)
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: 	/usr/local/go/src/reflect/value.go:460 +0x5f6
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: reflect.Value.Call(0xc000550cc0, 0xc000bcdfe8, 0x13, 0xc000846718, 0x3, 0x3, 0x67569b, 0xc000ff8000, 0x0)
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: 	/usr/local/go/src/reflect/value.go:321 +0xb4
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: net/rpc.(*service).call(0xc000c9a8c0, 0xc0005179f0, 0xc0004ca0b0, 0xc0004ca0c0, 0xc000c19500, 0xc0000c1460, 0x460e900, 0xc0005c14a0, 0x16, 0x460e940, ...)
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: 	/usr/local/go/src/net/rpc/server.go:377 +0x16f
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: created by net/rpc.(*Server).ServeCodec
2020-03-12T09:27:00.258-0400 [DEBUG] plugin.terraform-provider-aws: 	/usr/local/go/src/net/rpc/server.go:474 +0x42b

Expected Behavior

Actual Behavior

Steps to Reproduce

  1. terraform apply

Important Factoids

References

First noticed by @stefansundin in #12346.

Relevant code:

https://github.com/terraform-providers/terraform-provider-aws/blob/654cc23a38444d4836155d6a2243e3976b5f3992/aws/internal/keyvaluetags/key_value_tags.go#L134-L142

@ghost ghost added service/lightsail Issues and PRs that pertain to the lightsail service. bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. labels Mar 12, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 12, 2020
@ewbankkit
Copy link
Contributor Author

ewbankkit commented Mar 12, 2020

The behaviour of empty tag values differs between AWS services, e.g. for EC2/VPC the equivalent does not crash:

resource "aws_vpc" "test" {
  cidr_block = "10.1.0.0/16"
  tags = {
    Name = "terraform-test"
    KeyOnlyTag = ""
  }
}

@bflad bflad removed the needs-triage Waiting for first response or review from a maintainer. label Mar 13, 2020
bflad added a commit that referenced this issue Jun 22, 2020
…on, fix nil value panics, implement autoscaling service tags

Reference: #12368
Reference: #13808
bflad added a commit that referenced this issue Jul 6, 2020
…on, fix nil value panics, implement autoscaling service tags

Reference: #12368
Reference: #13808
bflad added a commit that referenced this issue Aug 20, 2020
…on, fix nil value panics, implement autoscaling service tags

Reference: #12368
Reference: #13808
bflad added a commit that referenced this issue Sep 1, 2020
…on, fix nil value panics, implement autoscaling service tags

Reference: #12368
Reference: #13808
bflad added a commit that referenced this issue Sep 1, 2020
…gs and ignore_tags support in aws_autoscaling_group resource, return empty strings with key-only tags instead of panicking (#13868)

* internal/keyvaluetags: Implement support for additional tag information, fix nil value panics, implement autoscaling service tags

Reference: #12368
Reference: #13808

* resource/aws_autoscaling_group: Implement keyvaluetags and support provider ignore_tags

Reference: #13808

Output from acceptance testing:

```
--- PASS: TestAccAWSAutoScalingGroup_ALB_TargetGroups (179.86s)
--- PASS: TestAccAWSAutoScalingGroup_ALB_TargetGroups_ELBCapacity (333.20s)
--- PASS: TestAccAWSAutoScalingGroup_autoGeneratedName (51.77s)
--- PASS: TestAccAWSAutoScalingGroup_basic (240.41s)
--- PASS: TestAccAWSAutoScalingGroup_classicVpcZoneIdentifier (134.91s)
--- PASS: TestAccAWSAutoScalingGroup_enablingMetrics (177.09s)
--- PASS: TestAccAWSAutoScalingGroup_initialLifecycleHook (243.57s)
--- PASS: TestAccAWSAutoScalingGroup_launchTemplate (45.88s)
--- PASS: TestAccAWSAutoScalingGroup_LaunchTemplate_IAMInstanceProfile (58.72s)
--- PASS: TestAccAWSAutoScalingGroup_launchTemplate_update (106.61s)
--- PASS: TestAccAWSAutoScalingGroup_launchTempPartitionNum (51.25s)
--- PASS: TestAccAWSAutoScalingGroup_LoadBalancers (618.13s)
--- PASS: TestAccAWSAutoScalingGroup_MaxInstanceLifetime (165.12s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy (44.59s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_OnDemandAllocationStrategy (42.10s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_OnDemandBaseCapacity (76.16s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_OnDemandPercentageAboveBaseCapacity (47.32s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_SpotAllocationStrategy (43.62s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_SpotInstancePools (82.44s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_SpotMaxPrice (150.94s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_UpdateToZeroOnDemandBaseCapacity (78.70s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_LaunchTemplate_LaunchTemplateSpecification_LaunchTemplateName (45.47s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_LaunchTemplate_LaunchTemplateSpecification_Version (84.44s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_LaunchTemplate_Override_InstanceType (76.53s)
--- PASS: TestAccAWSAutoScalingGroup_MixedInstancesPolicy_LaunchTemplate_Override_WeightedCapacity (207.67s)
--- PASS: TestAccAWSAutoScalingGroup_namePrefix (50.25s)
--- PASS: TestAccAWSAutoScalingGroup_serviceLinkedRoleARN (54.73s)
--- PASS: TestAccAWSAutoScalingGroup_suspendingProcesses (198.11s)
--- PASS: TestAccAWSAutoScalingGroup_tags (232.54s)
--- PASS: TestAccAWSAutoScalingGroup_TargetGroupArns (247.63s)
--- PASS: TestAccAWSAutoScalingGroup_terminationPolicies (105.39s)
--- PASS: TestAccAWSAutoScalingGroup_VpcUpdates (175.27s)
--- PASS: TestAccAWSAutoScalingGroup_WithLoadBalancer (251.24s)
--- PASS: TestAccAWSAutoScalingGroup_WithLoadBalancer_ToTargetGroup (392.43s)
--- PASS: TestAccAWSAutoScalingGroup_withMetrics (81.00s)
--- PASS: TestAccAWSAutoScalingGroup_withPlacementGroup (146.95s)
```
@bflad bflad added this to the v3.5.0 milestone Sep 1, 2020
@bflad
Copy link
Contributor

bflad commented Sep 1, 2020

The fix for this has been merged and will release with version 3.5.0 of the Terraform AWS Provider, later this week.

@ghost
Copy link

ghost commented Sep 3, 2020

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

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Oct 1, 2020

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 Oct 1, 2020
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/lightsail Issues and PRs that pertain to the lightsail service.
Projects
None yet
2 participants