-
Notifications
You must be signed in to change notification settings - Fork 209
feat: Add stream_workspace resource + ds to replace stream_instance #3832
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
Open
kpatel71716
wants to merge
12
commits into
master
Choose a base branch
from
CLOUDP-335390_2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,673
−2
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0daa662
doc: add docs for new stream_workspace rs/ds to replace instance
kpatel71716 86e00a9
doc: add deprecation messaging to stream_instance docs
kpatel71716 2d37ec5
feat: add stream_workspace resource + ds to replace stream_instance
kpatel71716 740d002
doc: refactor docs + add migration guide
kpatel71716 f00236c
chore: remove var name stutter and unused code
kpatel71716 216bb8c
add MoveState impl + scheme deprecation messages
kpatel71716 f291265
remove workspace to instance mapping
kpatel71716 6c0a058
fix tf-validate
kpatel71716 b9c23b8
fix tf-validate
kpatel71716 88bfbb6
rename resource and data source files
kpatel71716 9b09791
add migration guide to data source docs
kpatel71716 b833d7f
pull in latest sdk changes
kpatel71716 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 hidden or 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,23 @@ | ||
| ```release-note:new-datasource | ||
| mongodbatlas_stream_workspace | ||
| ``` | ||
|
|
||
| ```release-note:new-datasource | ||
| mongodbatlas_stream_workspaces | ||
| ``` | ||
|
|
||
| ```release-note:new-resource | ||
| mongodbatlas_stream_workspace | ||
| ``` | ||
|
|
||
| ```release-note:note | ||
| data-source/mongodbatlas_stream_instance: Deprecates the `mongodbatlas_stream_instance` datasource, use `mongodbatlas_stream_workspace` | ||
marcosuma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| ```release-note:note | ||
| data-source/mongodbatlas_stream_instances: Deprecates the `mongodbatlas_stream_instances` datasource, use `mongodbatlas_stream_workspaces` | ||
| ``` | ||
|
|
||
| ```release-note:note | ||
| resource/mongodbatlas_stream_instance: Deprecates the `mongodbatlas_stream_instance` resource, use `mongodbatlas_stream_workspace` | ||
| ``` | ||
This file contains hidden or 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 hidden or 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 hidden or 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,45 @@ | ||
| --- | ||
| subcategory: "Streams" | ||
| --- | ||
|
|
||
| # Data Source: mongodbatlas_stream_workspace | ||
|
|
||
| `mongodbatlas_stream_workspace` describes a stream workspace that contains configurations for stream processing. | ||
|
|
||
| ~> **NOTE:** Use this data source for new configurations instead of `mongodbatlas_stream_instance`. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```terraform | ||
| data "mongodbatlas_stream_workspace" "example" { | ||
| project_id = "<PROJECT_ID>" | ||
| workspace_name = "<WORKSPACE_NAME>" | ||
| } | ||
| ``` | ||
|
|
||
| ## Migration from stream_instance | ||
|
|
||
| If you're migrating from the deprecated `mongodbatlas_stream_instance` data source, see the [Migration Guide: Stream Instance to Stream Workspace](../guides/stream-instance-to-stream-workspace-migration-guide) for step-by-step instructions and examples. | ||
|
|
||
| ## Argument Reference | ||
|
|
||
| * `project_id` - (Required) Unique 24-hexadecimal digit string that identifies your project. | ||
| * `workspace_name` - (Required) Label that identifies the stream workspace. | ||
|
|
||
| ## Attributes Reference | ||
|
|
||
| * `data_process_region` - Defines the cloud service provider and region where MongoDB Cloud performs stream processing. See [data process region](#data-process-region). | ||
| * `hostnames` - List that contains the hostnames assigned to the stream workspace. | ||
| * `stream_config` - Defines the configuration options for an Atlas Stream Processing Instance. See [stream config](#stream-config) | ||
|
|
||
|
|
||
| ### Data Process Region | ||
|
|
||
| * `cloud_provider` - Label that identifies the cloud service provider where MongoDB Cloud performs stream processing. The [MongoDB Atlas API](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Streams/operation/creategroupstreamworkspace) describes the valid values. | ||
| * `region` - Name of the cloud provider region hosting Atlas Stream Processing. The [MongoDB Atlas API](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Streams/operation/creategroupstreamworkspace) describes the valid values. | ||
|
|
||
| ### Stream Config | ||
|
|
||
| * `tier` - Selected tier for the Stream Instance. Configures Memory / VCPU allowances. The [MongoDB Atlas API](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Streams/operation/creategroupstreamworkspace) describes the valid values. | ||
|
|
||
| To learn more, see: [MongoDB Atlas API - Stream Workspace](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Streams/operation/creategroupstreamworkspace) Documentation. |
This file contains hidden or 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,55 @@ | ||
| --- | ||
| subcategory: "Streams" | ||
| --- | ||
|
|
||
| # Data Source: mongodbatlas_stream_workspaces | ||
|
|
||
| `mongodbatlas_stream_workspaces` describes the stream workspaces defined in a project. | ||
|
|
||
| ~> **NOTE:** Use this data source for new configurations instead of `mongodbatlas_stream_instances`. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```terraform | ||
| data "mongodbatlas_stream_workspaces" "test" { | ||
| project_id = "<PROJECT_ID>" | ||
| } | ||
| ``` | ||
|
|
||
| ## Migration from stream_instances | ||
|
|
||
| If you're migrating from the deprecated `mongodbatlas_stream_instances` data source, see the [Migration Guide: Stream Instance to Stream Workspace](../guides/stream-instance-to-stream-workspace-migration-guide) for step-by-step instructions and examples. | ||
|
|
||
| ## Argument Reference | ||
|
|
||
| * `project_id` - (Required) Unique 24-hexadecimal digit string that identifies your project. | ||
|
|
||
| * `page_num` - (Optional) Number of the page that displays the current set of the total objects that the response returns. Defaults to `1`. | ||
| * `items_per_page` - (Optional) Number of items that the response returns per page, up to a maximum of `500`. Defaults to `100`. | ||
|
|
||
|
|
||
| ## Attributes Reference | ||
|
|
||
| In addition to all arguments above, it also exports the following attributes: | ||
|
|
||
| * `results` - A list where each element contains a Stream Workspace. | ||
| * `total_count` - Count of the total number of items in the result set. The count might be greater than the number of objects in the results array if the entire result set is paginated. | ||
|
|
||
| ### Stream Workspace | ||
|
|
||
| * `project_id` - Unique 24-hexadecimal digit string that identifies your project. | ||
| * `workspace_name` - Label that identifies the stream workspace. | ||
| * `data_process_region` - Defines the cloud service provider and region where MongoDB Cloud performs stream processing. See [data process region](#data-process-region). | ||
| * `hostnames` - List that contains the hostnames assigned to the stream workspace. | ||
| * `stream_config` - Defines the configuration options for an Atlas Stream Processing Instance. See [stream config](#stream-config) | ||
|
|
||
| ### Data Process Region | ||
|
|
||
| * `cloud_provider` - Label that identifies the cloud service provider where MongoDB Cloud performs stream processing. The [MongoDB Atlas API](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Streams/operation/creategroupstreamworkspace) describes the valid values. | ||
| * `region` - Name of the cloud provider region hosting Atlas Stream Processing. The [MongoDB Atlas API](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Streams/operation/creategroupstreamworkspace) describes the valid values. | ||
|
|
||
| ### Stream Config | ||
|
|
||
| * `tier` - Selected tier for the Stream Workspace. Configures Memory / VCPU allowances. The [MongoDB Atlas API](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Streams/operation/creategroupstreamworkspace) describes the valid values. | ||
|
|
||
| To learn more, see: [MongoDB Atlas API - Stream Instance](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Streams/operation/creategroupstreamworkspace) Documentation. |
212 changes: 212 additions & 0 deletions
212
docs/guides/stream-instance-to-stream-workspace-migration-guide.md
This file contains hidden or 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,212 @@ | ||
| --- | ||
| page_title: "Migration Guide: Stream Instance to Stream Workspace" | ||
| --- | ||
|
|
||
| # Migration Guide: Stream Instance to Stream Workspace | ||
|
|
||
| **Objective**: This guide explains how to replace the deprecated `mongodbatlas_stream_instance` resource with the `mongodbatlas_stream_workspace` resource. For data source migrations, refer to the [output changes](#output-changes) section. | ||
|
|
||
| ## Why do we have both `mongodbatlas_stream_instance` and `mongodbatlas_stream_workspace` resources? | ||
|
|
||
| Both `mongodbatlas_stream_instance` and `mongodbatlas_stream_workspace` resources currently allow customers to manage MongoDB Atlas Stream Processing workspaces. Initially, only `mongodbatlas_stream_instance` existed. However, MongoDB Atlas has evolved its terminology and API to use "workspace" instead of "instance" for stream processing environments. To align with this change and provide a clearer, more consistent naming convention, we created the `mongodbatlas_stream_workspace` resource as a direct replacement. | ||
|
|
||
| ## If I am using `mongodbatlas_stream_instance`, why should I move to `mongodbatlas_stream_workspace`? | ||
|
|
||
| The `mongodbatlas_stream_workspace` resource provides the exact same functionality as `mongodbatlas_stream_instance` but with updated terminology that aligns with MongoDB Atlas's current naming conventions. This change provides: | ||
|
|
||
| 1. **Consistent Terminology**: Aligns with MongoDB Atlas's current documentation and UI terminology | ||
| 2. **Future-Proof**: New stream processing features will be developed using the workspace terminology | ||
| 3. **Clearer Intent**: The term "workspace" better describes the stream processing environment | ||
|
|
||
| To maintain consistency with MongoDB Atlas's terminology and ensure you're using the most current resource names, we recommend migrating to `mongodbatlas_stream_workspace`. The `mongodbatlas_stream_instance` resource is deprecated and will be removed in future major versions of the provider. | ||
|
|
||
| ## How should I move to `mongodbatlas_stream_workspace`? | ||
|
|
||
| To move from `mongodbatlas_stream_instance` to `mongodbatlas_stream_workspace` we offer two alternatives: | ||
| 1. [(Recommended) Use the `moved` block](#migration-using-the-moved-block-recommended) | ||
| 2. [Manually use the import command with the `mongodbatlas_stream_workspace` resource](#migration-using-import) | ||
|
|
||
| ### Best Practices Before Migrating | ||
|
|
||
| Before doing any migration, create a backup of your [Terraform state file](https://developer.hashicorp.com/terraform/cli/commands/state). | ||
|
|
||
| ## Migration using the Moved block (recommended) | ||
|
|
||
| This is our recommended method to migrate from `mongodbatlas_stream_instance` to `mongodbatlas_stream_workspace`. The [moved block](https://developer.hashicorp.com/terraform/language/moved) is a Terraform feature that allows to move between resource types. It's conceptually similar to running `removed` and `import` commands separately but it brings the convenience of doing it in one step. | ||
|
|
||
| **Prerequisites:** | ||
| - Terraform version 1.8 or later is required, more information in the [State Move page](https://developer.hashicorp.com/terraform/plugin/framework/resources/state-move). | ||
| - MongoDB Atlas Provider version 2.1 or later is required. | ||
|
|
||
| The basic experience when using the `moved` block is as follows: | ||
| 1. Before starting, run `terraform plan` to make sure that there are no planned changes. | ||
| 2. Add the `mongodbatlas_stream_workspace` resource definition. | ||
| 3. Comment out or delete the `mongodbatlas_stream_instance` resource definition. | ||
| 4. Update the references from your previous stream instance resource: `mongodbatlas_stream_instance.this.XXXX` to the new `mongodbatlas_stream_workspace.this.XXX`. | ||
| - Change `instance_name` to `workspace_name` in your references | ||
| - Double check [output-changes](#output-changes) to ensure the underlying configuration stays unchanged. | ||
| 5. Add the `moved` block to your configuration file, e.g.: | ||
| ```terraform | ||
| moved { | ||
| from = mongodbatlas_stream_instance.this | ||
| to = mongodbatlas_stream_workspace.this | ||
| } | ||
| ``` | ||
| 6. Run `terraform plan` and make sure that there are no planned changes, only the moved block should be shown. This is an example output of a successful plan: | ||
| ```text | ||
| # mongodbatlas_stream_instance.this has moved to mongodbatlas_stream_workspace.this | ||
| resource "mongodbatlas_stream_workspace" "this" { | ||
| workspace_name = "my-workspace" | ||
| # (6 unchanged attributes hidden) | ||
| } | ||
|
|
||
| Plan: 0 to add, 0 to change, 0 to destroy. | ||
| ``` | ||
|
|
||
| 7. Run `terraform apply` to apply the changes. The `mongodbatlas_stream_instance` resource will be removed from the Terraform state and the `mongodbatlas_stream_workspace` resource will be added. | ||
| 8. Hashicorp recommends to keep the move block in your configuration file to help track the migrations, however you can delete the `moved` block from your configuration file without any adverse impact. | ||
|
|
||
| ## Migration using import | ||
|
|
||
| **Note**: We recommend the [`moved` block](#migration-using-the-moved-block-recommended) method as it's more convenient and less error-prone. | ||
|
|
||
| This method uses [Terraform native tools](https://developer.hashicorp.com/terraform/language/import/generating-configuration) and works if you: | ||
| 1. Have an existing stream workspace without any Terraform configuration and want to import and manage it with Terraform. | ||
| 2. Have existing `mongodbatlas_stream_instance` resource(s) but you can't use the [recommended approach](#migration-using-the-moved-block-recommended). | ||
|
|
||
| The process works as follow: | ||
| 1. If you have an existing `mongodbatlas_stream_instance` resource, remove it from your configuration and delete it from the state file, e.g.: `terraform state rm mongodbatlas_stream_instance.this`. | ||
| 2. Find the import IDs of the stream workspaces you want to migrate: `{PROJECT_ID}-{WORKSPACE_NAME}`, such as `664619d870c247237f4b86a6-my-workspace` | ||
| 3. Import it using the `terraform import` command, e.g.: `terraform import mongodbatlas_stream_workspace.this 664619d870c247237f4b86a6-my-workspace`. | ||
| 4. Run `terraform plan -generate-config-out=stream_workspace.tf`. This should generate a `stream_workspace.tf` file. | ||
| 5. Update the references from your previous stream instance resource: `mongodbatlas_stream_instance.this.XXXX` to the new `mongodbatlas_stream_workspace.this.XXX`. | ||
| - Change `instance_name` to `workspace_name` in your references | ||
| - Double check [output-changes](#output-changes) to ensure the underlying configuration stays unchanged. | ||
| 6. Run `terraform apply`. You should see the resource(s) imported. | ||
|
|
||
| ## Main Changes Between `mongodbatlas_stream_instance` and `mongodbatlas_stream_workspace` | ||
|
|
||
| The primary change is the field name for identifying the stream processing workspace: | ||
|
|
||
| 1. **Field Name**: `instance_name` is replaced with `workspace_name` | ||
| 2. **Resource Name**: `mongodbatlas_stream_instance` becomes `mongodbatlas_stream_workspace` | ||
| 3. **Data Source Names**: | ||
| - `mongodbatlas_stream_instance` becomes `mongodbatlas_stream_workspace` | ||
| - `mongodbatlas_stream_instances` becomes `mongodbatlas_stream_workspaces` | ||
|
|
||
| All other functionality remains identical. | ||
|
|
||
| ### Example 1: Old Configuration (`mongodbatlas_stream_instance`) | ||
|
|
||
| ```terraform | ||
| resource "mongodbatlas_stream_instance" "this" { | ||
| project_id = var.project_id | ||
| instance_name = "my-stream-workspace" | ||
| data_process_region = { | ||
| region = "VIRGINIA_USA" | ||
| cloud_provider = "AWS" | ||
| } | ||
| } | ||
|
|
||
| data "mongodbatlas_stream_instance" "this" { | ||
| project_id = var.project_id | ||
| instance_name = mongodbatlas_stream_instance.this.instance_name | ||
| } | ||
|
|
||
| data "mongodbatlas_stream_instances" "all" { | ||
| project_id = var.project_id | ||
| } | ||
| ``` | ||
|
|
||
| ### Example 2: New Configuration (`mongodbatlas_stream_workspace`) | ||
|
|
||
| ```terraform | ||
| resource "mongodbatlas_stream_workspace" "this" { | ||
| project_id = var.project_id | ||
| workspace_name = "my-stream-workspace" | ||
| data_process_region = { | ||
| region = "VIRGINIA_USA" | ||
| cloud_provider = "AWS" | ||
| } | ||
| } | ||
|
|
||
| data "mongodbatlas_stream_workspace" "this" { | ||
| project_id = var.project_id | ||
| workspace_name = mongodbatlas_stream_workspace.this.workspace_name | ||
| } | ||
|
|
||
| data "mongodbatlas_stream_workspaces" "all" { | ||
| project_id = var.project_id | ||
| } | ||
| ``` | ||
|
|
||
| ### Output Changes | ||
|
|
||
| The only change in outputs is the field name: | ||
| - **Field Name Change**: | ||
| - Before: `mongodbatlas_stream_instance.this.instance_name` | ||
| - After: `mongodbatlas_stream_workspace.this.workspace_name` | ||
|
|
||
| All other attributes (`project_id`, `data_process_region`, `stream_config`, `hostnames`, etc.) remain exactly the same. | ||
|
|
||
| ## Complete Migration Example with Moved Block | ||
|
|
||
| Here's a complete example showing the migration process: | ||
|
|
||
| ### Step 1: Original Configuration | ||
| ```terraform | ||
| resource "mongodbatlas_stream_instance" "example" { | ||
| project_id = var.project_id | ||
| instance_name = "my-workspace" | ||
| data_process_region = { | ||
| region = "VIRGINIA_USA" | ||
| cloud_provider = "AWS" | ||
| } | ||
| } | ||
|
|
||
| output "stream_hostnames" { | ||
| value = mongodbatlas_stream_instance.example.hostnames | ||
| } | ||
| ``` | ||
|
|
||
| ### Step 2: Add Moved Block and New Resource | ||
| ```terraform | ||
| # Add the moved block | ||
| moved { | ||
| from = mongodbatlas_stream_instance.example | ||
| to = mongodbatlas_stream_workspace.example | ||
| } | ||
|
|
||
| # Replace with new resource (note: instance_name becomes workspace_name) | ||
| resource "mongodbatlas_stream_workspace" "example" { | ||
| project_id = var.project_id | ||
| workspace_name = "my-workspace" | ||
| data_process_region = { | ||
| region = "VIRGINIA_USA" | ||
| cloud_provider = "AWS" | ||
| } | ||
| } | ||
|
|
||
| # Update output references | ||
| output "stream_hostnames" { | ||
| value = mongodbatlas_stream_workspace.example.hostnames | ||
| } | ||
| ``` | ||
|
|
||
| ### Step 3: Apply and Clean Up | ||
| After running `terraform apply`, you can optionally remove the `moved` block: | ||
|
|
||
| ```terraform | ||
| resource "mongodbatlas_stream_workspace" "example" { | ||
| project_id = var.project_id | ||
| workspace_name = "my-workspace" | ||
| data_process_region = { | ||
| region = "VIRGINIA_USA" | ||
| cloud_provider = "AWS" | ||
| } | ||
| } | ||
|
|
||
| output "stream_hostnames" { | ||
| value = mongodbatlas_stream_workspace.example.hostnames | ||
| } | ||
| ``` |
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.
Uh oh!
There was an error while loading. Please reload this page.