driftctl/pkg/resource/aws/aws_iam_policy.go

26 lines
811 B
Go

package aws
import (
"github.com/cloudskiff/driftctl/pkg/helpers"
"github.com/cloudskiff/driftctl/pkg/resource"
)
const AwsIamPolicyResourceType = "aws_iam_policy"
func initAwsIAMPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
resourceSchemaRepository.UpdateSchema(AwsIamPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){
"policy": func(attributeSchema *resource.AttributeSchema) {
attributeSchema.JsonString = true
},
})
resourceSchemaRepository.SetNormalizeFunc(AwsIamPolicyResourceType, func(res *resource.AbstractResource) {
val := res.Attrs
jsonString, err := helpers.NormalizeJsonString((*val)["policy"])
if err == nil {
_ = val.SafeSet([]string{"policy"}, jsonString)
}
val.SafeDelete([]string{"name_prefix"})
})
}