driftctl/pkg/resource/aws/aws_sns_topic_subscription.go

40 lines
1.3 KiB
Go
Raw Normal View History

package aws
2021-05-03 16:18:00 +00:00
import (
"github.com/cloudskiff/driftctl/pkg/helpers"
2021-05-03 16:18:00 +00:00
"github.com/cloudskiff/driftctl/pkg/resource"
)
2021-03-25 11:13:52 +00:00
const AwsSnsTopicSubscriptionResourceType = "aws_sns_topic_subscription"
2021-05-03 16:18:00 +00:00
func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
resourceSchemaRepository.UpdateSchema(AwsSnsTopicSubscriptionResourceType, map[string]func(attributeSchema *resource.AttributeSchema){
"delivery_policy": func(attributeSchema *resource.AttributeSchema) {
attributeSchema.JsonString = true
},
"filter_policy": func(attributeSchema *resource.AttributeSchema) {
attributeSchema.JsonString = true
},
})
resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.AbstractResource) {
val := res.Attrs
jsonString, err := helpers.NormalizeJsonString((*val)["delivery_policy"])
if err == nil {
2021-05-21 14:09:45 +00:00
_ = val.SafeSet([]string{"delivery_policy"}, jsonString)
}
jsonString, err = helpers.NormalizeJsonString((*val)["filter_policy"])
if err == nil {
2021-05-21 14:09:45 +00:00
_ = val.SafeSet([]string{"filter_policy"}, jsonString)
}
val.DeleteIfDefault("endpoint_auto_confirms")
v, exists := val.Get("confirmation_timeout_in_minutes")
if exists && v.(float64) == 1 {
val.SafeDelete([]string{"confirmation_timeout_in_minutes"})
}
})
2021-05-03 16:18:00 +00:00
}