Skip to content

Conversation

kpatel71716
Copy link
Collaborator

@kpatel71716 kpatel71716 commented Aug 21, 2025

Description

JIRA: CLOUDP-339895, following the plan discussed with APIx team in CLOUDP-336156

As part of an ongoing effort to rename stream instances to stream workspaces, we will support a workspace_name field for the stream_connection resource and datasource that will function identically to 1instance_name`. To avoid confusion, only one of instance_name or workspace name will be allowed to be set

In a future major version of terraform, we will remove the instance_name field

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 marked this pull request as ready for review September 25, 2025 12:42
@kpatel71716 kpatel71716 requested review from a team as code owners September 25, 2025 12:42
Copy link
Contributor

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

resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.DataSourceSchemaRequest{
RequiredFields: []string{"project_id", "instance_name", "connection_name"},
RequiredFields: []string{"project_id", "connection_name"},
OverridenFields: map[string]dsschema.Attribute{
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 here with overridden?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was unnecessary. I removed it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually looks like we still need this so that terraform can use the workspace_name field in place of the instance name field. Without this we get errors due to terraform thinking that the datasource is being modified due to the mapping of the instance_name and workspace_name fields

connV2 := d.Client.AtlasV2
projectID := streamConnectionConfig.ProjectID.ValueString()
instanceName := streamConnectionConfig.InstanceName.ValueString()
effectiveWorkspaceName := getEffectiveWorkspaceName(&streamConnectionConfig)
Copy link
Collaborator

Choose a reason for hiding this comment

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

will this now fail if they pass instanceSize only?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The check below will error if workspace_name and instance_name are both undefined. If both are defined, then there will also be an error in NewTFStreamConnectionWithInstanceName

So one of workspace_name and instance_name is essentially required

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah ok, so for whoever continues to use instance_name there will be no impact, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep, that's correct!

"workspace_name": schema.StringAttribute{
Optional: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
Copy link
Member

@lantoli lantoli Sep 26, 2025

Choose a reason for hiding this comment

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

this means that if user changes workspace_name, Delete and Create will be called instead of Update.

qq: is this the behavior we want? there are 3 main alternatives:

  • Destroy and create a new resource (current approach)
  • Handle workspace_name changes in Update
  • Raise an error that workspace_name can't be updated

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Double checked and discussed with our team. This is intentional behavior. The same happens with the equivalent instance_name attribute today

@lantoli
Copy link
Member

lantoli commented Sep 26, 2025

tf-validate PR check fail will probably get fixed if you bring latest from master to this branch, there was a fix here: #3713

Copy link
Contributor

@carriecwk carriecwk left a comment

Choose a reason for hiding this comment

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

lgtm

@github-actions github-actions bot added the stale label Oct 2, 2025
@mongodb mongodb deleted a comment from github-actions bot Oct 2, 2025
@mongodb mongodb deleted a comment from github-actions bot Oct 2, 2025
@github-actions github-actions bot removed the stale label Oct 3, 2025
@kpatel71716 kpatel71716 requested a review from marcosuma October 3, 2025 07:34
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.

5 participants