Skip to content

Commit fbca024

Browse files
feat: CLOUDP-380506 Update stream connection resource (#1582)
Co-authored-by: Rakhul S Prakash <rakhul.s.prakash@peerislands.io>
1 parent 940ba27 commit fbca024

20 files changed

Lines changed: 844 additions & 64 deletions

cfn-resources/stream-connection/cmd/resource/mappings.go

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,24 @@ import (
2121
)
2222

2323
func GetStreamConnectionModel(streamsConn *admin.StreamsConnection, currentModel *Model) *Model {
24-
var model *Model
24+
model := new(Model)
2525

2626
if currentModel != nil {
27-
model = currentModel
27+
model.ProjectId = currentModel.ProjectId
28+
model.Profile = currentModel.Profile
29+
model.WorkspaceName = currentModel.WorkspaceName
30+
model.InstanceName = currentModel.InstanceName
2831
if model.WorkspaceName == nil && model.InstanceName != nil && *model.InstanceName != "" {
2932
model.WorkspaceName = model.InstanceName
3033
}
31-
} else {
32-
model = new(Model)
3334
}
3435

3536
model.ConnectionName = streamsConn.Name
3637
model.Type = streamsConn.Type
3738
model.ClusterName = streamsConn.ClusterName
38-
if streamsConn.ClusterGroupId != nil {
39-
model.ClusterProjectId = streamsConn.ClusterGroupId
40-
}
39+
model.ClusterProjectId = streamsConn.ClusterGroupId
4140
model.BootstrapServers = streamsConn.BootstrapServers
42-
if streamsConn.Url != nil {
43-
model.Url = streamsConn.Url
44-
}
41+
model.Url = streamsConn.Url
4542

4643
model.DbRoleToExecute = NewModelDBRoleToExecute(streamsConn.DbRoleToExecute)
4744

@@ -62,6 +59,8 @@ func GetStreamConnectionModel(streamsConn *admin.StreamsConnection, currentModel
6259
Access: &Access{
6360
Type: streamsConn.Networking.Access.Type,
6461
ConnectionId: streamsConn.Networking.Access.ConnectionId,
62+
Name: streamsConn.Networking.Access.Name,
63+
TgwRouteId: streamsConn.Networking.Access.TgwRouteId,
6564
},
6665
}
6766
}
@@ -72,6 +71,30 @@ func GetStreamConnectionModel(streamsConn *admin.StreamsConnection, currentModel
7271
}
7372
}
7473

74+
if streamsConn.Provider != nil {
75+
model.Provider = streamsConn.Provider
76+
} else if currentModel != nil {
77+
model.Provider = currentModel.Provider
78+
}
79+
80+
if streamsConn.SchemaRegistryAuthentication != nil {
81+
model.SchemaRegistryAuthentication = &SchemaRegistryAuthentication{
82+
Type: &streamsConn.SchemaRegistryAuthentication.Type,
83+
Username: streamsConn.SchemaRegistryAuthentication.Username,
84+
}
85+
} else if currentModel != nil && currentModel.SchemaRegistryAuthentication != nil {
86+
model.SchemaRegistryAuthentication = &SchemaRegistryAuthentication{
87+
Type: currentModel.SchemaRegistryAuthentication.Type,
88+
Username: currentModel.SchemaRegistryAuthentication.Username,
89+
}
90+
}
91+
92+
if streamsConn.SchemaRegistryUrls != nil {
93+
model.SchemaRegistryUrls = *streamsConn.SchemaRegistryUrls
94+
} else if currentModel != nil {
95+
model.SchemaRegistryUrls = currentModel.SchemaRegistryUrls
96+
}
97+
7598
return model
7699
}
77100

@@ -145,6 +168,8 @@ func newStreamConnectionReq(model *Model) *admin.StreamsConnection {
145168
Access: &admin.StreamsKafkaNetworkingAccess{
146169
Type: model.Networking.Access.Type,
147170
ConnectionId: model.Networking.Access.ConnectionId,
171+
Name: model.Networking.Access.Name,
172+
TgwRouteId: model.Networking.Access.TgwRouteId,
148173
},
149174
}
150175
}
@@ -153,7 +178,8 @@ func newStreamConnectionReq(model *Model) *admin.StreamsConnection {
153178
if typeStr == AWSLambdaType {
154179
if model.Aws != nil {
155180
streamConnReq.Aws = &admin.StreamsAWSConnectionConfig{
156-
RoleArn: model.Aws.RoleArn,
181+
RoleArn: model.Aws.RoleArn,
182+
TestBucket: model.Aws.TestBucket,
157183
}
158184
}
159185
}
@@ -165,6 +191,20 @@ func newStreamConnectionReq(model *Model) *admin.StreamsConnection {
165191
}
166192
}
167193

