From 36bfca97d0dbd8b31e46b16e33023a8a2c3923a9 Mon Sep 17 00:00:00 2001 From: Christopher Haar Date: Sun, 22 Oct 2023 13:21:00 +0200 Subject: [PATCH] fix(iam-role): ignore managed_policy_arns in late init Signed-off-by: Christopher Haar (cherry picked from commit 765c9502c23b064e0ed9afce049f9718fe0962a9) --- apis/iam/v1beta1/zz_generated_terraformed.go | 1 + config/iam/config.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/apis/iam/v1beta1/zz_generated_terraformed.go b/apis/iam/v1beta1/zz_generated_terraformed.go index c19f68b9e7..6e0110f4f6 100755 --- a/apis/iam/v1beta1/zz_generated_terraformed.go +++ b/apis/iam/v1beta1/zz_generated_terraformed.go @@ -843,6 +843,7 @@ func (tr *Role) LateInitialize(attrs []byte) (bool, error) { return false, errors.Wrap(err, "failed to unmarshal Terraform state parameters for late-initialization") } opts := []resource.GenericLateInitializerOption{resource.WithZeroValueJSONOmitEmptyFilter(resource.CNameWildcard)} + opts = append(opts, resource.WithNameFilter("ManagedPolicyArns")) li := resource.NewGenericLateInitializer(opts...) return li.LateInitialize(&tr.Spec.ForProvider, params) diff --git a/config/iam/config.go b/config/iam/config.go index 2271af098c..2b5a7a9417 100644 --- a/config/iam/config.go +++ b/config/iam/config.go @@ -33,6 +33,9 @@ func Configure(p *config.Provider) { p.AddResourceConfigurator("aws_iam_role", func(r *config.Resource) { r.MetaResource.ArgumentDocs["inline_policy"] = `Configuration block defining an exclusive set of IAM inline policies associated with the IAM role. See below. If no blocks are configured, Crossplane will not manage any inline policies in this resource. Configuring one empty block (i.e., inline_policy {}) will cause Crossplane to remove all inline policies added out of band on apply.` r.MetaResource.ArgumentDocs["managed_policy_arns"] = `Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Crossplane will ignore policy attachments to this resource. When configured, Crossplane will align the role's managed policy attachments with this set by attaching or detaching managed policies. Configuring an empty set (i.e., managed_policy_arns = []) will cause Crossplane to remove all managed policy attachments.` + r.LateInitializer = config.LateInitializer{ + IgnoredFields: []string{"managed_policy_arns"}, + } }) p.AddResourceConfigurator("aws_iam_instance_profile", func(r *config.Resource) {