2021-02-24 17:49:02 +00:00
|
|
|
package aws
|
|
|
|
|
2021-05-17 10:09:35 +00:00
|
|
|
import (
|
|
|
|
"github.com/cloudskiff/driftctl/pkg/helpers"
|
|
|
|
"github.com/cloudskiff/driftctl/pkg/resource"
|
|
|
|
)
|
2021-03-25 11:13:52 +00:00
|
|
|
|
2021-02-24 17:49:02 +00:00
|
|
|
const AwsKmsKeyResourceType = "aws_kms_key"
|
|
|
|
|
2021-05-17 10:09:35 +00:00
|
|
|
func initAwsKmsKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
|
|
|
resourceSchemaRepository.UpdateSchema(AwsKmsKeyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){
|
|
|
|
"policy": func(attributeSchema *resource.AttributeSchema) {
|
|
|
|
attributeSchema.JsonString = true
|
|
|
|
},
|
|
|
|
})
|
2021-08-09 14:03:04 +00:00
|
|
|
resourceSchemaRepository.SetNormalizeFunc(AwsKmsKeyResourceType, func(res *resource.Resource) {
|
2021-05-24 15:19:06 +00:00
|
|
|
val := res.Attrs
|
2021-05-17 10:09:35 +00:00
|
|
|
val.SafeDelete([]string{"deletion_window_in_days"})
|
|
|
|
jsonString, err := helpers.NormalizeJsonString((*val)["policy"])
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
2021-05-21 14:09:45 +00:00
|
|
|
_ = val.SafeSet([]string{"policy"}, jsonString)
|
2021-05-17 10:09:35 +00:00
|
|
|
})
|
2021-09-17 15:16:06 +00:00
|
|
|
resourceSchemaRepository.SetFlags(AwsKmsKeyResourceType, resource.FlagDeepMode)
|
2021-05-17 10:09:35 +00:00
|
|
|
}
|