When you create an Elasticsearch instance using azurerm_elastic_cloud_elasticsearch, how do you retrieve the initial root credentials of the instance?
When you create the instance using the ec_deployment resource in the ec Elastic Cloud Provider from Elastic, you can retrieve the credentials through the elasticsearch_username and elasticsearch_password attributes, cf. Terraform Registry.
But this will not work when you create the instance using azurerm_elastic_cloud_elasticsearch, because elasticsearch_username and elasticsearch_password are not present in the ec_deployment data source. The following code will not work:
resource "azurerm_elastic_cloud_elasticsearch" "default" {
name = "${var.projectName}-elasticsearch"
resource_group_name = azurerm_resource_group.default.name
location = azurerm_resource_group.default.location
sku_name = "ess-monthly-consumption_Monthly"
elastic_cloud_email_address = "THES@softwareag.com"
logs {
send_activity_logs = true
send_azuread_logs = true
send_subscription_logs = true
}
tags = {
environment = "${var.projectName}"
}
}
provider "ec" {
apikey = "XXX"
}
data "ec_deployment" "default" {
id = azurerm_elastic_cloud_elasticsearch.default.elastic_cloud_deployment_id
}
output "elasticsearch_endpoint" {
value = data.ec_deployment.default.elasticsearch[0].https_endpoint
}
output "elasticsearch_username" {
value = data.ec_deployment.default.elasticsearch_username
}
output "elasticsearch_password" {
value = data.ec_deployment.default.elasticsearch_password
sensitive = true
}
Thanks for your help!
Best regards,
Thomas