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

resource/aws_sns_platform_application: Remove hashing StateFunc on platform credential and principal #3894

Merged
merged 2 commits into from
Jul 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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