2021-02-05 10:03:45 +00:00
|
|
|
package aws
|
|
|
|
|
2021-05-03 16:18:00 +00:00
|
|
|
import (
|
2021-05-18 15:06:11 +00:00
|
|
|
"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
|
|
|
|
2021-02-05 10:03:45 +00:00
|
|
|
const AwsSnsTopicSubscriptionResourceType = "aws_sns_topic_subscription"
|
|
|
|
|
2021-05-03 16:18:00 +00:00
|
|
|
func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
2021-08-09 15:15:35 +00:00
|
|
|
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) map[string]string {
|
|
|
|
return map[string]string{
|
2021-08-18 13:58:28 +00:00
|
|
|
"SubscriptionId": res.ResourceId(),
|
2021-08-09 15:15:35 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-05-03 16:18:00 +00:00
|
|
|
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
|
|
|
|
},
|
|
|
|
})
|
2021-05-18 15:06:11 +00:00
|
|
|
|
2021-08-09 14:03:04 +00:00
|
|
|
resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) {
|
2021-05-24 15:19:06 +00:00
|
|
|
val := res.Attrs
|
2021-05-18 15:06:11 +00:00
|
|
|
jsonString, err := helpers.NormalizeJsonString((*val)["delivery_policy"])
|
|
|
|
if err == nil {
|
2021-05-21 14:09:45 +00:00
|
|
|
_ = val.SafeSet([]string{"delivery_policy"}, jsonString)
|
2021-05-18 15:06:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
jsonString, err = helpers.NormalizeJsonString((*val)["filter_policy"])
|
|
|
|
if err == nil {
|
2021-05-21 14:09:45 +00:00
|
|
|
_ = val.SafeSet([]string{"filter_policy"}, jsonString)
|
2021-05-18 15:06:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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-09-17 15:16:06 +00:00
|
|
|
resourceSchemaRepository.SetFlags(AwsSnsTopicSubscriptionResourceType, resource.FlagDeepMode)
|
2021-05-03 16:18:00 +00:00
|
|
|
}
|