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]: In aws_lightsail_instance, availability_zone is limited to those belong to the region in provider "aws" #28869

Closed
np36 opened this issue Jan 13, 2023 · 7 comments · Fixed by #30056
Labels
bug Addresses a defect in current functionality. service/lightsail Issues and PRs that pertain to the lightsail service.
Milestone

Comments

@np36
Copy link

np36 commented Jan 13, 2023

Terraform Core Version

1.3.7

AWS Provider Version

4.45.0

Affected Resource(s)

  • aws_lightsail_instance

Expected Behavior

availability_zone in aws_lightsail_instance could be set to any one that listed in Terraform Doc/aws/Resource: aws_lightsail_instance/Availability Zones:

ap-northeast-1{a,c,d}
ap-northeast-2{a,c}
ap-south-1{a,b}
ap-southeast-1{a,b,c}
ap-southeast-2{a,b,c}
ca-central-1{a,b}
eu-central-1{a,b,c}
eu-west-1{a,b,c}
eu-west-2{a,b,c}
eu-west-3{a,b,c}
us-east-1{a,b,c,d,e,f}
us-east-2{a,b,c}
us-west-2{a,b,c}

Actual Behavior

if set provider like this:

provider "aws" {
  region = "us-east-2"
}

and set aws_lightsail_instance like this:

resource "aws_lightsail_instance" "main" {
  ...
  availability_zone = "ap-northeast-2c"
  ...
}

terraform apply would complain:

Error: InvalidInputException: The given Availability Zone is invalid. 
It must be one of the following: us-east-2a,us-east-2b,us-east-2c.

Relevant Error/Panic Output Snippet

aws_lightsail_instance.main[0]: Creating...
╷
│ Error: InvalidInputException: The given Availability Zone is invalid. It must be one of the following: us-east-2a,us-east-2b,us-east-2c.
│ {
│   RespMetadata: {
│     StatusCode: 400,
│     RequestID: "xxxxxxxxxxxxxxxxx"
│   },
│   Code_: "InvalidParams",
│   Message_: "The given Availability Zone is invalid. It must be one of the following: us-east-2a,us-east-2b,us-east-2c."
│ }
│ 
│   with aws_lightsail_instance.main[0],
│   on lightsail.tf line 1, in resource "aws_lightsail_instance" "main":
│    1: resource "aws_lightsail_instance" "main" {
│

Terraform Configuration Files

provider "aws" {
  region = "us-east-2"
}

resource "aws_lightsail_instance" "main" {
  name = "example"
  availability_zone = "ap-northeast-2c"
  blueprint_id = "wordpress"
  bundle_id = "nano_2_0"
}


Steps to Reproduce

if set provider like this:

provider "aws" {
  region = "us-east-2"
}

and set aws_lightsail_instance like this:

resource "aws_lightsail_instance" "main" {
  ...
  availability_zone = "ap-northeast-2c"
  ...
}

terraform apply would complain:

Error: InvalidInputException: The given Availability Zone is invalid. 
It must be one of the following: us-east-2a,us-east-2b,us-east-2c.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@np36 np36 added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Jan 13, 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 Jan 13, 2023
@justinretzolk
Copy link
Member

Hey @np36 👋 My read on those docs is that those are the availability zones that currently support Lightsail. You could, however, utilize different regions by using provider aliasing and passing the provider meta-argument to select the provider instantiation in the appropriate region.

@justinretzolk justinretzolk added waiting-response Maintainers are waiting on response from community or contributor. and removed bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Jan 17, 2023
@gdavison gdavison added the bug Addresses a defect in current functionality. label Feb 9, 2023
@gdavison
Copy link
Contributor

gdavison commented Feb 9, 2023

We should add validation to the availability_zone parameter so that it rejects AZs from other regions.

@brittandeyoung
Copy link
Collaborator

@gdavison I am looking at providing a fix for this. How would one access the providers region within the schema?

@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Mar 15, 2023
@gdavison
Copy link
Contributor

gdavison commented Mar 15, 2023

@brittandeyoung you'll need to use a CustomizeDiff function (https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/customizing-differences) on the schema.Resource. The last parameter, of type interface{}, can be cast to a (*conns.AWSClient), which has the parameter Region.

Thanks for picking this up!

@github-actions
Copy link

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

@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 Apr 16, 2023
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. service/lightsail Issues and PRs that pertain to the lightsail service.
Projects
None yet
4 participants