Skip to content

Conversation

@kpatel71716
Copy link
Collaborator

@kpatel71716 kpatel71716 commented Oct 30, 2025

Description

CLOUDP-335390 As part of the effort to rename Atlas Stream Processing Instances to Workspaces, we are adding a new stream_workspace resource/datasource to replace stream_instance

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

Copy link
Collaborator Author

@kpatel71716 kpatel71716 left a comment

Choose a reason for hiding this comment

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

Added logical commits to refactor the docs, simplify var naming that was copy/pasted over + remove copied unused methods, and refactored the workspace/instance struct mapping logic for a better intermediate solution as we transition

@@ -0,0 +1,175 @@
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.

Filenames should not have the resource name. New convention similar to streamprocessor instead (remove stream_workspace from the name)

Comment on lines +47 to +57
streamWorkspaceReq, diags := newStreamWorkspaceCreateReq(ctx, &plan)
if diags.HasError() {
resp.Diagnostics.Append(diags...)
return
}
apiResp, _, err := connV2.StreamsApi.CreateStreamWorkspace(ctx, projectID, streamWorkspaceReq).Execute()
if err != nil {
resp.Diagnostics.AddError("error creating resource", err.Error())
return
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would try to re-use also the API calls, then we can just run instanceModel := streaminstance.Create(streamInstance, diags *diag.Diagnostics) and it returns the converted streaminstance.TFModel.
Then you can simply check diags.HasError() after call and only do the workspaceModel = FromInstanceModel(instanceModel)

Copy link
Collaborator Author

@kpatel71716 kpatel71716 Nov 5, 2025

Choose a reason for hiding this comment

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

Would this imply that we need to convert the streamWorkspace object to a streamInstance to call this? I am thinking we could create a reusable method for newStreamWorkspaceCreateReq since we don't need to pass in the entire plan and can pass individual fields instead

I am fine keeping the stream instance and stream workspace separate at that level for now. As one day we might add features to stream workspace that we don't support for stream instance. So converting to streamInstance would cause us to lose the data from the fields only supported in stream workspace

Copy link
Collaborator

@EspenAlbert EspenAlbert Nov 6, 2025

Choose a reason for hiding this comment

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

Would this imply that we need to convert the streamWorkspace object to a streamInstance to call this?

Yes.

[... one day we might add features to stream workspace that we don't support for stream instance

This makes sense. Motivation for users to change.

Feel free to resolve

Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

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

Great job! Thank you for addressing the comments 👏

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