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

[Bug]: aws_lightsail_instance, name verification always fails. #33386

Closed
TakashiAihara opened this issue Sep 10, 2023 · 6 comments · Fixed by #33405
Closed

[Bug]: aws_lightsail_instance, name verification always fails. #33386

TakashiAihara opened this issue Sep 10, 2023 · 6 comments · Fixed by #33405
Assignees
Labels
bug Addresses a defect in current functionality. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/lightsail Issues and PRs that pertain to the lightsail service.
Milestone

Comments

@TakashiAihara
Copy link

TakashiAihara commented Sep 10, 2023

Terraform Core Version

1.5.7

AWS Provider Version

5.16.1

Affected Resource(s)

  • aws_lightsail_instance

Expected Behavior

  • Successful verification.

Actual Behavior

  • Validation of "name" fails.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

provider "aws" {
  region = "eu-west-1"
}

resource "aws_lightsail_instance" "promo_site" {
  name              = "promosite"
  availability_zone = "eu-west-1a"
  blueprint_id      = "joomla_3_6_5"
  bundle_id         = "nano_1_0"
  key_pair_name     = "some_key"
}

Steps to Reproduce

$ terraform init
$ TF_LOG=DEBUG terraform validate

Debug Output

2023-09-10T03:57:02.068Z [INFO]  Terraform version: 1.5.7
2023-09-10T03:57:02.068Z [DEBUG] using github.com/hashicorp/go-tfe v1.26.0
2023-09-10T03:57:02.068Z [DEBUG] using github.com/hashicorp/hcl/v2 v2.16.2
2023-09-10T03:57:02.068Z [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.0
2023-09-10T03:57:02.068Z [DEBUG] using github.com/zclconf/go-cty v1.12.2
2023-09-10T03:57:02.068Z [INFO]  Go runtime version: go1.20.7
2023-09-10T03:57:02.068Z [INFO]  CLI args: []string{"/root/.tfenv/versions/1.5.7/terraform", "validate"}
2023-09-10T03:57:02.068Z [DEBUG] Attempting to open CLI config file: /root/.terraformrc
2023-09-10T03:57:02.068Z [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2023-09-10T03:57:02.068Z [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2023-09-10T03:57:02.068Z [DEBUG] ignoring non-existing provider search directory /root/.terraform.d/plugins
2023-09-10T03:57:02.068Z [DEBUG] ignoring non-existing provider search directory /root/.local/share/terraform/plugins
2023-09-10T03:57:02.068Z [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2023-09-10T03:57:02.068Z [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2023-09-10T03:57:02.068Z [INFO]  CLI command args: []string{"validate"}
2023-09-10T03:57:02.811Z [DEBUG] checking for provisioner in "."
2023-09-10T03:57:02.811Z [DEBUG] checking for provisioner in "/root/.tfenv/versions/1.5.7"
2023-09-10T03:57:02.811Z [DEBUG] Building and walking validate graph
2023-09-10T03:57:02.811Z [DEBUG] ProviderTransformer: "aws_lightsail_instance.promo_site" (*terraform.NodeValidatableResource) needs provider["registry.terraform.io/hashicorp/aws"]
2023-09-10T03:57:02.811Z [DEBUG] created provider logger: level=debug
2023-09-10T03:57:02.811Z [INFO]  provider: configuring client automatic mTLS
2023-09-10T03:57:02.827Z [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.16.0/linux_amd64/terraform-provider-aws_v5.16.0_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/aws/5.16.0/linux_amd64/terraform-provider-aws_v5.16.0_x5]
2023-09-10T03:57:02.828Z [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.16.0/linux_amd64/terraform-provider-aws_v5.16.0_x5 pid=112288
2023-09-10T03:57:02.828Z [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.16.0/linux_amd64/terraform-provider-aws_v5.16.0_x5
2023-09-10T03:57:02.908Z [INFO]  provider.terraform-provider-aws_v5.16.0_x5: configuring server automatic mTLS: timestamp=2023-09-10T03:57:02.908Z
2023-09-10T03:57:02.926Z [DEBUG] provider: using plugin: version=5
2023-09-10T03:57:02.926Z [DEBUG] provider.terraform-provider-aws_v5.16.0_x5: plugin address: address=/tmp/plugin3474112601 network=unix timestamp=2023-09-10T03:57:02.925Z
2023-09-10T03:57:03.534Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-09-10T03:57:03.543Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.16.0/linux_amd64/terraform-provider-aws_v5.16.0_x5 pid=112288
2023-09-10T03:57:03.543Z [DEBUG] provider: plugin exited
2023-09-10T03:57:03.543Z [DEBUG] ReferenceTransformer: "aws_lightsail_instance.promo_site" references: []
2023-09-10T03:57:03.543Z [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/hashicorp/aws\"]" references: []
2023-09-10T03:57:03.544Z [DEBUG] Starting graph walk: walkValidate
2023-09-10T03:57:03.544Z [DEBUG] created provider logger: level=debug
2023-09-10T03:57:03.544Z [INFO]  provider: configuring client automatic mTLS
2023-09-10T03:57:03.550Z [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.16.0/linux_amd64/terraform-provider-aws_v5.16.0_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/aws/5.16.0/linux_amd64/terraform-provider-aws_v5.16.0_x5]
2023-09-10T03:57:03.550Z [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.16.0/linux_amd64/terraform-provider-aws_v5.16.0_x5 pid=112312
2023-09-10T03:57:03.550Z [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.16.0/linux_amd64/terraform-provider-aws_v5.16.0_x5
2023-09-10T03:57:03.629Z [INFO]  provider.terraform-provider-aws_v5.16.0_x5: configuring server automatic mTLS: timestamp=2023-09-10T03:57:03.628Z
2023-09-10T03:57:03.645Z [DEBUG] provider: using plugin: version=5
2023-09-10T03:57:03.645Z [DEBUG] provider.terraform-provider-aws_v5.16.0_x5: plugin address: address=/tmp/plugin1207799467 network=unix timestamp=2023-09-10T03:57:03.645Z
2023-09-10T03:57:04.209Z [ERROR] provider.terraform-provider-aws_v5.16.0_x5: Response contains error diagnostic: @module=sdk.proto diagnostic_detail= diagnostic_severity=ERROR tf_req_id=30b55aff-1b74-33ea-d197-9c142e703e16 tf_resource_type=aws_lightsail_instance tf_rpc=ValidateResourceTypeConfig @caller=github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/diag/diagnostics.go:58 tf_proto_version=5.4 diagnostic_attribute=AttributeName("name") diagnostic_summary="invalid value for name (must contain only alphanumeric characters, underscores, hyphens, and dots)" tf_provider_addr=registry.terraform.io/hashicorp/aws timestamp=2023-09-10T03:57:04.209Z
2023-09-10T03:57:04.209Z [ERROR] vertex "aws_lightsail_instance.promo_site" error: invalid value for name (must contain only alphanumeric characters, underscores, hyphens, and dots)
╷
│ Error: invalid value for name (must contain only alphanumeric characters, underscores, hyphens, and dots)
│ 
│   with aws_lightsail_instance.promo_site,
│   on ai1.tf line 15, in resource "aws_lightsail_instance" "promo_site":
│   15:   name              = "promosite"
│ 
╵
2023-09-10T03:57:04.210Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-09-10T03:57:04.221Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.16.0/linux_amd64/terraform-provider-aws_v5.16.0_x5 pid=112312
2023-09-10T03:57:04.221Z [DEBUG] provider: plugin exited

Panic Output

No response

Important Factoids

Downgrade the "provider" to 5.15.0 will result in successful validation.

hoge.tf

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.15.0"
    }
  }
}

provider "aws" {
  region = "eu-west-1"
}

resource "aws_lightsail_instance" "promo_site" {
  name              = "promosite"
  availability_zone = "eu-west-1a"
  blueprint_id      = "joomla_3_6_5"
  bundle_id         = "nano_1_0"
  key_pair_name     = "some_key"
}

operation

$ rm -rf .terraform .terraform.lock.hcl
$ terraform init
$ TF_LOG=DEBUG terraform validate

output

2023-09-10T03:58:38.419Z [INFO]  Terraform version: 1.5.7
2023-09-10T03:58:38.419Z [DEBUG] using github.com/hashicorp/go-tfe v1.26.0
2023-09-10T03:58:38.419Z [DEBUG] using github.com/hashicorp/hcl/v2 v2.16.2
2023-09-10T03:58:38.419Z [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.0
2023-09-10T03:58:38.419Z [DEBUG] using github.com/zclconf/go-cty v1.12.2
2023-09-10T03:58:38.419Z [INFO]  Go runtime version: go1.20.7
2023-09-10T03:58:38.419Z [INFO]  CLI args: []string{"/root/.tfenv/versions/1.5.7/terraform", "init"}
2023-09-10T03:58:38.419Z [DEBUG] Attempting to open CLI config file: /root/.terraformrc
2023-09-10T03:58:38.419Z [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2023-09-10T03:58:38.419Z [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2023-09-10T03:58:38.419Z [DEBUG] ignoring non-existing provider search directory /root/.terraform.d/plugins
2023-09-10T03:58:38.419Z [DEBUG] ignoring non-existing provider search directory /root/.local/share/terraform/plugins
2023-09-10T03:58:38.419Z [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2023-09-10T03:58:38.419Z [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2023-09-10T03:58:38.420Z [INFO]  CLI command args: []string{"init"}

Initializing the backend...
2023-09-10T03:58:38.421Z [DEBUG] New state was assigned lineage "4b6b82c5-4d2f-0082-9182-1dc85a3b9cf5"
2023-09-10T03:58:38.421Z [DEBUG] checking for provisioner in "."
2023-09-10T03:58:38.421Z [DEBUG] checking for provisioner in "/root/.tfenv/versions/1.5.7"

Initializing provider plugins...
- Finding hashicorp/aws versions matching "5.15.0"...
2023-09-10T03:58:38.421Z [DEBUG] Service discovery for registry.terraform.io at https://registry.terraform.io/.well-known/terraform.json
2023-09-10T03:58:38.688Z [DEBUG] GET https://registry.terraform.io/v1/providers/hashicorp/aws/versions
2023-09-10T03:58:38.882Z [DEBUG] GET https://registry.terraform.io/v1/providers/hashicorp/aws/5.15.0/download/linux/amd64
2023-09-10T03:58:39.085Z [DEBUG] GET https://releases.hashicorp.com/terraform-provider-aws/5.15.0/terraform-provider-aws_5.15.0_SHA256SUMS
2023-09-10T03:58:39.360Z [DEBUG] GET https://releases.hashicorp.com/terraform-provider-aws/5.15.0/terraform-provider-aws_5.15.0_SHA256SUMS.72D7468F.sig
- Installing hashicorp/aws v5.15.0...
2023-09-10T03:58:43.503Z [DEBUG] Provider signed by 34365D9472D7468F HashiCorp Security (hashicorp.com/security) <security@hashicorp.com>
- Installed hashicorp/aws v5.15.0 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

References

No response

Would you like to implement a fix?

No

@TakashiAihara TakashiAihara added the bug Addresses a defect in current functionality. label Sep 10, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot added the service/lightsail Issues and PRs that pertain to the lightsail service. label Sep 10, 2023
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 10, 2023
@nkbud
Copy link

nkbud commented Sep 11, 2023

The regex is now: ^[0-9A-Za-z_.-]+[_.^-]$
This requires the string to end with one of: [_.^-]

I suspect the regex should be: [0-9A-Za-z_.-]+

Edit. I was wrong. See ewbankkit's comment.

@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Sep 11, 2023
@ewbankkit
Copy link
Contributor

AWS console
Screenshot 2023-09-11 at 8 01 22 AM
v5.15.0

"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]`), "must begin with an alphanumeric character"),
validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+[^._\-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
),
},

v5.16.1

"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]`), "must begin with an alphanumeric character"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
),
},

@ewbankkit
Copy link
Contributor

I believe that the problem is caused by the moving of the ^ in the final regex from the start (indicating a negated character class) into the body of the character class.

Relates #33371.
Relates #33359.

@ewbankkit ewbankkit added the regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. label Sep 11, 2023
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Sep 11, 2023
@ewbankkit ewbankkit added regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. and removed regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. labels Sep 11, 2023
@ewbankkit ewbankkit changed the title [Bug]: aws_lightsail_instance, "name" verification always fails. [Bug]: aws_lightsail_instance, name verification always fails. Sep 11, 2023
@ewbankkit ewbankkit added the regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. label Sep 11, 2023
@YakDriver YakDriver self-assigned this Sep 11, 2023
@github-actions github-actions bot added this to the v5.17.0 milestone Sep 11, 2023
@YakDriver YakDriver modified the milestones: v5.17.0, v5.16.2 Sep 11, 2023
@github-actions github-actions bot removed the bug Addresses a defect in current functionality. label Sep 11, 2023
@github-actions
Copy link

This functionality has been released in v5.16.2 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!

@github-actions
Copy link

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 Oct 12, 2023
@justinretzolk justinretzolk added the bug Addresses a defect in current functionality. label Feb 10, 2024
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. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/lightsail Issues and PRs that pertain to the lightsail service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants