-
Notifications
You must be signed in to change notification settings - Fork 152
/
aws_sns_topic_subscription.go
39 lines (33 loc) · 1.34 KB
/
aws_sns_topic_subscription.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package aws
import (
"github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/pkg/helpers"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsSnsTopicSubscriptionResourceType = "aws_sns_topic_subscription"
func initSnsTopicSubscriptionMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) {
val := res.Attrs
jsonString, err := helpers.NormalizeJsonString((*val)["delivery_policy"])
if err == nil {
_ = val.SafeSet([]string{"delivery_policy"}, jsonString)
}
jsonString, err = helpers.NormalizeJsonString((*val)["filter_policy"])
if err == nil {
_ = 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"})
}
})
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
},
})
}