Skip to content

Conversation

@kpatel71716
Copy link
Collaborator

Description

Please include a summary of the fix/feature/change, including any relevant motivation and context.

Link to any related issue(s):

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@kpatel71716 kpatel71716 changed the title feat: add stream_workspace resource + ds to replace stream_instance feat: Add stream_workspace resource + ds to replace stream_instance Oct 30, 2025
@kpatel71716
Copy link
Collaborator Author

kpatel71716 commented Oct 31, 2025

Please review by individual commit to filter out all the docs updates. My thought was that we can take an initial approach to convert the stream workspace model to the stream instance model and back to reduce code duplication. Happy to take a different approach if the team does not feel comfortable with this approach

As a follow-up to this PR we can consider refactoring this approach, but for now I felt it provides functionality without making the PR too complex. I mostly copied over a lot of the stream instance code to achieve the addition of the new resource and datasource

@kpatel71716 kpatel71716 marked this pull request as ready for review October 31, 2025 13:20
@kpatel71716 kpatel71716 requested review from a team as code owners October 31, 2025 13:20
@github-actions
Copy link
Contributor

APIx bot: a message has been sent to Docs Slack channel

Copy link
Collaborator

@xargom xargom left a comment

Choose a reason for hiding this comment

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

lgtm

To migrate from `mongodbatlas_stream_instance` to `mongodbatlas_stream_workspace`, update your data source configuration:

```terraform
# Old (deprecated)
Copy link
Member

Choose a reason for hiding this comment

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

nit: have the recommended one first

Copy link
Collaborator

Choose a reason for hiding this comment

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

@kpatel71716 we usually have this as an upgrade guide doc, separated by the resource / data-source doc (but we add a link).
For example: https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/cluster-to-advanced-cluster-migration-guide (this is a bit more complex)

Copy link
Collaborator

Choose a reason for hiding this comment

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

to add: we also provide an example in the examples/ repository folder to show exactly how to upgrade


You must set the following variables:

- `atlas_client_id`: MongoDB Atlas Service Account Client ID
Copy link
Member

Choose a reason for hiding this comment

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

nit: add ending periods

}
}

type TFStreamsWorkspaceModel struct {
Copy link
Member

Choose a reason for hiding this comment

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

as it's already in package streamworkspace, we use TFModel better

}

// GetInstanceName returns the workspace name as instance name for API compatibility
func (m *TFStreamsWorkspaceModel) GetInstanceName() types.String {
Copy link
Member

Choose a reason for hiding this comment

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

I can't find where GetInstanceName or SetInstanceName are used

}

func (r *streamsWorkspaceRS) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
var streamsWorkspacePlan TFStreamsWorkspaceModel
Copy link
Member

Choose a reason for hiding this comment

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

nit: as similar comments, you can just say plan as we're already in the stream workspace package and this is even a local func var

config.RSCommon
}

func (r *streamsWorkspaceRS) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
Copy link
Member

Choose a reason for hiding this comment

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

as it's already in resource package we normally use (r *rs) for resources and (d *ds) for datasources

```

```release-note:note
data-source/mongodbatlas_stream_instance: Deprecates the `mongodbatlas_stream_instance` datasource, use `mongodbatlas_stream_workspace`
Copy link
Member

Choose a reason for hiding this comment

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

DeprecationMessage is missing in the deprecated resource/datasource schemas


# Resource: mongodbatlas_stream_instance

~> **DEPRECATED:** This resource is deprecated. Please use [`mongodbatlas_stream_workspace`](stream_workspace.md) instead.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
~> **DEPRECATED:** This resource is deprecated. Please use [`mongodbatlas_stream_workspace`](stream_workspace.md) instead.
~> **DEPRECATED:** This resource is deprecated. Please use [`mongodbatlas_stream_workspace`](stream_workspace) instead.

links in TF registry don't have .md

To migrate from `mongodbatlas_stream_instance` to `mongodbatlas_stream_workspace`, update your data source configuration:

```terraform
# Old (deprecated)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@kpatel71716 we usually have this as an upgrade guide doc, separated by the resource / data-source doc (but we add a link).
For example: https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/cluster-to-advanced-cluster-migration-guide (this is a bit more complex)

```

```release-note:note
data-source/mongodbatlas_stream_instance: Deprecates the `mongodbatlas_stream_instance` datasource, use `mongodbatlas_stream_workspace`
Copy link
Collaborator

Choose a reason for hiding this comment

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

IIUC, we're also deprecating the plural


`mongodbatlas_stream_workspaces` describes the stream workspaces defined in a project.

~> **NOTE:** This data source is an alias for `mongodbatlas_stream_instances`. Use this data source for new configurations.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do we mean with alias? It might be confusing since we're saying mongodbatlas_stream_instances is deprecated


## Migration from stream_instances

To migrate from `mongodbatlas_stream_instances` data source to `mongodbatlas_stream_workspaces`, use the following `moved` block:
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment. Make a single upgrade guide and move all this content there.

To migrate from `mongodbatlas_stream_instance` to `mongodbatlas_stream_workspace`, update your data source configuration:

```terraform
# Old (deprecated)
Copy link
Collaborator

Choose a reason for hiding this comment

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

to add: we also provide an example in the examples/ repository folder to show exactly how to upgrade


To learn more, see the [Stream Workspace Documentation](https://www.mongodb.com/docs/atlas/atlas-sp/manage-processing-instance/#configure-a-stream-processing-instance).

## Migration from stream_instance
Copy link
Collaborator

Choose a reason for hiding this comment

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

sweet!

@@ -0,0 +1,200 @@
package streamworkspace
Copy link
Collaborator

Choose a reason for hiding this comment

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

just double checking: is this a copy paste of the streaminstance file?

return
}

func (r *streamsWorkspaceRS) ValidateConfig(ctx context.Context, req resource.ValidateConfigRequest, resp *resource.ValidateConfigResponse) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see usage of this or why it would be needed

"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/streaminstance"
)

var _ resource.ResourceWithConfigure = &streamsWorkspaceRS{}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to avoid duplicating all the logic in these two resources.
I would instead abstract out the CRUD operations just after the model conversion so all the API calls and diagnostic handling is the same.
Then you can keep the streaminstance.TFModel --> steamworkspace.TFModel as a final step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants