SNS Topic Subscription: import more attributes (#10408)

This commit is contained in:
yn 2017-01-30 03:52:23 -08:00 committed by Paul Stack
parent 55ca64a095
commit 8ea5d53954
1 changed files with 20 additions and 5 deletions

View File

@ -18,6 +18,13 @@ import (
const awsSNSPendingConfirmationMessage = "pending confirmation" const awsSNSPendingConfirmationMessage = "pending confirmation"
const awsSNSPendingConfirmationMessageWithoutSpaces = "pendingconfirmation" const awsSNSPendingConfirmationMessageWithoutSpaces = "pendingconfirmation"
var SNSSubscriptionAttributeMap = map[string]string{
"topic_arn": "TopicArn",
"endpoint": "Endpoint",
"protocol": "Protocol",
"raw_message_delivery": "RawMessageDelivery",
}
func resourceAwsSnsTopicSubscription() *schema.Resource { func resourceAwsSnsTopicSubscription() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
Create: resourceAwsSnsTopicSubscriptionCreate, Create: resourceAwsSnsTopicSubscriptionCreate,
@ -158,11 +165,19 @@ func resourceAwsSnsTopicSubscriptionRead(d *schema.ResourceData, meta interface{
if attributeOutput.Attributes != nil && len(attributeOutput.Attributes) > 0 { if attributeOutput.Attributes != nil && len(attributeOutput.Attributes) > 0 {
attrHash := attributeOutput.Attributes attrHash := attributeOutput.Attributes
log.Printf("[DEBUG] raw message delivery: %s", *attrHash["RawMessageDelivery"]) resource := *resourceAwsSnsTopicSubscription()
if *attrHash["RawMessageDelivery"] == "true" {
d.Set("raw_message_delivery", true) for iKey, oKey := range SNSSubscriptionAttributeMap {
} else { log.Printf("[DEBUG] Reading %s => %s", iKey, oKey)
d.Set("raw_message_delivery", false)
if attrHash[oKey] != nil {
if resource.Schema[iKey] != nil {
var value string
value = *attrHash[oKey]
log.Printf("[DEBUG] Reading %s => %s -> %s", iKey, oKey, value)
d.Set(iKey, value)
}
}
} }
} }