Skip to content

Commit 0580e52

Browse files
INTMDB-710: Serverless Instance wants to do an in-place update on every run (#1152)
1 parent ac01234 commit 0580e52

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

mongodbatlas/data_source_mongodbatlas_third_party_integrations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func integrationToSchema(d *schema.ResourceData, integration *matlas.ThirdPartyI
115115
"org_name": integration.OrgName,
116116
"url": integrationSchema.URL,
117117
"secret": integrationSchema.Secret,
118-
"microsoft_teams_webhook_url": integrationSchema.MicrosoftTeamsWebhookURL,
118+
"microsoft_teams_webhook_url": integration.MicrosoftTeamsWebhookURL,
119119
"user_name": integrationSchema.UserName,
120120
"password": integrationSchema.Password,
121121
"service_discovery": integration.ServiceDiscovery,

mongodbatlas/resource_mongodbatlas_serverless_instance.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ func resourceMongoDBAtlasServerlessInstanceRead(ctx context.Context, d *schema.R
259259
if err := d.Set("connection_strings_standard_srv", serverlessInstance.ConnectionStrings.StandardSrv); err != nil {
260260
return diag.Errorf("error setting `connection_strings_standard_srv` for serverless instance (%s): %s", d.Id(), err)
261261
}
262-
if len(serverlessInstance.ConnectionStrings.PrivateEndpoint) > 0 {
263-
if err := d.Set("connection_strings_private_endpoint_srv", flattenSRVConnectionString(serverlessInstance.ConnectionStrings.PrivateEndpoint)); err != nil {
264-
return diag.Errorf("error setting `connection_strings_private_endpoint_srv` for serverless instance (%s): %s", d.Id(), err)
265-
}
262+
263+
if err := d.Set("connection_strings_private_endpoint_srv", flattenSRVConnectionString(serverlessInstance.ConnectionStrings.PrivateEndpoint)); err != nil {
264+
return diag.Errorf("error setting `connection_strings_private_endpoint_srv` for serverless instance (%s): %s", d.Id(), err)
266265
}
266+
267267
if err := d.Set("create_date", serverlessInstance.CreateDate); err != nil {
268268
return diag.Errorf("error setting `create_date` for serverless instance (%s): %s", d.Id(), err)
269269
}

mongodbatlas/resource_mongodbatlas_serverless_instance_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func TestAccClusterRSServerlessInstance_basic(t *testing.T) {
3131
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
3232
resource.TestCheckResourceAttr(resourceName, "name", instanceName),
3333
resource.TestCheckResourceAttr(resourceName, "termination_protection_enabled", "false"),
34+
testAccCheckConnectionStringPrivateEndpointIsPresentWithNoElement(resourceName),
3435
),
3536
},
3637
},
@@ -114,11 +115,25 @@ func testAccCheckMongoDBAtlasServerlessInstanceImportStateIDFunc(resourceName st
114115
}
115116

116117
ids := decodeStateID(rs.Primary.ID)
117-
118118
return fmt.Sprintf("%s-%s", ids["project_id"], ids["name"]), nil
119119
}
120120
}
121121

122+
func testAccCheckConnectionStringPrivateEndpointIsPresentWithNoElement(resourceName string) resource.TestCheckFunc {
123+
return func(s *terraform.State) error {
124+
rs, ok := s.RootModule().Resources[resourceName]
125+
if !ok {
126+
return fmt.Errorf("not found: %s", resourceName)
127+
}
128+
129+
if connectionStringPrivateEndpoint := rs.Primary.Attributes["connection_strings_private_endpoint_srv.#"]; connectionStringPrivateEndpoint == "" {
130+
return fmt.Errorf("expected connection_strings_private_endpoint_srv to be present")
131+
}
132+
133+
return nil
134+
}
135+
}
136+
122137
func testAccMongoDBAtlasServerlessInstanceConfig(projectID, name string, ignoreConnectionStrings bool) string {
123138
lifecycle := ""
124139

0 commit comments

Comments
 (0)