194+
if typeStr == SchemaRegistryType {
195+
streamConnReq.Provider = model.Provider
196+
if model.SchemaRegistryAuthentication != nil {
197+
streamConnReq.SchemaRegistryAuthentication = &admin.SchemaRegistryAuthentication{
198+
Type: util.SafeString(model.SchemaRegistryAuthentication.Type),
199+
Username: model.SchemaRegistryAuthentication.Username,
200+
Password: model.SchemaRegistryAuthentication.Password,
201+
}
202+
}
203+
if len(model.SchemaRegistryUrls) > 0 {
204+
streamConnReq.SchemaRegistryUrls = &model.SchemaRegistryUrls
205+
}
206+
}
207+
168208
return &streamConnReq
169209
}
170210

@@ -205,5 +245,8 @@ func newStreamsKafkaAuthentication(authenticationModel *StreamsKafkaAuthenticati
205245
ClientSecret: authenticationModel.ClientSecret,
206246
Scope: authenticationModel.Scope,
207247
SaslOauthbearerExtensions: authenticationModel.SaslOauthbearerExtensions,
248+
SslCertificate: authenticationModel.SslCertificate,
249+
SslKey: authenticationModel.SslKey,
250+
SslKeyPassword: authenticationModel.SslKeyPassword,
208251
}
209252
}

cfn-resources/stream-connection/cmd/resource/model.go

Lines changed: 34 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cfn-resources/stream-connection/cmd/resource/resource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const (
3535
KafkaConnectionType = "Kafka"
3636
AWSLambdaType = "AWSLambda"
3737
HTTPSType = "Https"
38+
SchemaRegistryType = "SchemaRegistry"
3839
)
3940

4041
var CreateRequiredFields = []string{constants.ProjectID, constants.ConnectionName, constants.Type}

cfn-resources/stream-connection/docs/README.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ To declare this entity in your AWS CloudFormation template, use the following sy
2828
"<a href="#networking" title="Networking">Networking</a>" : <i><a href="networking.md">Networking</a></i>,
2929
"<a href="#aws" title="Aws">Aws</a>" : <i><a href="aws.md">Aws</a></i>,
3030
"<a href="#url" title="Url">Url</a>" : <i>String</i>,
31-
"<a href="#headers" title="Headers">Headers</a>" : <i><a href="headers.md">Headers</a></i>
31+
"<a href="#headers" title="Headers">Headers</a>" : <i><a href="headers.md">Headers</a></i>,
32+
"<a href="#provider" title="Provider">Provider</a>" : <i>String</i>,
33+
"<a href="#schemaregistryauthentication" title="SchemaRegistryAuthentication">SchemaRegistryAuthentication</a>" : <i><a href="schemaregistryauthentication.md">SchemaRegistryAuthentication</a></i>,
34+
"<a href="#schemaregistryurls" title="SchemaRegistryUrls">SchemaRegistryUrls</a>" : <i>[ String, ... ]</i>
3235
}
3336
}
3437
</pre>
@@ -55,6 +58,10 @@ Properties:
5558
<a href="#aws" title="Aws">Aws</a>: <i><a href="aws.md">Aws</a></i>
5659
<a href="#url" title="Url">Url</a>: <i>String</i>
5760
<a href="#headers" title="Headers">Headers</a>: <i><a href="headers.md">Headers</a></i>
61+
<a href="#provider" title="Provider">Provider</a>: <i>String</i>
62+
<a href="#schemaregistryauthentication" title="SchemaRegistryAuthentication">SchemaRegistryAuthentication</a>: <i><a href="schemaregistryauthentication.md">SchemaRegistryAuthentication</a></i>
63+
<a href="#schemaregistryurls" title="SchemaRegistryUrls">SchemaRegistryUrls</a>: <i>
64+
- String</i>
5865
</pre>
5966

