Skip to content

feat: Update Stream Connection Resource#1524

Merged
ParthasarathyV merged 14 commits intomasterfrom
CLOUDP-369806-stream-connection
Jan 20, 2026
Merged

feat: Update Stream Connection Resource#1524
ParthasarathyV merged 14 commits intomasterfrom
CLOUDP-369806-stream-connection

Conversation

@sivaram-mongodb
Copy link
Copy Markdown
Contributor

@sivaram-mongodb sivaram-mongodb commented Jan 8, 2026

Proposed changes

Updated existing resource Stream Connection with significant enhancements:

  • Added support for two new connection types: AWSLambda and Https
  • Implemented OAuth (OAUTHBEARER) authentication mechanism for Kafka connections with full OAuth 2.0 flow
  • Upgraded Atlas SDK from v20231115014 to v20250312010 for latest API features
  • Added comprehensive unit test coverage with mock-based testing
  • Created 4 new CloudFormation example templates showcasing new features
  • Improved model mapping logic with proper handling of write-only sensitive fields
  • Enhanced test infrastructure with 6 complete test input sets for all connection types

cfn testing:

image

Published to AWS private registry

image

stack testing for cluster connection type :

image image

stack testing for Sample connection type:

image image

stack testing for http connection type:

image image

stack testing for aws lamda connection type:

image image

stack testing for kafka (basic) connection type:

image image image

stack testing for kafka (OAuth ) connection type:

image image image image

Jira ticket: CLOUDP-369806

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)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as
    expected)
  • This change requires a documentation update
  • 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.

Manual QA performed:

  • cfn invoke for each of CRUDL/cfn test
  • Updated resource in example
  • Published to AWS private registry
  • Used the template in example to create and update a stack in AWS
  • Deleted stack to ensure resources are deleted
  • Created multiple resources in same stack
  • Validated in Atlas UI
  • Included screenshots

Required Checklist:

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • For CFN Resources: I have released by changes in the private registry and proved by change
    works in Atlas

Further comments

