-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Supports PRIVATE_LINK
networking type in mongodbatlas_stream_connection
resource and data sources
#2940
base: CLOUDP-288973-stream-privatelink
Are you sure you want to change the base?
Changes from 6 commits
0656bca
ea27a86
5ba7140
867de8e
9d7fc21
f7f54ef
af567c1
7c36f47
5a4dc8e
f8aa693
51afe03
ac5c75f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
resource/mongodbatlas_stream_connection: Supports Privatelink networking access type for Kafka Stream Connections | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,15 +67,16 @@ func NewStreamConnectionReq(ctx context.Context, plan *TFStreamConnectionModel) | |
} | ||
streamConnection.Networking = &admin.StreamsKafkaNetworking{ | ||
Access: &admin.StreamsKafkaNetworkingAccess{ | ||
Type: networkingModel.Access.Type.ValueStringPointer(), | ||
Type: networkingModel.Access.Type.ValueStringPointer(), | ||
ConnectionId: networkingModel.Access.ConnectionID.ValueStringPointer(), | ||
}, | ||
} | ||
} | ||
|
||
return &streamConnection, nil | ||
} | ||
|
||
func NewTFStreamConnection(ctx context.Context, projID, instanceName string, currAuthConfig *types.Object, apiResp *admin.StreamsConnection) (*TFStreamConnectionModel, diag.Diagnostics) { | ||
func NewTFStreamConnection(ctx context.Context, projID, instanceName string, currAuthConfig, currNetworkingConfig *types.Object, apiResp *admin.StreamsConnection) (*TFStreamConnectionModel, diag.Diagnostics) { | ||
EspenAlbert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rID := fmt.Sprintf("%s-%s-%s", instanceName, projID, conversion.SafeString(apiResp.Name)) | ||
connectionModel := TFStreamConnectionModel{ | ||
ID: types.StringValue(rID), | ||
|
@@ -128,9 +129,18 @@ func NewTFStreamConnection(ctx context.Context, projID, instanceName string, cur | |
|
||
connectionModel.Networking = types.ObjectNull(NetworkingObjectType.AttrTypes) | ||
if apiResp.Networking != nil { | ||
connectionID := types.StringNull() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use the apiResp.Networking? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After testing this I realized that the API does not return the ConnectionID, this will be fixed in https://jira.mongodb.org/browse/CLOUDP-294715 and meanwhile I have implemented this to be able to test and use the feature There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This extra implementation will be removed once connectionID is returned, and as you said in the other comment, this affects the import which makes the user experience lack a certain feature. Will push for this to be fixed soon |
||
if currNetworkingConfig != nil && !currNetworkingConfig.IsNull() { // if config is available (create & update of resource) connectionID value from the config is set in new state | ||
configNetworkingModel := &TFNetworkingModel{} | ||
if diags := currNetworkingConfig.As(ctx, configNetworkingModel, basetypes.ObjectAsOptions{}); diags.HasError() { | ||
return nil, diags | ||
} | ||
connectionID = configNetworkingModel.Access.ConnectionID | ||
} | ||
networkingModel, diags := types.ObjectValueFrom(ctx, NetworkingObjectType.AttrTypes, TFNetworkingModel{ | ||
Access: TFNetworkingAccessModel{ | ||
Type: types.StringPointerValue(apiResp.Networking.Access.Type), | ||
Type: types.StringPointerValue(apiResp.Networking.Access.Type), | ||
ConnectionID: connectionID, | ||
}, | ||
}) | ||
if diags.HasError() { | ||
|
@@ -175,7 +185,7 @@ func NewTFStreamConnections(ctx context.Context, | |
for i := range input { | ||
projectID := streamConnectionsConfig.ProjectID.ValueString() | ||
instanceName := streamConnectionsConfig.InstanceName.ValueString() | ||
connectionModel, diags := NewTFStreamConnection(ctx, projectID, instanceName, nil, &input[i]) | ||
connectionModel, diags := NewTFStreamConnection(ctx, projectID, instanceName, nil, nil, &input[i]) | ||
if diags.HasError() { | ||
return nil, diags | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
//nolint:gocritic | ||
package streamprivatelinkendpoint | ||
|
||
import ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about
name
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attribute exists in the API and SDK but is not a used attribute. It was created some time ago but it won't be used going forward https://jira.mongodb.org/browse/CLOUDP-294716 . When we first implemented the networking attribute for VPC peering, this attribute existed but was later removed. We removed it from the code but remained in the docs