27 lines
889 B
Go
27 lines
889 B
Go
package aws
|
|
|
|
import (
|
|
"github.com/cloudskiff/driftctl/pkg/helpers"
|
|
"github.com/cloudskiff/driftctl/pkg/resource"
|
|
)
|
|
|
|
const AwsKmsKeyResourceType = "aws_kms_key"
|
|
|
|
func initAwsKmsKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
|
resourceSchemaRepository.UpdateSchema(AwsKmsKeyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){
|
|
"policy": func(attributeSchema *resource.AttributeSchema) {
|
|
attributeSchema.JsonString = true
|
|
},
|
|
})
|
|
resourceSchemaRepository.SetNormalizeFunc(AwsKmsKeyResourceType, func(res *resource.Resource) {
|
|
val := res.Attrs
|
|
val.SafeDelete([]string{"deletion_window_in_days"})
|
|
jsonString, err := helpers.NormalizeJsonString((*val)["policy"])
|
|
if err != nil {
|
|
return
|
|
}
|
|
_ = val.SafeSet([]string{"policy"}, jsonString)
|
|
})
|
|
resourceSchemaRepository.SetFlags(AwsKmsKeyResourceType, resource.FlagDeepMode)
|
|
}
|