@sivaram-mongodb sivaram-mongodb requested a review from a team as a code owner January 8, 2026 08:05
@sivaram-mongodb sivaram-mongodb force-pushed the CLOUDP-369806-stream-connection branch from 8d19d2f to 070e1be Compare January 8, 2026 08:36
Comment thread cfn-resources/stream-connection/cmd/resource/resource_test.go Outdated
Comment thread cfn-resources/stream-connection/cmd/resource/resource.go Outdated
Comment thread cfn-resources/stream-connection/cmd/resource/resource_test.go Outdated
Comment thread cfn-resources/stream-connection/cmd/resource/resource_test.go Outdated
Comment thread cfn-resources/stream-connection/cmd/resource/resource.go Outdated
if _, apiResp, err := conn.StreamsApi.DeleteStreamConnection(ctx, *projectID, *instanceName, *connectionName).Execute(); err != nil {
return handleError(apiResp, constants.DELETE, err)
resp, err := conn.StreamsApi.DeleteStreamConnection(ctx, *projectID, *workspaceOrInstanceName, *connectionName).Execute()
if err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the reason for this refactoring? Removing the call to handleError?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess this is handled by the @sivaram-mongodb . We have the handleError method.

model := GetStreamConnectionModel(&accumulatedStreamConns[i], nil)
model.ProjectId = currentModel.ProjectId
model.InstanceName = currentModel.InstanceName
if currentModel.WorkspaceName != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the logic behind this conditional, should't we always set it for both WorkspaceName and InstanceName?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We are setting it for both Workspace and InstanceName as suggested.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be simpler to use the workspaceOrInstanceName variable directly:

model.WorkspaceName = workspaceOrInstanceName
model.InstanceName = workspaceOrInstanceName

@sivaram-mongodb sivaram-mongodb force-pushed the CLOUDP-369806-stream-connection branch from 070e1be to 00f146f Compare January 13, 2026 09:02
@sivaram-mongodb sivaram-mongodb force-pushed the CLOUDP-369806-stream-connection branch from 00f146f to d491792 Compare January 13, 2026 11:02
@sivaram-mongodb sivaram-mongodb force-pushed the CLOUDP-369806-stream-connection branch from 3e3d371 to 372c763 Compare January 14, 2026 05:52
…nnection tests; remove resource unit tests
@sivaram-mongodb sivaram-mongodb force-pushed the CLOUDP-369806-stream-connection branch from 372c763 to 1706c15 Compare January 14, 2026 05:56
@sivaram-mongodb sivaram-mongodb marked this pull request as draft January 14, 2026 05:59
@ParthasarathyV ParthasarathyV marked this pull request as ready for review January 16, 2026 21:44
"InstanceName": {
"type": "string",
"description": "Human-readable label that identifies the stream instance."
"description": "Human-readable label that identifies the stream instance. Deprecated: Use WorkspaceName instead."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we emphasize the warning here, similar to TF messaging & referencing other CFN deprecated attributes:

"WARNING: This field is deprecated and will be removed in the next major release. Please use WorkspaceName instead" ...... "

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated InstanceName description with stronger deprecation warning: "WARNING: This field is deprecated and will be removed in the next major release. Please use WorkspaceName instead."

"/properties/ProjectId",
"/properties/ConnectionName",
"/properties/InstanceName",
"/properties/WorkspaceName",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

InstanceName would still qualify as the primaryIdentifier no?

"ConnectionName": "ConnectionNameAWSLambda",
"Type": "AWSLambda",
"Aws": {
"RoleArn": "arn:aws:iam::263641576157:role/mongodb-atlas-streams-lambda-new"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove roleArn here and from other test input files

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed hardcoded RoleArn placeholders

"ConnectionName": "ConnectionNameAWSLambda",
"Type": "AWSLambda",
"Aws": {
"RoleArn": "arn:aws:iam::263641576157:role/mongodb-atlas-streams-lambda-new-updated"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove roleArn here and from other test input files

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed hardcoded RoleArn placeholders

iamRoleNameUpdate="mongodb-atlas-streams-lambda-$(date +%s)-${RANDOM}-updated"
policyName="atlas-lambda-invoke-policy"

echo "Creating IAM roles: ${iamRoleNameCreate} and ${iamRoleNameUpdate}"
Copy link
Copy Markdown
Collaborator

@maastha maastha Jan 16, 2026

Choose a reason for hiding this comment

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

Why do we need different roles here?
For reference https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/internal/service/streamconnection/resource_stream_connection_test.go#L935 this is how we have stream connection tests setup in Terraform

I think we should be able to simplify the setup here.

Can you explain why we need all the roles and policies in this script?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Simplified IAM setup to use single role for both CREATE/UPDATE tests (removed duplicate role and Lambda permissions policy) to align with Terraform's pattern - kept only trust policy.

return nil, errEvent
}

normalizeWorkspaceName(currentModel)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: why not use getWorkspaceOrInstanceName here instead? it does mostly the same as normalizeWorkspaceName but IMO it would be clearer/more explicit what is happening

return *peErr, nil
}

workspaceOrInstanceName, peErr := getWorkspaceOrInstanceName(currentModel)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

workspace name will always be set here because InitEnvWithLatestClient has been called. Could use it directly instead of calling getWorkspaceOrInstanceName

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think you could simplify it by using directly workspace name here or not call normalizeWorkspaceName in InitEnvWithLatestClient. WDYT?
my overall feeling is that getWorkspaceOrInstanceName and normalizeWorkspaceName do very similar things and we could unify

Copy link
Copy Markdown
Contributor

@ParthasarathyV ParthasarathyV Jan 20, 2026

Choose a reason for hiding this comment

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

Agreed.

I’ve removed getWorkspaceOrInstanceName and unified the logic into normalizeWorkspaceName. After InitEnvWithLatestClient, WorkspaceName is guaranteed to be set, so all handlers now use currentModel.WorkspaceName directly. ( keeps backward compatibility with InstanceName )

Comment thread cfn-resources/stream-connection/cmd/resource/resource.go
Copy link
Copy Markdown
Collaborator

@oarbusi oarbusi left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the comments, LGTM

@ParthasarathyV ParthasarathyV added this pull request to the merge queue Jan 20, 2026
Merged via the queue into master with commit 25ac09f Jan 20, 2026
40 checks passed
@ParthasarathyV ParthasarathyV deleted the CLOUDP-369806-stream-connection branch January 20, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants