driftctl/pkg/resource/aws/aws_iam_access_key.go

30 lines
1.1 KiB
Go
Raw Normal View History

package aws
2021-05-11 15:02:08 +00:00
import (
"github.com/cloudskiff/driftctl/pkg/resource"
)
2021-03-25 11:13:52 +00:00
const AwsIamAccessKeyResourceType = "aws_iam_access_key"
2021-05-11 15:02:08 +00:00
func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsIamAccessKeyResourceType, func(res *resource.AbstractResource) {
val := res.Attrs
2021-05-11 15:02:08 +00:00
// As we can't read secrets from aws API once access_key created we need to set
// fields retrieved from state to nil to avoid drift
// We can't detect drift if we cannot retrieve latest value from aws API for fields like secrets, passwords etc ...
val.SafeDelete([]string{"secret"})
val.SafeDelete([]string{"ses_smtp_password_v4"})
2021-06-01 13:38:14 +00:00
val.SafeDelete([]string{"encrypted_secret"})
val.SafeDelete([]string{"key_fingerprint"})
val.SafeDelete([]string{"pgp_key"})
2021-05-11 15:02:08 +00:00
})
2021-05-21 14:09:45 +00:00
resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsIamAccessKeyResourceType, func(res *resource.AbstractResource) map[string]string {
val := res.Attrs
attrs := make(map[string]string)
if user := val.GetString("user"); user != nil && *user != "" {
attrs["User"] = *user
}
return attrs
})
2021-05-11 15:02:08 +00:00
}