我正在尝试使用terraform创建aws-sns-ios推送通知平台应用程序。我得到以下错误
Error creating SNS platform application: InvalidParameter: Invalid parameter: PlatformPrincipal not valid.
下面是我的地形代码
resource "aws_sns_platform_application" "apns_application" {
name = var.ios_application_name
platform = var.ios_platform
platform_credential = var.ios_key
platform_principal = filebase64("${path.module}/TestAPNS.p12")
}
我该如何解决这个问题有什么建议吗。当前证书是为沙箱环境生成的。
文档显示它正在寻找证书,而不是base64的证书。(https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_platform_application)
你试过吗
platform_principal = file("${path.module}/TestAPNS.p12")
您可以使用这个方便的提供程序让它与.p12
文件一起工作:https://registry.terraform.io/providers/bendrucker/pkcs12/latest/docs/data-sources/archive
data "pkcs12_archive" "apns_certificate" {
archive = filebase64("${path.root}/TestAPNS.p12")
password = var.apns_certificate_password
}
resource "aws_sns_platform_application" "apns_application" {
name = "${var.env}-${var.sns_platform_name}-APN"
platform = "APNS"
platform_credential = data.pkcs12_archive.apns_certificate.private_key
platform_principal = data.pkcs12_archive.apns_certificate.certificate
}