hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.61k stars 4.65k forks source link

Azurerm for "mailfrom addresses" #22549

Open sureshkachwa opened 1 year ago

sureshkachwa commented 1 year ago

Is there an existing issue for this?

Community Note

Description

Usually in OCI (oracle cloud), we do have a terraform resource to create an approved sender and was looking for the same solution in Azure as well but after all the research I see that neither terraform, azure-cli nor azure-biceps have a configuration/resource to create "mail from address" in "Email communication service"

New or Affected Resource(s)/Data Source(s)

NA

Potential Terraform Configuration

resource "email_communication" "test" {
displayname = xxxxxxxxx
mailfrom_address = xxxxxxxxxx
}

References

NA

mybayern1974 commented 1 year ago

@sureshkachwa Thank you for filing this issue. Given technically this TF AzureRM provider is built based on Azure APIs whose spec is defined here. Could you please elaborate what is the Azure API Spec or any Azure service documentation indicating what Email communication service is? Thus the Terraform AzureRM product team could take a further look at this feature request.

sureshkachwa commented 1 year ago

@mybayern1974 Thank you, document link for Azure's "email communication service" is https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/email/create-email-communication-resource

sureshkachwa commented 1 year ago

@mybayern1974 Also, the APIs used by the email communication service are listed below. https://learn.microsoft.com/en-us/rest/api/communication/email/send?tabs=HTTP

sureshkachwa commented 1 year ago

Any more information needed on this?

mybayern1974 commented 1 year ago

with acknowledging I'm not the expert of Azure communication/email service, by seeing the business doc provided above, is azurerm_communication_service or azurerm_email_communication_service what is expected?

In addition, a kindly heads up in advance that, if more detail info could be provided to present that this is an existing Azure feature and could be experienced by other Azure tools, say Azure portal, then it could be a Terraform AzureRM feature request candidate as logged in this repo, while the Terraform AzureRM team might not be able to commit a timeline to implement it which though would have entered the feature backlog.

timja commented 1 year ago

It needs custom domains implemented first:

azurerm_email_communication_service_domain

Then mail from could be added, something like:

azurerm_email_communication_service_domain_mail_from
timja commented 1 year ago

Also created an issue for https://github.com/hashicorp/terraform-provider-azurerm/issues/22995

sureshkachwa commented 1 year ago

@mybayern1974 can you please check my description, it is about creating "mail from addresses" in Azure "email communication services"

mybayern1974 commented 1 year ago

@sureshkachwa , I'm convinced this is a reasonable feature request. While as I suggested above, this feature request could be put to Hashicorp and Microsoft Terraform backlog while I cannot commit/predict a timeline to implement it.

kantorv commented 1 year ago

there is workaround with azapi provider https://learn.microsoft.com/en-us/azure/templates/microsoft.communication/emailservices/domains/senderusernames?pivots=deployment-language-terraform

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.Communication/emailServices/domains/senderUsernames@2023-04-01-preview"
  name = "string"
  parent_id = "string"
  body = jsonencode({
    properties = {
      displayName = "string"
      username = "string"
    }
  })
}
simaotwx commented 5 months ago

Why does azurerm_email_communication_service exist without any way to configure the things that really matter? I can create the resource but that's where it ends. Guess will have to use @kantorv's suggestion.

simaotwx commented 5 months ago

In addition to senderUsernames, the domains can be configured using: https://learn.microsoft.com/en-us/azure/templates/microsoft.communication/emailservices/domains?pivots=deployment-language-terraform

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.Communication/emailServices/domains@2023-04-01-preview"
  name = "string"
  location = "string"
  parent_id = "string"
  tags = {
    tagName1 = "tagValue1"
    tagName2 = "tagValue2"
  }
  body = jsonencode({
    properties = {
      domainManagement = "string"
      userEngagementTracking = "string"
    }
  })
}
emmaoh5 commented 5 months ago

Once I configure domain using azapi_resource, how do I verify the custom domain?

There's API support to initiate verification https://learn.microsoft.com/en-us/rest/api/communication/resourcemanager/domains/initiate-verification?view=rest-communication-resourcemanager-2023-03-31&tabs=HTTP and I can use azapi_update_resource to make a call.

But how do I verify that response is succeeded and move forward with connecting email with verified domain to communication service using terraform? Is scripting only option? I would like to fully automate creating email resource, communication resource, create and verify custom domain, and connect email resource to communication resource using Terraform.