6067
## Properties
@@ -99,7 +106,7 @@ _Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/l
99106

100107
#### InstanceName
101108

102-
Human-readable label that identifies the stream instance. Deprecated: Use WorkspaceName instead.
109+
Human-readable label that identifies the stream instance. WARNING: This field is deprecated and will be removed in the next major release. Please use WorkspaceName instead.
103110

104111
_Required_: No
105112

@@ -207,7 +214,7 @@ _Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormati
207214

208215
#### Networking
209216

210-
Networking configuration for AWS PrivateLink connections.
217+
Networking configuration for connections.
211218

212219
_Required_: No
213220

@@ -245,3 +252,33 @@ _Type_: <a href="headers.md">Headers</a>
245252

246253
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
247254

255+
#### Provider
256+
257+
The Schema Registry provider.
258+
259+
_Required_: No
260+
261+
_Type_: String
262+
263+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
264+
265+
#### SchemaRegistryAuthentication
266+
267+
Authentication configuration for Schema Registry.
268+
269+
_Required_: No
270+
271+
_Type_: <a href="schemaregistryauthentication.md">SchemaRegistryAuthentication</a>
272+
273+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
274+
275+
#### SchemaRegistryUrls
276+
277+
List of Schema Registry endpoint URLs. Each URL must use the http or https scheme and specify a valid host and optional port.
278+
279+
_Required_: No
280+
281+
_Type_: List of String
282+
283+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
284+

cfn-resources/stream-connection/docs/aws.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ To declare this entity in your AWS CloudFormation template, use the following sy
1010

1111
<pre>
1212
{
13-
"<a href="#rolearn" title="RoleArn">RoleArn</a>" : <i>String</i>
13+
"<a href="#rolearn" title="RoleArn">RoleArn</a>" : <i>String</i>,
14+
"<a href="#testbucket" title="TestBucket">TestBucket</a>" : <i>String</i>
1415
}
1516
</pre>
1617

1718
### YAML
1819

1920
<pre>
2021
<a href="#rolearn" title="RoleArn">RoleArn</a>: <i>String</i>
22+
<a href="#testbucket" title="TestBucket">TestBucket</a>: <i>String</i>
2123
</pre>
2224

2325
## Properties
@@ -32,3 +34,13 @@ _Type_: String
3234

3335
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
3436

37+
#### TestBucket
38+
39+
The name of an S3 bucket used to check authorization of the passed-in IAM role ARN.
40+
41+
_Required_: No
42+
43+
_Type_: String
44+
45+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
46+

cfn-resources/stream-connection/docs/networking.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MongoDB::Atlas::StreamConnection Networking
22

3-
Networking configuration for AWS PrivateLink connections.
3+
Networking configuration for connections.
44

55
## Syntax
66

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# MongoDB::Atlas::StreamConnection SchemaRegistryAuthentication
2+
3+
Authentication configuration for Schema Registry.
4+
5+
## Syntax
6+
7+
To declare this entity in your AWS CloudFormation template, use the following syntax:
8+
9+
### JSON
10+
11+
<pre>
12+
{
13+
"<a href="#type" title="Type">Type</a>" : <i>String</i>,
14+
"<a href="#username" title="Username">Username</a>" : <i>String</i>,
15+
"<a href="#password" title="Password">Password</a>" : <i>String</i>
16+
}
17+
</pre>
18+
19+
### YAML
20+
21+
<pre>
22+
<a href="#type" title="Type">Type</a>: <i>String</i>
23+
<a href="#username" title="Username">Username</a>: <i>String</i>
24+
<a href="#password" title="Password">Password</a>: <i>String</i>
25+
</pre>
26+
27+
## Properties
28+
29+
#### Type
30+
31+
Authentication type discriminator. Specifies the authentication mechanism for Schema Registry.
32+
33+
_Required_: No
34+
35+
_Type_: String
36+
37+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
38+
39+
#### Username
40+
41+
Username or Public Key for authentication.
42+
43+
_Required_: No
44+
45+
_Type_: String
46+
47+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
48+
49+
#### Password
50+
51+
Password or Private Key for authentication. Review [AWS security best practices for CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/security-best-practices.html#creds) to manage credentials.
52+
53+
_Required_: No
54+
55+
_Type_: String
56+
57+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
58+

0 commit comments

Comments
 (0)