Skip to content

Commit 3f5e26d

Browse files
authored
Swap logic for variable substitution (#950)
1 parent 1040025 commit 3f5e26d

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

mongodbatlas/resource_mongodbatlas_alert_configuration.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -737,32 +737,44 @@ func flattenAlertConfigurationNotifications(d *schema.ResourceData, notification
737737
return nil
738738
}
739739

740+
if len(notificationsSchema) > 0 {
741+
for i := range notificationsSchema {
742+
notifications[i].APIToken = notificationsSchema[i].APIToken
743+
notifications[i].DatadogAPIKey = notificationsSchema[i].DatadogAPIKey
744+
notifications[i].FlowdockAPIToken = notificationsSchema[i].FlowdockAPIToken
745+
notifications[i].OpsGenieAPIKey = notificationsSchema[i].OpsGenieAPIKey
746+
notifications[i].ServiceKey = notificationsSchema[i].ServiceKey
747+
notifications[i].VictorOpsAPIKey = notificationsSchema[i].VictorOpsAPIKey
748+
notifications[i].VictorOpsRoutingKey = notificationsSchema[i].VictorOpsRoutingKey
749+
}
750+
}
751+
740752
nts := make([]map[string]interface{}, len(notifications))
741753

742754
for i := range notifications {
743755
nts[i] = map[string]interface{}{
744-
"api_token": notificationsSchema[i].APIToken,
756+
"api_token": notifications[i].APIToken,
745757
"channel_name": notifications[i].ChannelName,
746-
"datadog_api_key": notificationsSchema[i].DatadogAPIKey,
758+
"datadog_api_key": notifications[i].DatadogAPIKey,
747759
"datadog_region": notifications[i].DatadogRegion,
748760
"delay_min": notifications[i].DelayMin,
749761
"email_address": notifications[i].EmailAddress,
750762
"email_enabled": notifications[i].EmailEnabled,
751-
"flowdock_api_token": notificationsSchema[i].FlowdockAPIToken,
763+
"flowdock_api_token": notifications[i].FlowdockAPIToken,
752764
"flow_name": notifications[i].FlowName,
753765
"interval_min": notifications[i].IntervalMin,
754766
"mobile_number": notifications[i].MobileNumber,
755-
"ops_genie_api_key": notificationsSchema[i].OpsGenieAPIKey,
767+
"ops_genie_api_key": notifications[i].OpsGenieAPIKey,
756768
"ops_genie_region": notifications[i].OpsGenieRegion,
757769
"org_name": notifications[i].OrgName,
758-
"service_key": notificationsSchema[i].ServiceKey,
770+
"service_key": notifications[i].ServiceKey,
759771
"sms_enabled": notifications[i].SMSEnabled,
760772
"team_id": notifications[i].TeamID,
761773
"team_name": notifications[i].TeamName,
762774
"type_name": notifications[i].TypeName,
763775
"username": notifications[i].Username,
764-
"victor_ops_api_key": notificationsSchema[i].VictorOpsAPIKey,
765-
"victor_ops_routing_key": notificationsSchema[i].VictorOpsRoutingKey,
776+
"victor_ops_api_key": notifications[i].VictorOpsAPIKey,
777+
"victor_ops_routing_key": notifications[i].VictorOpsRoutingKey,
766778
"microsoft_teams_webhook_url": notifications[i].MicrosoftTeamsWebhookURL,
767779
"webhook_secret": notifications[i].WebhookSecret,
768780
"webhook_url": notifications[i].WebhookURL,

0 commit comments

Comments
 (0)