Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Azure Notification Hub FCM credentials #25215

Open
1 task done
tcarsuzanlandytech opened this issue Mar 12, 2024 · 4 comments
Open
1 task done

Support for Azure Notification Hub FCM credentials #25215

tcarsuzanlandytech opened this issue Mar 12, 2024 · 4 comments

Comments

@tcarsuzanlandytech
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Description

We need a new FCM credentials block in Azure Notification module.

image

Migration from GCM to FCM is required before July 2024.
https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-gcm-to-fcm
https://learn.microsoft.com/en-us/azure/notification-hubs/firebase-migration-rest#create-google-service-account-json-file

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

azurerm_notification_hub

Potential Terraform Configuration

resource "azurerm_notification_hub" "example" {
  name                = "mynotificationhub"
  namespace_name      = azurerm_notification_hub_namespace.example.name
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  fcm_credential {
    private_key       = "xxx"
    client_email      = "xxx"
    project_id        = "xxx"
  } 
}

References

MicrosoftDocs/azure-docs#93522

@ferlorca
Copy link

Hi any updates regarding this issue?

@simonecoppini
Copy link

I do not understand... it looks like almost a dead prjoect ... there are differents resources that needs to be updates and no feedback from the team

@vitaliy-shatskiy
Copy link

Any updates?

@asieverding
Copy link

No updates on this so far...
I have found a solution with AzAPI provider in Terraform. The following example initializes the providers, creates a resource group, notification hub namespace and a notification hub with apns and fcm configuration.

# Add providers
terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "3.109.0"
    }

    azapi = {
      source  = "Azure/azapi"
      version = "1.15.0"
    }
  }
}

provider "azurerm" {
  features {}
}

provider "azapi" {}

variable "app_name" {
  type        = string
  description = ""
  default     = "my-app"
}

# Create resource group
resource "azurerm_resource_group" "resource_group" {
  name     = "rg-${var.app_name}"
  location = "West Europe"
}

# Create notification hub namespace
resource "azurerm_notification_hub_namespace" "notification_hub_namespace" {
  name                = "nhn-${var.app_name}"
  resource_group_name = azurerm_resource_group.resource_group.name
  location            = azurerm_resource_group.resource_group.location
  namespace_type      = "NotificationHub"
  sku_name            = "Free"

  depends_on = [
    azurerm_resource_group.resource_group
  ]
}

# Create notification hub
resource "azurerm_notification_hub" "notification_hub" {
  name                = "nh-${var.app_name}"
  namespace_name      = azurerm_notification_hub_namespace.notification_hub_namespace.name
  resource_group_name = azurerm_resource_group.resource_group.name
  location            = azurerm_resource_group.resource_group.location

  apns_credential {
    application_mode = "Production"
    bundle_id        = var.apns_bundle_id
    key_id           = var.apns_key_id
    team_id          = var.apns_team_id
    token            = var.apns_token
  }

  depends_on = [
    azurerm_resource_group.resource_group,
    azurerm_notification_hub_namespace.notification_hub_namespace
  ]
}

# Add fcm to notification hub
resource "azapi_update_resource" "notification_hub_fcm_append" {
  type        = "Microsoft.NotificationHubs/namespaces/notificationHubs@2023-10-01-preview"
  resource_id = azurerm_notification_hub.notification_hub.id

  body = jsonencode({
    properties = {
      fcmV1Credential = {
        properties = {
          clientEmail = var.fcm_client_email
          privateKey  = var.fcm_private_key
          projectId   = var.fcm_project_id
        }
      }
    }
  })

  depends_on = [
    azurerm_resource_group.resource_group,
    azurerm_notification_hub_namespace.notification_hub_namespace,
    azurerm_notification_hub.notification_hub
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants