-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add cloud region resource #535
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "materialize_region Resource - terraform-provider-materialize" | ||
subcategory: "" | ||
description: |- | ||
The region resource allows you to manage regions in Materialize. When a new region is created, it automatically includes an 'xsmall' quickstart cluster as part of the initialization process. Users are billed for this quickstart cluster from the moment the region is created. To avoid unnecessary charges, you can connect to the new region and drop the quickstart cluster if it is not needed. Please note that disabling a region cannot be achieved directly through this provider. If you need to disable a region, contact Materialize support for assistance. This process ensures that any necessary cleanup and billing adjustments are handled properly. | ||
--- | ||
|
||
# materialize_region (Resource) | ||
|
||
The region resource allows you to manage regions in Materialize. When a new region is created, it automatically includes an 'xsmall' quickstart cluster as part of the initialization process. Users are billed for this quickstart cluster from the moment the region is created. To avoid unnecessary charges, you can connect to the new region and drop the quickstart cluster if it is not needed. Please note that disabling a region cannot be achieved directly through this provider. If you need to disable a region, contact Materialize support for assistance. This process ensures that any necessary cleanup and billing adjustments are handled properly. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "materialize_region" "example" { | ||
region_id = "aws/us-east-1" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `region_id` (String) The ID of the region to manage. Example: aws/us-west-2 | ||
|
||
### Read-Only | ||
|
||
- `enabled_at` (String) The timestamp when the region was enabled. | ||
- `http_address` (String) The HTTP address of the region. | ||
- `id` (String) The ID of this resource. | ||
- `region_state` (Boolean) The state of the region. True if enabled, false otherwise. | ||
- `resolvable` (Boolean) Indicates if the region is resolvable. | ||
- `sql_address` (String) The SQL address of the region. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# Regions can be imported using the `terraform import` command | ||
terraform import materialize_region.example_region aws/us-east-1 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Regions can be imported using the `terraform import` command | ||
terraform import materialize_region.example_region aws/us-east-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
resource "materialize_region" "example" { | ||
region_id = "aws/us-east-1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package provider | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
) | ||
|
||
func TestAccResourceRegion_basic(t *testing.T) { | ||
resourceName := "materialize_region.test" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: testAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccResourceRegionConfig(), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(resourceName, "region_id", "aws/us-east-1"), | ||
resource.TestCheckResourceAttrSet(resourceName, "sql_address"), | ||
resource.TestCheckResourceAttr(resourceName, "sql_address", "materialized:6877"), | ||
resource.TestCheckResourceAttrSet(resourceName, "http_address"), | ||
resource.TestCheckResourceAttr(resourceName, "http_address", "materialized:6875"), | ||
resource.TestCheckResourceAttr(resourceName, "resolvable", "true"), | ||
resource.TestCheckResourceAttrSet(resourceName, "enabled_at"), | ||
resource.TestCheckResourceAttr(resourceName, "region_state", "true"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccResourceRegion_update(t *testing.T) { | ||
resourceName := "materialize_region.test" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: testAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccResourceRegionConfig(), | ||
Check: resource.TestCheckResourceAttr(resourceName, "region_id", "aws/us-east-1"), | ||
}, | ||
{ | ||
Config: testAccResourceRegionConfig(), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(resourceName, "region_id", "aws/us-east-1"), | ||
resource.TestCheckResourceAttrSet(resourceName, "sql_address"), | ||
resource.TestCheckResourceAttr(resourceName, "sql_address", "materialized:6877"), | ||
resource.TestCheckResourceAttrSet(resourceName, "http_address"), | ||
resource.TestCheckResourceAttr(resourceName, "http_address", "materialized:6875"), | ||
resource.TestCheckResourceAttr(resourceName, "resolvable", "true"), | ||
resource.TestCheckResourceAttrSet(resourceName, "enabled_at"), | ||
resource.TestCheckResourceAttr(resourceName, "region_state", "true"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccResourceRegionConfig() string { | ||
return ` | ||
resource "materialize_region" "test" { | ||
region_id = "aws/us-east-1" | ||
} | ||
` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this use the frontegg client? This is the cloud region api, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think that this has been flawed from the initial implementation during the large refactor a few months ago.
As far as I can tell, the main idea seems to have been to reuse the FronteggClient's HTTPClient which already includes the Authorization token.
I'll have to refactor this. I've created an issue to track this and will submit a PR tomorrow! #543
Thanks for pointing it out!