From f5300f7980761debe7d496090e83cdad057eb8d3 Mon Sep 17 00:00:00 2001 From: Christopher Haar Date: Tue, 25 Jun 2024 19:58:39 +0200 Subject: [PATCH] fix(ec2): late init remove for defaultVersion when using updateDefaultVersion: true Signed-off-by: Christopher Haar --- apis/ec2/v1beta2/zz_launchtemplate_terraformed.go | 1 + config/ec2/config.go | 4 ++++ examples/ec2/v1beta1/launchtemplate.yaml | 5 +---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apis/ec2/v1beta2/zz_launchtemplate_terraformed.go b/apis/ec2/v1beta2/zz_launchtemplate_terraformed.go index c8dd851638..4775f8eca1 100755 --- a/apis/ec2/v1beta2/zz_launchtemplate_terraformed.go +++ b/apis/ec2/v1beta2/zz_launchtemplate_terraformed.go @@ -118,6 +118,7 @@ func (tr *LaunchTemplate) 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("DefaultVersion")) li := resource.NewGenericLateInitializer(opts...) return li.LateInitialize(&tr.Spec.ForProvider, params) diff --git a/config/ec2/config.go b/config/ec2/config.go index c95aec31f7..21948d41f8 100644 --- a/config/ec2/config.go +++ b/config/ec2/config.go @@ -142,6 +142,10 @@ func Configure(p *config.Provider) { r.References["network_interfaces.subnet_id"] = config.Reference{ TerraformName: "aws_subnet", } + r.LateInitializer = config.LateInitializer{ + IgnoredFields: []string{"default_version"}, + } + }) p.AddResourceConfigurator("aws_vpc_endpoint", func(r *config.Resource) { diff --git a/examples/ec2/v1beta1/launchtemplate.yaml b/examples/ec2/v1beta1/launchtemplate.yaml index a95f503d8d..25508a30ae 100644 --- a/examples/ec2/v1beta1/launchtemplate.yaml +++ b/examples/ec2/v1beta1/launchtemplate.yaml @@ -22,10 +22,6 @@ spec: - cpuCredits: standard disableApiTermination: true ebsOptimized: "true" - elasticGpuSpecifications: - - type: test - elasticInferenceAccelerator: - - type: eia1.medium instanceInitiatedShutdownBehavior: terminate instanceMarketOptions: - marketType: spot @@ -43,6 +39,7 @@ spec: - associatePublicIpAddress: "true" placement: - availabilityZone: us-west-2a + updateDefaultVersion: true tagSpecifications: - resourceType: instance tags: