terraform-provider-aws
terraform-provider-aws copied to clipboard
[Bug]:
Terraform Core Version
1.3.3
AWS Provider Version
4.41.0
Affected Resource(s)
aws_lightsail_disk_attachment
Expected Behavior
A disk should have attached
Actual Behavior
Crashed
Relevant Error/Panic Output Snippet
tack trace from the terraform-provider-aws_v4.41.0_x5 plugin:
panic: interface conversion: interface {} is nil, not string
goroutine 514 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/lightsail.resourceDiskAttachmentCreate({0xc1e77c0, 0xc00378a7b0}, 0x0?, {0x9dd4700?, 0xc001683500?})
github.com/hashicorp/terraform-provider-aws/internal/service/lightsail/disk_attachment.go:60 +0x6a5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc1e77c0?, {0xc1e77c0?, 0xc00378a7b0?}, 0xd?, {0x9dd4700?, 0xc001683500?})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:702 +0x84
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0014fac40, {0xc1e77c0, 0xc00378a7b0}, 0xc00445c680, 0xc004420980, {0x9dd4700, 0xc001683500})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:837 +0xa85
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00012e738, {0xc1e77c0?, 0xc00378a690?}, 0xc002a2b810)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1021 +0xe8d
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ApplyResourceChange({0xc002fa1080, 0xc002fa10e0, {0xc0045ba020, 0x2, 0x2}, 0xc002fa10b0, 0xc002fca540, 0xc0040eedb0, 0xc002fa1110}, {0xc1e77c0, ...}, ...)
github.com/hashicorp/[email protected]/tf5muxserver/mux_server_ApplyResourceChange.go:27 +0x142
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc001ed8dc0, {0xc1e77c0?, 0xc00373dd70?}, 0xc0018ad500)
github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:818 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xaed6660?, 0xc001ed8dc0}, {0xc1e77c0, 0xc00373dd70}, 0xc0018ad490, 0x0)
github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc003793860, {0xc1f2040, 0xc000e72680}, 0xc004443680, 0xc00465a5d0, 0x11e1a320, 0x0)
google.golang.org/[email protected]/server.go:1340 +0xd23
google.golang.org/grpc.(*Server).handleStream(0xc003793860, {0xc1f2040, 0xc000e72680}, 0xc004443680, 0x0)
google.golang.org/[email protected]/server.go:1713 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.2()
google.golang.org/[email protected]/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/[email protected]/server.go:963 +0x28a
Error: The terraform-provider-aws_v4.41.0_x5 plugin crashed!
This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.
Terraform Configuration Files
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
required_version = ">= 1.0.0"
}
provider "aws" {
profile = "default"
region = var.aws_region
}
resource "aws_lightsail_key_pair" "pac-jenkins" {
name = "ssh-keys"
public_key = file(var.ssh_pub_key_file)
}
resource "aws_lightsail_static_ip" "pac-jenkins" {
name = "pac-jenkins"
}
resource "aws_lightsail_static_ip_attachment" "pac-jenkins" {
static_ip_name = aws_lightsail_static_ip.pac-jenkins.id
instance_name = aws_lightsail_instance.pac-jenkins.id
}
locals {
user_data_template_vars = {
aws_account_id = var.aws_account_id
aws_region = var.aws_region
jenkins_image = "${aws_ecr_repository.pac-jenkins.repository_url}:${local.image_tag}"
awscli_config = file(var.awscli_config_file)
awscli_credentials = file(var.awscli_credentials_file)
}
}
resource "aws_lightsail_instance" "pac-jenkins" {
name = "pac-jenkins-instance"
availability_zone = data.aws_availability_zones.available.names[0]
blueprint_id = "amazon_linux_2"
bundle_id = "2xlarge_2_0"
key_pair_name = aws_lightsail_key_pair.pac-jenkins.name
user_data = templatefile("${path.module}/cluster_service_user_data.sh", local.user_data_template_vars)
}
data "aws_availability_zones" "available" {
state = "available"
filter {
name = "region-name"
values = [var.aws_region]
}
filter {
name = "opt-in-status"
values = ["opt-in-not-required"]
}
}
resource "aws_lightsail_disk" "pac-jenkins-workspace" {
name = "test"
size_in_gb = 32
availability_zone = data.aws_availability_zones.available.names[0]
}
resource "aws_lightsail_disk_attachment" "test" {
disk_name = aws_lightsail_disk.pac-jenkins-workspace.name
instance_name = aws_lightsail_instance.pac-jenkins.name
disk_path = "/jenkins-home"
}
Steps to Reproduce
terraform init
terraform plan
terraform apply
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
No response
Community Note
Voting for Prioritization
- Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
- Please see our prioritization guide for information on how we prioritize.
- 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.
Volunteering to Work on This Issue
- If you are interested in working on this issue, please leave a comment.
- If this would be your first contribution, please review the contribution guide.
@benjamint-bsquare I have opened a PR that will resolve the crash you are experiencing. Basically, the crash is happening after the disk fails to attach and when its attempting to display the error returned by AWS.
This PR will not resolve your current config however. I added a test with your exact path and this is what is returned by the AWS API:
Error: AttachDisk Amazon Lightsail Disk Attachment (tf-acc-test-454657590263985767): InvalidInputException: The disk path is invalid. You must specify a valid disk path.
{
RespMetadata: {
StatusCode: 400,
RequestID: "571bffcb-ea15-46cb-9718-7a141552c1d4"
},
Code_: "InvalidParams",
Message_: "The disk path is invalid. You must specify a valid disk path."
}
```
You will need to update your path to be a valid disk path. (e.g., /dev/xvdf).
This functionality has been released in v4.49.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. Thank you!
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.