[Documentation]: Add example for specifying p12 certificate with `aws_sns_platform_application`
#40,803 opened on Jan 7, 2025
Repository metrics
- Stars
- (11,045 stars)
- PR merge metrics
- (Avg merge 19d 21h) (251 merged PRs in 30d)
Description
Terraform Core Version
OpenTofu v1.8.7
AWS Provider Version
v5.81.0
Affected Resource(s)
- aws_sns_platform_application APNS
The platform_principal needs to be the contents of a p12 file for APNS. Since that is a binary file and terraform expects all strings to be utf-8 (see e.g. https://developer.hashicorp.com/terraform/language/functions/base64decode), we have a bit of a problem.
I guess one option would be to add a mutually exclusive platform_principal_base64 that would eat bas64 encoded data instead.
Expected Behavior
resource "aws_sns_platform_application" "apns_application" {
name = "APNS-01"
platform = "APNS"
platform_credential = data.onepassword_item.sns_apns_cert_key.password
platform_principal = base64decode(data.onepassword_item.sns_apns_cert.file[0].content_base64)
}
Should apply correctly.
Actual Behavior
│ Call to function "base64decode" failed: the result of decoding the provided string is not valid UTF-8.
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
resource "aws_sns_platform_application" "apns_application" {
name = "APNS-01"
platform = "APNS"
platform_credential = data.onepassword_item.sns_apns_cert_key.password
platform_principal = base64decode(data.onepassword_item.sns_apns_cert.file[0].content_base64)
}
Steps to Reproduce
tofu apply
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
I might be able to implement the suggested fix