Invalid value for name on lightsail import

Hi, i created a couple of lightsail instances manually and now trying to import them to the state file but get the below:

│ Error: invalid value for name (must contain only alphanumeric characters, underscores, hyphens, and dots)

│ with aws_lightsail_instance.totb-learning,
│ on lightsail.tf line 27, in resource “aws_lightsail_instance” “totb-learning”:
│ 27: name = “totb-learning-01”

even if i just give it a plain text signal name it comes up with the error. I can import the resource into an empty lightsail resource and then do a state show that gives me all the info i need for the required fields, but running a plan/apply just throws this error despite it being the correct name.

any ideas?

1 Like

Probably a bug in terraform-provider-aws.
We have requested a fix.
Try fixing to 5.15.0 as a workaround.

terraform {
required_providers {
aws = {
source = “hashicorp/aws”
version = “5.15.0”
}
}
}

1 Like

Sorry - i should have put the provider ver i was using as well but you were spot on, 5.16.0 has the bug but 5.15.0 worked fine.

Thanks for the help