feat: Update Stream Connection Resource#1524
Conversation
8d19d2f to
070e1be
Compare
| 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 { |
There was a problem hiding this comment.
What is the reason for this refactoring? Removing the call to handleError?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
What is the logic behind this conditional, should't we always set it for both WorkspaceName and InstanceName?
There was a problem hiding this comment.
We are setting it for both Workspace and InstanceName as suggested.
There was a problem hiding this comment.
I think it would be simpler to use the workspaceOrInstanceName variable directly:
model.WorkspaceName = workspaceOrInstanceName
model.InstanceName = workspaceOrInstanceName070e1be to
00f146f
Compare
00f146f to
d491792
Compare
…dformation-resources into CLOUDP-369806-stream-connection
3e3d371 to
372c763
Compare
…nnection tests; remove resource unit tests
372c763 to
1706c15
Compare
| "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." |
There was a problem hiding this comment.
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" ...... "
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
InstanceName would still qualify as the primaryIdentifier no?
| "ConnectionName": "ConnectionNameAWSLambda", | ||
| "Type": "AWSLambda", | ||
| "Aws": { | ||
| "RoleArn": "arn:aws:iam::263641576157:role/mongodb-atlas-streams-lambda-new" |
There was a problem hiding this comment.
remove roleArn here and from other test input files
There was a problem hiding this comment.
Removed hardcoded RoleArn placeholders
| "ConnectionName": "ConnectionNameAWSLambda", | ||
| "Type": "AWSLambda", | ||
| "Aws": { | ||
| "RoleArn": "arn:aws:iam::263641576157:role/mongodb-atlas-streams-lambda-new-updated" |
There was a problem hiding this comment.
remove roleArn here and from other test input files
There was a problem hiding this comment.
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}" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
workspace name will always be set here because InitEnvWithLatestClient has been called. Could use it directly instead of calling getWorkspaceOrInstanceName
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 )
oarbusi
left a comment
There was a problem hiding this comment.
Thanks for addressing the comments, LGTM
…dformation-resources into CLOUDP-369806-stream-connection
Proposed changes
Updated existing resource Stream Connection with significant enhancements:
cfn testing:
Published to AWS private registry
stack testing for cluster connection type :
stack testing for Sample connection type:
stack testing for http connection type:
stack testing for aws lamda connection type:
stack testing for kafka (basic) connection type:
stack testing for kafka (OAuth ) connection type:
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:
expected)
Manual QA performed:
Required Checklist:
make fmtand formatted my codeworks in Atlas
Further comments