Skip to content

Commit

Permalink
Merge branch 'rd-fix-new-apns-cert' of ssh://github.com/Disciple-Medi…
Browse files Browse the repository at this point in the history
…a/terraform-provider-aws into Disciple-Media-rd-fix-new-apns-cert
  • Loading branch information
bflad committed Jul 14, 2020
2 parents da02a0a + 3dd4c79 commit 91f448c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions aws/resource_aws_sns_platform_application.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package aws

import (
"crypto/sha256"
"fmt"
"log"
"strings"
Expand Down Expand Up @@ -60,7 +59,7 @@ func resourceAwsSnsPlatformApplication() *schema.Resource {
"platform_credential": {
Type: schema.TypeString,
Required: true,
StateFunc: hashSum,
Sensitive: true,
},
"arn": {
Type: schema.TypeString,
Expand Down Expand Up @@ -89,7 +88,7 @@ func resourceAwsSnsPlatformApplication() *schema.Resource {
"platform_principal": {
Type: schema.TypeString,
Optional: true,
StateFunc: hashSum,
Sensitive: true,
},
"success_feedback_role_arn": {
Type: schema.TypeString,
Expand Down Expand Up @@ -158,6 +157,12 @@ func resourceAwsSnsPlatformApplicationUpdate(d *schema.ResourceData, meta interf
}
}

if d.HasChange("platform_principal") {
// If the principal has changed we must also send the credential, even if it didn't change,
// as they must be specified together in the request.
attributes["PlatformCredential"] = aws.String(d.Get("platform_credential").(string))
}

// Make API call to update attributes
req := &sns.SetPlatformApplicationAttributesInput{
PlatformApplicationArn: aws.String(d.Id()),
Expand Down Expand Up @@ -271,10 +276,6 @@ func decodeResourceAwsSnsPlatformApplicationID(input string) (arnS, name, platfo
return
}

func hashSum(contents interface{}) string {
return fmt.Sprintf("%x", sha256.Sum256([]byte(contents.(string))))
}

func validateAwsSnsPlatformApplication(d *schema.ResourceDiff) error {
platform := d.Get("platform").(string)
if snsPlatformRequiresPlatformPrincipal[platform] {
Expand Down

0 comments on commit 91f448c

Please sign in to comment.