Skip to content

Commit 0a2ae66

Browse files
feat: Supports new AWSLambda connection type in streams processing (#3085)
* feat: Supports new AWSLambda connection type in streams processing * feat: renaming and adding acc tests * feat: add change log * feat: minor change * feat: add env vars to GH workflow * CLOUDP-300287: merge master * CLOUDP-300287: merge master * CLOUDP-300287: merge master * CLOUDP-300287: fix doc per comment * changelog * fix example * trigger test fix * Trigger Build * fix workflow * CLOUDP-300287: fix lint error * CLOUDP-300287: test accpt test * CLOUDP-300287: test accpt test * CLOUDP-300287: test accpt test * CLOUDP-300287: test accpt test * CLOUDP-300287: test accpt test * fix acc test * don't hardcode project * CLOUDP-300287: refactor by comments * CLOUDP-300287: refactor by comments * CLOUDP-300287: refactor by comments * CLOUDP-300287: refactor by comments --------- Co-authored-by: Oriol Arbusi <[email protected]>
1 parent a66d3a3 commit 0a2ae66

File tree

13 files changed

+249
-8
lines changed

13 files changed

+249
-8
lines changed

.changelog/3085.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:enhancement
2+
resource/mongodbatlas_stream_connection: Adds `AWSLambda` connection
3+
```
4+
5+
```release-note:enhancement
6+
data-source/mongodbatlas_stream_connection: Adds `AWSLambda` connection
7+
```

.github/workflows/acceptance-tests-runner.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ on:
115115
mongodb_atlas_project_ear_pe_aws_id:
116116
type: string
117117
required: true
118+
mongodb_atlas_asp_project_ear_pe_id:
119+
type: string
120+
required: true
121+
mongodb_atlas_asp_project_aws_role_arn:
122+
type: string
123+
required: true
118124
secrets: # all secrets are passed explicitly in this workflow
119125
mongodb_atlas_public_key:
120126
required: true
@@ -646,6 +652,8 @@ jobs:
646652
AWS_CUSTOMER_MASTER_KEY_ID: ${{ secrets.aws_customer_master_key_id }}
647653
MONGODB_ATLAS_PROJECT_EAR_PE_AWS_ID: ${{ inputs.mongodb_atlas_project_ear_pe_aws_id }}
648654
AWS_EAR_ROLE_ID: ${{ inputs.aws_ear_role_id }}
655+
MONGODB_ATLAS_ASP_PROJECT_EAR_PE_ID: ${{ inputs.mongodb_atlas_asp_project_ear_pe_id }}
656+
MONGODB_ATLAS_ASP_PROJECT_AWS_ROLE_ARN: ${{ inputs.mongodb_atlas_asp_project_aws_role_arn }}
649657
run: make testacc
650658

651659
event_trigger:
@@ -1063,6 +1071,8 @@ jobs:
10631071
AWS_REGION: ${{ vars.AWS_REGION }}
10641072
AWS_VPC_CIDR_BLOCK: ${{ vars.AWS_VPC_CIDR_BLOCK }}
10651073
AWS_VPC_ID: ${{ vars.AWS_VPC_ID }}
1074+
MONGODB_ATLAS_ASP_PROJECT_AWS_ROLE_ARN: ${{ inputs.mongodb_atlas_asp_project_aws_role_arn }}
1075+
MONGODB_ATLAS_ASP_PROJECT_EAR_PE_ID: ${{ inputs.mongodb_atlas_asp_project_ear_pe_id }}
10661076
ACCTEST_PACKAGES: |
10671077
./internal/service/streamconnection
10681078
./internal/service/streaminstance

.github/workflows/acceptance-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,6 @@ jobs:
130130
mongodb_atlas_rp_org_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_RP_ORG_ID_QA || vars.MONGODB_ATLAS_RP_ORG_ID_DEV }}
131131
mongodb_atlas_flex_project_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FLEX_PROJECT_ID_QA || vars.MONGODB_ATLAS_FLEX_PROJECT_ID }}
132132
confluent_cloud_network_id: ${{ vars.CONFLUENT_CLOUD_NETWORK_ID }}
133-
confluent_cloud_privatelink_access_id: ${{ vars.CONFLUENT_CLOUD_PRIVATELINK_ACCESS_ID }}
133+
confluent_cloud_privatelink_access_id: ${{ vars.CONFLUENT_CLOUD_PRIVATELINK_ACCESS_ID }}
134+
mongodb_atlas_asp_project_ear_pe_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_ASP_PROJECT_EAR_PE_ID_QA || vars.MONGODB_ATLAS_ASP_PROJECT_EAR_PE_ID_DEV }}
135+
mongodb_atlas_asp_project_aws_role_arn: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_ASP_PROJECT_AWS_ROLE_ARN_QA || vars.MONGODB_ATLAS_ASP_PROJECT_AWS_ROLE_ARN_DEV }}

.github/workflows/code-health.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ on:
99
- '*.md'
1010
- 'examples/**'
1111
- 'LICENSE'
12-
pull_request: {}
13-
workflow_dispatch: {}
12+
pull_request:
13+
workflow_dispatch:
1414

1515
jobs:
1616
build:

docs/data-sources/stream_connection.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ data "mongodbatlas_stream_connection" "example" {
2020

2121
## Attributes Reference
2222

23-
* `type` - Type of connection. Can be either `Cluster`, `Kafka` or `Sample`.
23+
* `type` - Type of connection. Can be `Cluster`, `Kafka`, `Sample`, or `AWSLambda`.
2424

2525
If `type` is of value `Cluster` the following additional attributes are defined:
2626
* `cluster_name` - Name of the cluster configured for this connection.
@@ -33,6 +33,9 @@ If `type` is of value `Kafka` the following additional attributes are defined:
3333
* `security` - Properties for the secure transport connection to Kafka. For SSL, this can include the trusted certificate to use. See [security](#security).
3434
* `networking` - Networking Access Type can either be `PUBLIC` (default) or `VPC`. See [networking](#networking).
3535

36+
If `type` is of value `AWSLambda` the following additional attributes are defined:
37+
* `aws` - The configuration for AWS Lambda connection. See [AWS](#AWS)
38+
3639
### Authentication
3740

3841
* `mechanism` - Style of authentication. Can be one of `PLAIN`, `SCRAM-256`, or `SCRAM-512`.
@@ -56,5 +59,8 @@ If `type` is of value `Kafka` the following additional attributes are defined:
5659
* `type` - Selected networking type. Either `PUBLIC`, `VPC` or `PRIVATE_LINK`. Defaults to `PUBLIC`.
5760
* `connection_id` - Id of the Private Link connection when type is `PRIVATE_LINK`.
5861

62+
### AWS
63+
* `role_arn` - Amazon Resource Name (ARN) that identifies the Amazon Web Services (AWS) Identity and Access Management (IAM) role that MongoDB Cloud assumes when it accesses resources in your AWS account.
64+
5965
To learn more, see: [MongoDB Atlas API - Stream Connection](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Streams/operation/getStreamConnection) Documentation.
6066
The [Terraform Provider Examples Section](https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/examples/mongodbatlas_stream_instance/atlas-streams-user-journey.md) also contains details on the overall support for Atlas Streams Processing in Terraform.

docs/data-sources/stream_connections.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ In addition to all arguments above, it also exports the following attributes:
3232
* `project_id` - Unique 24-hexadecimal digit string that identifies your project.
3333
* `instance_name` - Human-readable label that identifies the stream instance.
3434
* `connection_name` - Human-readable label that identifies the stream connection. In the case of the Sample type, this is the name of the sample source.
35-
* `type` - Type of connection. Can be either `Cluster`, `Kafka` or `Sample`.
35+
* `type` - Type of connection. `Cluster`, `Kafka`, `Sample`, or `AWSLambda`.
3636

3737
If `type` is of value `Cluster` the following additional attributes are defined:
3838
* `cluster_name` - Name of the cluster configured for this connection.
@@ -45,6 +45,9 @@ If `type` is of value `Kafka` the following additional attributes are defined:
4545
* `security` - Properties for the secure transport connection to Kafka. For SSL, this can include the trusted certificate to use. See [security](#security).
4646
* `networking` - Networking Access Type can either be `PUBLIC` (default) or `VPC`. See [networking](#networking).
4747

48+
If `type` is of value `AWSLambda` the following additional attributes are defined::
49+
* `aws` - The configuration for AWS Lambda connection. See [AWS](#AWS)
50+
4851
### Authentication
4952

5053
* `mechanism` - Style of authentication. Can be one of `PLAIN`, `SCRAM-256`, or `SCRAM-512`.
@@ -68,5 +71,8 @@ If `type` is of value `Kafka` the following additional attributes are defined:
6871
* `type` - Selected networking type. Either `PUBLIC`, `VPC` or `PRIVATE_LINK`. Defaults to `PUBLIC`.
6972
* `connection_id` - Id of the Private Link connection when type is `PRIVATE_LINK`.
7073

74+
### AWS
75+
* `role_arn` - Amazon Resource Name (ARN) that identifies the Amazon Web Services (AWS) Identity and Access Management (IAM) role that MongoDB Cloud assumes when it accesses resources in your AWS account.
76+
7177
To learn more, see: [MongoDB Atlas API - Stream Connection](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Streams/operation/listStreamConnections) Documentation.
7278
The [Terraform Provider Examples Section](https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/examples/mongodbatlas_stream_instance/atlas-streams-user-journey.md) also contains details on the overall support for Atlas Streams Processing in Terraform.

docs/resources/stream_connection.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,27 @@ resource "mongodbatlas_stream_connection" "test" {
6666
}
6767
```
6868

69+
### Example AWSLambda Connection
70+
71+
```terraform
72+
resource "mongodbatlas_stream_connection" "test" {
73+
project_id = var.project_id
74+
instance_name = "NewInstance"
75+
connection_name = "AWSLambdaConnection"
76+
type = "AWSLambda"
77+
aws = {
78+
role_arn = "arn:aws:iam::123456789123:role/lambdaRole"
79+
}
80+
}
81+
82+
```
83+
6984
## Argument Reference
7085

7186
* `project_id` - (Required) Unique 24-hexadecimal digit string that identifies your project.
7287
* `instance_name` - (Required) Human-readable label that identifies the stream instance.
7388
* `connection_name` - (Required) Human-readable label that identifies the stream connection. In the case of the Sample type, this is the name of the sample source.
74-
* `type` - (Required) Type of connection. Can be either `Cluster`, `Kafka` or `Sample`.
89+
* `type` - (Required) Type of connection. Can be `Cluster`, `Kafka`, `Sample`, or `AWSLambda`.
7590

7691
If `type` is of value `Cluster` the following additional arguments are defined:
7792
* `cluster_name` - Name of the cluster configured for this connection.
@@ -84,6 +99,9 @@ If `type` is of value `Kafka` the following additional arguments are defined:
8499
* `security` - Properties for the secure transport connection to Kafka. For SSL, this can include the trusted certificate to use. See [security](#security).
85100
* `networking` - Networking Access Type can either be `PUBLIC` (default) or `VPC`. See [networking](#networking).
86101

102+
If `type` is of value `AWSLambda` the following additional arguments are defined:
103+
* `aws` - The configuration for AWS Lambda connection. See [AWS](#AWS)
104+
87105
### Authentication
88106

89107
* `mechanism` - Style of authentication. Can be one of `PLAIN`, `SCRAM-256`, or `SCRAM-512`.
@@ -107,6 +125,9 @@ If `type` is of value `Kafka` the following additional arguments are defined:
107125
* `type` - Selected networking type. Either `PUBLIC`, `VPC` or `PRIVATE_LINK`. Defaults to `PUBLIC`.
108126
* `connection_id` - Id of the Private Link connection when type is `PRIVATE_LINK`.
109127

128+
### AWS
129+
* `role_arn` - Amazon Resource Name (ARN) that identifies the Amazon Web Services (AWS) Identity and Access Management (IAM) role that MongoDB Cloud assumes when it accesses resources in your AWS account.
130+
110131
## Import
111132

112133
You can import a stream connection resource using the instance name, project ID, and connection name. The format must be `INSTANCE_NAME-PROJECT_ID-CONNECTION_NAME`. For example:

examples/mongodbatlas_stream_connection/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ resource "mongodbatlas_stream_connection" "example-sample" {
7070
type = "Sample"
7171
}
7272

73+
resource "mongodbatlas_stream_connection" "example-aws-lambda" {
74+
project_id = var.project_id
75+
instance_name = mongodbatlas_stream_instance.example.instance_name
76+
connection_name = "AWSLambdaConnection"
77+
type = "AWSLambda"
78+
aws = {
79+
role_arn = "arn:aws:iam::123456789123:role/lambdaRole"
80+
}
81+
}
82+
7383
data "mongodbatlas_stream_connection" "example-kafka-ssl" {
7484
project_id = var.project_id
7585
instance_name = mongodbatlas_stream_instance.example.instance_name

internal/service/streamconnection/model_stream_connection.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ func NewStreamConnectionReq(ctx context.Context, plan *TFStreamConnectionModel)
7777
}
7878
}
7979

80+
if !plan.AWS.IsNull() {
81+
awsModel := &TFAWSModel{}
82+
if diags := plan.AWS.As(ctx, awsModel, basetypes.ObjectAsOptions{}); diags.HasError() {
83+
return nil, diags
84+
}
85+
streamConnection.Aws = &admin.StreamsAWSConnectionConfig{
86+
RoleArn: awsModel.RoleArn.ValueStringPointer(),
87+
}
88+
}
89+
8090
return &streamConnection, nil
8191
}
8292

@@ -149,6 +159,17 @@ func NewTFStreamConnection(ctx context.Context, projID, instanceName string, cur
149159
connectionModel.Networking = networkingModel
150160
}
151161

162+
connectionModel.AWS = types.ObjectNull(AWSObjectType.AttrTypes)
163+
if apiResp.Aws != nil {
164+
aws, diags := types.ObjectValueFrom(ctx, AWSObjectType.AttrTypes, TFAWSModel{
165+
RoleArn: types.StringPointerValue(apiResp.Aws.RoleArn),
166+
})
167+
if diags.HasError() {
168+
return nil, diags
169+
}
170+
connectionModel.AWS = aws
171+
}
172+
152173
return &connectionModel, nil
153174
}
154175

internal/service/streamconnection/model_stream_connection_test.go

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const (
2626
sampleConnectionName = "sample_stream_solar"
2727
networkingType = "PUBLIC"
2828
privatelinkNetworkingType = "PRIVATE_LINK"
29+
awslambdaConnectionName = "aws_lambda_connection"
30+
sampleRoleArn = "rn:aws:iam::123456789123:role/sample"
2931
)
3032

3133
var configMap = map[string]string{
@@ -70,6 +72,7 @@ func TestStreamConnectionSDKToTFModel(t *testing.T) {
7072
Security: types.ObjectNull(streamconnection.ConnectionSecurityObjectType.AttrTypes),
7173
DBRoleToExecute: tfDBRoleToExecuteObject(t, dbRole, dbRoleType),
7274
Networking: types.ObjectNull(streamconnection.NetworkingObjectType.AttrTypes),
75+
AWS: types.ObjectNull(streamconnection.AWSObjectType.AttrTypes),
7376
},
7477
},
7578
{
@@ -102,6 +105,7 @@ func TestStreamConnectionSDKToTFModel(t *testing.T) {
102105
Security: tfSecurityObject(t, DummyCACert, securityProtocol),
103106
DBRoleToExecute: types.ObjectNull(streamconnection.DBRoleToExecuteObjectType.AttrTypes),
104107
Networking: types.ObjectNull(streamconnection.NetworkingObjectType.AttrTypes),
108+
AWS: types.ObjectNull(streamconnection.AWSObjectType.AttrTypes),
105109
},
106110
},
107111
{
@@ -123,6 +127,7 @@ func TestStreamConnectionSDKToTFModel(t *testing.T) {
123127
Security: types.ObjectNull(streamconnection.ConnectionSecurityObjectType.AttrTypes),
124128
DBRoleToExecute: types.ObjectNull(streamconnection.DBRoleToExecuteObjectType.AttrTypes),
125129
Networking: types.ObjectNull(streamconnection.NetworkingObjectType.AttrTypes),
130+
AWS: types.ObjectNull(streamconnection.AWSObjectType.AttrTypes),
126131
},
127132
},
128133
{
@@ -155,6 +160,7 @@ func TestStreamConnectionSDKToTFModel(t *testing.T) {
155160
Security: tfSecurityObject(t, DummyCACert, securityProtocol),
156161
DBRoleToExecute: types.ObjectNull(streamconnection.DBRoleToExecuteObjectType.AttrTypes),
157162
Networking: types.ObjectNull(streamconnection.NetworkingObjectType.AttrTypes),
163+
AWS: types.ObjectNull(streamconnection.AWSObjectType.AttrTypes),
158164
},
159165
},
160166
{
@@ -175,6 +181,29 @@ func TestStreamConnectionSDKToTFModel(t *testing.T) {
175181
Security: types.ObjectNull(streamconnection.ConnectionSecurityObjectType.AttrTypes),
176182
DBRoleToExecute: types.ObjectNull(streamconnection.DBRoleToExecuteObjectType.AttrTypes),
177183
Networking: types.ObjectNull(streamconnection.NetworkingObjectType.AttrTypes),
184+
AWS: types.ObjectNull(streamconnection.AWSObjectType.AttrTypes),
185+
},
186+
},
187+
{
188+
name: "AWSLambda connection type with roleArn",
189+
SDKResp: &admin.StreamsConnection{
190+
Name: admin.PtrString(awslambdaConnectionName),
191+
Type: admin.PtrString("AWSLambda"),
192+
Aws: &admin.StreamsAWSConnectionConfig{RoleArn: admin.PtrString(sampleRoleArn)},
193+
},
194+
providedProjID: dummyProjectID,
195+
providedInstanceName: instanceName,
196+
expectedTFModel: &streamconnection.TFStreamConnectionModel{
197+
ProjectID: types.StringValue(dummyProjectID),
198+
InstanceName: types.StringValue(instanceName),
199+
ConnectionName: types.StringValue(awslambdaConnectionName),
200+
Type: types.StringValue("AWSLambda"),
201+
Authentication: types.ObjectNull(streamconnection.ConnectionAuthenticationObjectType.AttrTypes),
202+
Config: types.MapNull(types.StringType),
203+
Security: types.ObjectNull(streamconnection.ConnectionSecurityObjectType.AttrTypes),
204+
DBRoleToExecute: types.ObjectNull(streamconnection.DBRoleToExecuteObjectType.AttrTypes),
205+
Networking: types.ObjectNull(streamconnection.NetworkingObjectType.AttrTypes),
206+
AWS: tfAWSLambdaConfigObject(t, sampleRoleArn),
178207
},
179208
},
180209
}
@@ -238,8 +267,15 @@ func TestStreamConnectionsSDKToTFModel(t *testing.T) {
238267
Name: admin.PtrString(sampleConnectionName),
239268
Type: admin.PtrString("Sample"),
240269
},
270+
{
271+
Name: admin.PtrString(awslambdaConnectionName),
272+
Type: admin.PtrString("AWSLambda"),
273+
Aws: &admin.StreamsAWSConnectionConfig{
274+
RoleArn: admin.PtrString(sampleRoleArn),
275+
},
276+
},
241277
},
242-
TotalCount: admin.PtrInt(3),
278+
TotalCount: admin.PtrInt(4),
243279
},
244280
providedConfig: &streamconnection.TFStreamConnectionsDSModel{
245281
ProjectID: types.StringValue(dummyProjectID),
@@ -252,7 +288,7 @@ func TestStreamConnectionsSDKToTFModel(t *testing.T) {
252288
InstanceName: types.StringValue(instanceName),
253289
PageNum: types.Int64Value(1),
254290
ItemsPerPage: types.Int64Value(3),
255-
TotalCount: types.Int64Value(3),
291+
TotalCount: types.Int64Value(4),
256292
Results: []streamconnection.TFStreamConnectionModel{
257293
{
258294
ID: types.StringValue(fmt.Sprintf("%s-%s-%s", instanceName, dummyProjectID, connectionName)),
@@ -266,6 +302,7 @@ func TestStreamConnectionsSDKToTFModel(t *testing.T) {
266302
Security: tfSecurityObject(t, DummyCACert, securityProtocol),
267303
DBRoleToExecute: types.ObjectNull(streamconnection.DBRoleToExecuteObjectType.AttrTypes),
268304
Networking: tfNetworkingObject(t, networkingType, nil),
305+
AWS: types.ObjectNull(streamconnection.AWSObjectType.AttrTypes),
269306
},
270307
{
271308
ID: types.StringValue(fmt.Sprintf("%s-%s-%s", instanceName, dummyProjectID, connectionName)),
@@ -279,6 +316,7 @@ func TestStreamConnectionsSDKToTFModel(t *testing.T) {
279316
Security: types.ObjectNull(streamconnection.ConnectionSecurityObjectType.AttrTypes),
280317
DBRoleToExecute: tfDBRoleToExecuteObject(t, dbRole, dbRoleType),
281318
Networking: types.ObjectNull(streamconnection.NetworkingObjectType.AttrTypes),
319+
AWS: types.ObjectNull(streamconnection.AWSObjectType.AttrTypes),
282320
},
283321
{
284322
ID: types.StringValue(fmt.Sprintf("%s-%s-%s", instanceName, dummyProjectID, sampleConnectionName)),
@@ -292,6 +330,21 @@ func TestStreamConnectionsSDKToTFModel(t *testing.T) {
292330
Security: types.ObjectNull(streamconnection.ConnectionSecurityObjectType.AttrTypes),
293331
DBRoleToExecute: types.ObjectNull(streamconnection.DBRoleToExecuteObjectType.AttrTypes),
294332
Networking: types.ObjectNull(streamconnection.NetworkingObjectType.AttrTypes),
333+
AWS: types.ObjectNull(streamconnection.AWSObjectType.AttrTypes),
334+
},
335+
{
336+
ID: types.StringValue(fmt.Sprintf("%s-%s-%s", instanceName, dummyProjectID, awslambdaConnectionName)),
337+
ProjectID: types.StringValue(dummyProjectID),
338+
InstanceName: types.StringValue(instanceName),
339+
ConnectionName: types.StringValue(awslambdaConnectionName),
340+
Type: types.StringValue("AWSLambda"),
341+
ClusterName: types.StringNull(),
342+
Authentication: types.ObjectNull(streamconnection.ConnectionAuthenticationObjectType.AttrTypes),
343+
Config: types.MapNull(types.StringType),
344+
Security: types.ObjectNull(streamconnection.ConnectionSecurityObjectType.AttrTypes),
345+
DBRoleToExecute: types.ObjectNull(streamconnection.DBRoleToExecuteObjectType.AttrTypes),
346+
Networking: types.ObjectNull(streamconnection.NetworkingObjectType.AttrTypes),
347+
AWS: tfAWSLambdaConfigObject(t, sampleRoleArn),
295348
},
296349
},
297350
},
@@ -413,6 +466,23 @@ func TestStreamInstanceTFToSDKCreateModel(t *testing.T) {
413466
Type: admin.PtrString("Sample"),
414467
},
415468
},
469+
{
470+
name: "AWSLambda type TF state",
471+
tfModel: &streamconnection.TFStreamConnectionModel{
472+
ProjectID: types.StringValue(dummyProjectID),
473+
InstanceName: types.StringValue(instanceName),
474+
ConnectionName: types.StringValue(awslambdaConnectionName),
475+
Type: types.StringValue("AWSLambda"),
476+
AWS: tfAWSLambdaConfigObject(t, sampleRoleArn),
477+
},
478+
expectedSDKReq: &admin.StreamsConnection{
479+
Name: admin.PtrString(awslambdaConnectionName),
480+
Type: admin.PtrString("AWSLambda"),
481+
Aws: &admin.StreamsAWSConnectionConfig{
482+
RoleArn: admin.PtrString(sampleRoleArn),
483+
},
484+
},
485+
},
416486
}
417487

418488
for _, tc := range testCases {
@@ -503,3 +573,14 @@ func tfNetworkingObject(t *testing.T, networkingType string, connectionID *strin
503573
}
504574
return networking
505575
}
576+
577+
func tfAWSLambdaConfigObject(t *testing.T, roleArn string) types.Object {
578+
t.Helper()
579+
aws, diags := types.ObjectValueFrom(context.Background(), streamconnection.AWSObjectType.AttrTypes, streamconnection.TFAWSModel{
580+
RoleArn: types.StringValue(roleArn),
581+
})
582+
if diags.HasError() {
583+
t.Errorf("failed to create terraform data model: %s", diags.Errors()[0].Summary())
584+
}
585+
return aws
586+
}

0 commit comments

Comments
 (0)