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

Extend integration tests to run in two regions #614

Merged
merged 10 commits into from
Jul 30, 2024

Conversation

bobbyiliev
Copy link
Contributor

@bobbyiliev bobbyiliev commented Jul 19, 2024

Fixes #560

@bobbyiliev bobbyiliev requested a review from a team as a code owner July 19, 2024 13:19
@bobbyiliev bobbyiliev requested review from SangJunBak and removed request for a team July 19, 2024 13:19
@bobbyiliev bobbyiliev requested a review from arusahni July 19, 2024 13:21
Copy link

@SangJunBak SangJunBak left a comment

Choose a reason for hiding this comment

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

Code looks good to me! Unfortunate that users with multiple regions will have to duplicate a lot of their objects, but doesn't seem like there's a terraform-only solution for this.

@benesch
Copy link
Member

benesch commented Jul 29, 2024

Unfortunate that users with multiple regions will have to duplicate a lot of their objects, but doesn't seem like there's a terraform-only solution for this.

If they're looking to create the same objects in multiple regions, they can use Terraform's take on loops (count) to automatically create the same objects in multiple regions—is that the kind of thing you meant?

@bobbyiliev
Copy link
Contributor Author

Indeed, this can be done with a loop:

variable "regions" {
  type    = list(string)
  default = ["aws/us-west-2", "aws/us-east-1"]
}

resource "materialize_cluster" "multi_region_clusters" {
  count   = length(var.regions)
  name    = "cluster"
  comment = "Cluster in ${var.regions[count.index]}"
  region  = var.regions[count.index]
}

My idea behind the test here is to make sure that users can rely on the default region in their provider configuration, but also be able to spin up ad-hoc resources in different regions by overriding the default one in the resources themselves.

I think that in most cases, people only manage resources in 1 region, and if they wanted to replicate their whole setup in another region they would just change the default region provider configuration value.

@bobbyiliev bobbyiliev merged commit 73bd471 into main Jul 30, 2024
3 checks passed
@bobbyiliev bobbyiliev deleted the multi-cloud-region-tests branch July 30, 2024 13:49
@SangJunBak
Copy link

If they're looking to create the same objects in multiple regions, they can use Terraform's take on loops (count) to automatically create the same objects in multiple regions—is that the kind of thing you meant?

Something like that, but I could still see it getting messy with the count/for_each syntax. I think Bobby's solution:

I think that in most cases, people only manage resources in 1 region, and if they wanted to replicate their whole setup in another region they would just change the default region provider configuration value.

Was what I was thinking of!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests for multiple regions
3 participants