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

resource/rds_cluster_instance: Support availability_zone #2812

Merged
merged 4 commits into from
Feb 16, 2018

Conversation

atsushi-ishibashi
Copy link
Contributor

@atsushi-ishibashi atsushi-ishibashi commented Dec 31, 2017

Closes #2642

@radeksimko radeksimko added the enhancement Requests to existing resources that expand the functionality or scope. label Jan 2, 2018
@bflad bflad added the service/rds Issues and PRs that pertain to the rds service. label Jan 28, 2018
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @atsushi-ishibashi

Do you mind adding an acceptance test which involves availability_zone set to non-empty value? e.g. first AZ from the AZ data source?

@radeksimko radeksimko added the waiting-response Maintainers are waiting on response from community or contributor. label Feb 8, 2018
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Feb 9, 2018
@atsushi-ishibashi
Copy link
Contributor Author

If I use data "aws_availability_zones", it seemed to be difficult to check resource attribute so I specified the constant.

TF_ACC=1 go test ./aws -v -run=TestAccAWSRDSClusterInstance_az -timeout 120m
=== RUN   TestAccAWSRDSClusterInstance_az
--- PASS: TestAccAWSRDSClusterInstance_az (799.15s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	799.194s

@radeksimko
Copy link
Member

@atsushi-ishibashi Thanks for the update.

I understand it's difficult to reference the resource attribute, but the problem is that this test is now pinned to us-west-2 and more importantly may not run in all accounts as AWS often assigns different AZ names to different accounts.

How do you feel about using the AZ data source? e.g.

data "aws_availability_zones" "available" {}

resource "aws_rds_cluster" "default" {
...
  availability_zones = ["${data.aws_availability_zones.available.names}"]
...
}

resource "aws_rds_cluster_instance" "cluster_instances" {
...
  availability_zone       = "${data.aws_availability_zones.available.names[0]}"
...

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Feb 16, 2018
@atsushi-ishibashi
Copy link
Contributor Author

Sure👍
But how should I write the below line? @radeksimko
https://github.com/terraform-providers/terraform-provider-aws/pull/2812/files#diff-e2a347e0fe3dfd86606d211eb111c503R66

The main purpose of this test is to confirm whether the specified az is set as availability_zone.

Check: resource.ComposeTestCheckFunc(
testAccCheckAWSClusterInstanceExists("aws_rds_cluster_instance.cluster_instances", &v),
testAccCheckAWSDBClusterInstanceAttributes(&v),
resource.TestCheckResourceAttr("aws_rds_cluster_instance.cluster_instances", "availability_zone", "us-west-2a"),
//resource.TestCheckResourceAttr("aws_rds_cluster_instance.cluster_instances", "availability_zone", "us-west-2a"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok to check this more loosely, e.g.

resource.TestMatchResourceAttr("aws_rds_cluster_instance.cluster_instances", "availability_zone", regexp.MustCompile("^us-west-2[a-z]{1}$")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it👍

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Feb 16, 2018
@atsushi-ishibashi
Copy link
Contributor Author

@radeksimko Updated👍

TF_ACC=1 go test ./aws -v -run=TestAccAWSRDSClusterInstance_az -timeout 120m
=== RUN   TestAccAWSRDSClusterInstance_az
--- PASS: TestAccAWSRDSClusterInstance_az (920.21s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	**920.255s**

@radeksimko radeksimko changed the title r/rds_cluster_instance: Support availability_zone resource/rds_cluster_instance: Support availability_zone Feb 16, 2018
@radeksimko radeksimko self-assigned this Feb 16, 2018
@radeksimko radeksimko removed the waiting-response Maintainers are waiting on response from community or contributor. label Feb 16, 2018
@radeksimko radeksimko added this to the v1.10.0 milestone Feb 16, 2018
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@radeksimko radeksimko merged commit ac13c5a into hashicorp:master Feb 16, 2018
@bflad
Copy link
Contributor

bflad commented Feb 27, 2018

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

@ghost
Copy link

ghost commented Apr 7, 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 and limited conversation to collaborators Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/rds Issues and PRs that pertain to the rds service. size/M Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: support specifying availbility_zone for aws_rds_cluster_instance
3 participants