From 4657cb94d69b96045661c33ccd21377d8872162e Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Mon, 10 May 2021 22:47:48 -0700 Subject: [PATCH 01/10] Refactor LaunchTemplate.AssociatePublicIP --- pkg/model/awsmodel/autoscalinggroup.go | 38 ++++++++++--------- .../pkg/fi/cloudup/awstasks/launchtemplate.go | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index 2bc52602c7164..7eb2f9c81b8ef 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -143,7 +143,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde lt := &awstasks.LaunchTemplate{ Name: fi.String(name), Lifecycle: b.Lifecycle, - AssociatePublicIP: lc.AssociatePublicIP, BlockDeviceMappings: lc.BlockDeviceMappings, IAMInstanceProfile: lc.IAMInstanceProfile, ImageID: lc.ImageID, @@ -162,6 +161,26 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde HTTPTokens: lc.HTTPTokens, HTTPPutResponseHopLimit: lc.HTTPPutResponseHopLimit, } + + { + // @step: check the subnets are ok and pull together an array for us + subnets, err := b.GatherSubnets(ig) + if err != nil { + return nil, err + } + + // @step: check if we can add an public ip to this subnet + switch subnets[0].Type { + case kops.SubnetTypePublic, kops.SubnetTypeUtility: + lt.AssociatePublicIP = fi.Bool(true) + if ig.Spec.AssociatePublicIP != nil { + lt.AssociatePublicIP = ig.Spec.AssociatePublicIP + } + case kops.SubnetTypePrivate: + lt.AssociatePublicIP = fi.Bool(false) + } + } + // When using a MixedInstances ASG, AWS requires the SpotPrice be defined on the ASG // rather than the LaunchTemplate or else it returns this error: // You cannot use a launch template that is set to request Spot Instances (InstanceMarketOptions) @@ -361,23 +380,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateHelper(c *fi.ModelBuil return nil, err } - // @step: check the subnets are ok and pull together an array for us - subnets, err := b.GatherSubnets(ig) - if err != nil { - return nil, err - } - - // @step: check if we can add an public ip to this subnet - switch subnets[0].Type { - case kops.SubnetTypePublic, kops.SubnetTypeUtility: - t.AssociatePublicIP = fi.Bool(true) - if ig.Spec.AssociatePublicIP != nil { - t.AssociatePublicIP = ig.Spec.AssociatePublicIP - } - case kops.SubnetTypePrivate: - t.AssociatePublicIP = fi.Bool(false) - } - return t, nil } diff --git a/upup/pkg/fi/cloudup/awstasks/launchtemplate.go b/upup/pkg/fi/cloudup/awstasks/launchtemplate.go index 87c85e7764684..b8058e1bc3072 100644 --- a/upup/pkg/fi/cloudup/awstasks/launchtemplate.go +++ b/upup/pkg/fi/cloudup/awstasks/launchtemplate.go @@ -35,7 +35,7 @@ type LaunchTemplate struct { // Lifecycle is the resource lifecycle Lifecycle *fi.Lifecycle - // AssociatePublicIP indicates if a public ip address is assigned to instabces + // AssociatePublicIP indicates if a public ip address is assigned to instances AssociatePublicIP *bool // BlockDeviceMappings is a block device mappings BlockDeviceMappings []*BlockDeviceMapping From 055741411153466c09dee1db87dc8c3a7a287089 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Mon, 10 May 2021 22:51:00 -0700 Subject: [PATCH 02/10] Refactor LaunchTemplate.BlockDeviceMappings --- pkg/model/awsmodel/autoscalinggroup.go | 81 +++++++++++++------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index 7eb2f9c81b8ef..31e8a2ca1b5cd 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -143,7 +143,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde lt := &awstasks.LaunchTemplate{ Name: fi.String(name), Lifecycle: b.Lifecycle, - BlockDeviceMappings: lc.BlockDeviceMappings, IAMInstanceProfile: lc.IAMInstanceProfile, ImageID: lc.ImageID, InstanceMonitoring: lc.InstanceMonitoring, @@ -181,6 +180,46 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde } } + // @step: add any additional block devices + for i := range ig.Spec.Volumes { + x := &ig.Spec.Volumes[i] + if x.Type == "" { + x.Type = DefaultVolumeType + } + if x.Type == ec2.VolumeTypeIo1 || x.Type == ec2.VolumeTypeIo2 { + if x.Iops == nil { + x.Iops = fi.Int64(DefaultVolumeIonIops) + } + } else if x.Type == ec2.VolumeTypeGp3 { + if x.Iops == nil { + x.Iops = fi.Int64(DefaultVolumeGp3Iops) + } + if x.Throughput == nil { + x.Throughput = fi.Int64(DefaultVolumeGp3Throughput) + } + } else { + x.Iops = nil + } + deleteOnTermination := DefaultVolumeDeleteOnTermination + if x.DeleteOnTermination != nil { + deleteOnTermination = fi.BoolValue(x.DeleteOnTermination) + } + encryption := DefaultVolumeEncryption + if x.Encrypted != nil { + encryption = fi.BoolValue(x.Encrypted) + } + lt.BlockDeviceMappings = append(lt.BlockDeviceMappings, &awstasks.BlockDeviceMapping{ + DeviceName: fi.String(x.Device), + EbsDeleteOnTermination: fi.Bool(deleteOnTermination), + EbsEncrypted: fi.Bool(encryption), + EbsKmsKey: x.Key, + EbsVolumeIops: x.Iops, + EbsVolumeSize: fi.Int64(x.Size), + EbsVolumeThroughput: x.Throughput, + EbsVolumeType: fi.String(x.Type), + }) + } + // When using a MixedInstances ASG, AWS requires the SpotPrice be defined on the ASG // rather than the LaunchTemplate or else it returns this error: // You cannot use a launch template that is set to request Spot Instances (InstanceMarketOptions) @@ -329,46 +368,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateHelper(c *fi.ModelBuil t.SecurityGroups = append(t.SecurityGroups, sgTask) } - // @step: add any additional block devices to the launch configuration - for i := range ig.Spec.Volumes { - x := &ig.Spec.Volumes[i] - if x.Type == "" { - x.Type = DefaultVolumeType - } - if x.Type == ec2.VolumeTypeIo1 || x.Type == ec2.VolumeTypeIo2 { - if x.Iops == nil { - x.Iops = fi.Int64(DefaultVolumeIonIops) - } - } else if x.Type == ec2.VolumeTypeGp3 { - if x.Iops == nil { - x.Iops = fi.Int64(DefaultVolumeGp3Iops) - } - if x.Throughput == nil { - x.Throughput = fi.Int64(DefaultVolumeGp3Throughput) - } - } else { - x.Iops = nil - } - deleteOnTermination := DefaultVolumeDeleteOnTermination - if x.DeleteOnTermination != nil { - deleteOnTermination = fi.BoolValue(x.DeleteOnTermination) - } - encryption := DefaultVolumeEncryption - if x.Encrypted != nil { - encryption = fi.BoolValue(x.Encrypted) - } - t.BlockDeviceMappings = append(t.BlockDeviceMappings, &awstasks.BlockDeviceMapping{ - DeviceName: fi.String(x.Device), - EbsDeleteOnTermination: fi.Bool(deleteOnTermination), - EbsEncrypted: fi.Bool(encryption), - EbsKmsKey: x.Key, - EbsVolumeIops: x.Iops, - EbsVolumeSize: fi.Int64(x.Size), - EbsVolumeThroughput: x.Throughput, - EbsVolumeType: fi.String(x.Type), - }) - } - if b.AWSModelContext.UseSSHKey() { if t.SSHKey, err = b.LinkToSSHKey(); err != nil { return nil, err From 33590eb6177126d68d93d8ec161fb87c5a868ef9 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Mon, 10 May 2021 22:52:17 -0700 Subject: [PATCH 03/10] Refactor LaunchTemplate.CPUCredits --- pkg/model/awsmodel/autoscalinggroup.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index 31e8a2ca1b5cd..6ee630c4088f1 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -143,6 +143,7 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde lt := &awstasks.LaunchTemplate{ Name: fi.String(name), Lifecycle: b.Lifecycle, + CPUCredits: fi.String(fi.StringValue(ig.Spec.CPUCredits)), IAMInstanceProfile: lc.IAMInstanceProfile, ImageID: lc.ImageID, InstanceMonitoring: lc.InstanceMonitoring, @@ -256,12 +257,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde } } - if ig.Spec.CPUCredits != nil { - lt.CPUCredits = ig.Spec.CPUCredits - } else { - lt.CPUCredits = fi.String("") - } - return lt, nil } From 98502cd0b2375fec0ad25a221319adb8bfc12ac2 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Mon, 10 May 2021 22:58:08 -0700 Subject: [PATCH 04/10] Refactor LaunchTemplate.HTTPPutResponseHopLimit --- pkg/model/awsmodel/autoscalinggroup.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index 6ee630c4088f1..015ccea0de1ca 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -144,6 +144,7 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde Name: fi.String(name), Lifecycle: b.Lifecycle, CPUCredits: fi.String(fi.StringValue(ig.Spec.CPUCredits)), + HTTPPutResponseHopLimit: fi.Int64(1), IAMInstanceProfile: lc.IAMInstanceProfile, ImageID: lc.ImageID, InstanceMonitoring: lc.InstanceMonitoring, @@ -159,7 +160,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde Tenancy: lc.Tenancy, UserData: lc.UserData, HTTPTokens: lc.HTTPTokens, - HTTPPutResponseHopLimit: lc.HTTPPutResponseHopLimit, } { @@ -221,6 +221,10 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde }) } + if ig.Spec.InstanceMetadata != nil && ig.Spec.InstanceMetadata.HTTPPutResponseHopLimit != nil { + lt.HTTPPutResponseHopLimit = ig.Spec.InstanceMetadata.HTTPPutResponseHopLimit + } + // When using a MixedInstances ASG, AWS requires the SpotPrice be defined on the ASG // rather than the LaunchTemplate or else it returns this error: // You cannot use a launch template that is set to request Spot Instances (InstanceMarketOptions) @@ -316,10 +320,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateHelper(c *fi.ModelBuil if ig.Spec.InstanceMetadata != nil && ig.Spec.InstanceMetadata.HTTPTokens != nil { t.HTTPTokens = ig.Spec.InstanceMetadata.HTTPTokens } - t.HTTPPutResponseHopLimit = fi.Int64(1) - if ig.Spec.InstanceMetadata != nil && ig.Spec.InstanceMetadata.HTTPPutResponseHopLimit != nil { - t.HTTPPutResponseHopLimit = ig.Spec.InstanceMetadata.HTTPPutResponseHopLimit - } if ig.HasAPIServer() && b.APILoadBalancerClass() == kops.LoadBalancerClassNetwork { From 07aa346e681c0fef2476ff46e36646c7b3ca75f1 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Mon, 10 May 2021 23:00:58 -0700 Subject: [PATCH 05/10] Refactor LaunchTemplate.HTTPTokens --- pkg/model/awsmodel/autoscalinggroup.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index 015ccea0de1ca..be58d2e3c7710 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -145,6 +145,7 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde Lifecycle: b.Lifecycle, CPUCredits: fi.String(fi.StringValue(ig.Spec.CPUCredits)), HTTPPutResponseHopLimit: fi.Int64(1), + HTTPTokens: fi.String(ec2.LaunchTemplateHttpTokensStateOptional), IAMInstanceProfile: lc.IAMInstanceProfile, ImageID: lc.ImageID, InstanceMonitoring: lc.InstanceMonitoring, @@ -159,7 +160,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde Tags: tags, Tenancy: lc.Tenancy, UserData: lc.UserData, - HTTPTokens: lc.HTTPTokens, } { @@ -225,6 +225,10 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde lt.HTTPPutResponseHopLimit = ig.Spec.InstanceMetadata.HTTPPutResponseHopLimit } + if ig.Spec.InstanceMetadata != nil && ig.Spec.InstanceMetadata.HTTPTokens != nil { + lt.HTTPTokens = ig.Spec.InstanceMetadata.HTTPTokens + } + // When using a MixedInstances ASG, AWS requires the SpotPrice be defined on the ASG // rather than the LaunchTemplate or else it returns this error: // You cannot use a launch template that is set to request Spot Instances (InstanceMarketOptions) @@ -316,11 +320,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateHelper(c *fi.ModelBuil SecurityGroups: []*awstasks.SecurityGroup{sgLink}, } - t.HTTPTokens = fi.String(ec2.LaunchTemplateHttpTokensStateOptional) - if ig.Spec.InstanceMetadata != nil && ig.Spec.InstanceMetadata.HTTPTokens != nil { - t.HTTPTokens = ig.Spec.InstanceMetadata.HTTPTokens - } - if ig.HasAPIServer() && b.APILoadBalancerClass() == kops.LoadBalancerClassNetwork { for _, id := range b.Cluster.Spec.API.LoadBalancer.AdditionalSecurityGroups { From bfd8034ccea438e294ad823c13830050686023d7 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Mon, 10 May 2021 23:03:10 -0700 Subject: [PATCH 06/10] Refactor LaunchTemplate.IAMInstanceProfile --- pkg/model/awsmodel/autoscalinggroup.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index be58d2e3c7710..b34f278f2a38a 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -135,6 +135,12 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde return nil, err } + // @step: add the iam instance profile + link, err := b.LinkToIAMInstanceProfile(ig) + if err != nil { + return nil, fmt.Errorf("unable to find IAM profile link for instance group %q: %w", ig.ObjectMeta.Name, err) + } + tags, err := b.CloudTagsForInstanceGroup(ig) if err != nil { return nil, fmt.Errorf("error building cloud tags: %v", err) @@ -146,7 +152,7 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde CPUCredits: fi.String(fi.StringValue(ig.Spec.CPUCredits)), HTTPPutResponseHopLimit: fi.Int64(1), HTTPTokens: fi.String(ec2.LaunchTemplateHttpTokensStateOptional), - IAMInstanceProfile: lc.IAMInstanceProfile, + IAMInstanceProfile: link, ImageID: lc.ImageID, InstanceMonitoring: lc.InstanceMonitoring, InstanceType: lc.InstanceType, @@ -300,16 +306,9 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateHelper(c *fi.ModelBuil } } - // @step: add the iam instance profile - link, err := b.LinkToIAMInstanceProfile(ig) - if err != nil { - return nil, fmt.Errorf("unable to find IAM profile link for instance group %q: %w", ig.ObjectMeta.Name, err) - } - t := &awstasks.LaunchTemplate{ Name: fi.String(name), Lifecycle: b.Lifecycle, - IAMInstanceProfile: link, ImageID: fi.String(ig.Spec.Image), InstanceMonitoring: ig.Spec.DetailedInstanceMonitoring, InstanceType: fi.String(strings.Split(ig.Spec.MachineType, ",")[0]), From d0793bd6ed7798776dfc12503fc452ec01512e0e Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Mon, 10 May 2021 23:04:14 -0700 Subject: [PATCH 07/10] Refactor LaunchTemplate.ImageID --- pkg/model/awsmodel/autoscalinggroup.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index b34f278f2a38a..eea6396114748 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -153,7 +153,7 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde HTTPPutResponseHopLimit: fi.Int64(1), HTTPTokens: fi.String(ec2.LaunchTemplateHttpTokensStateOptional), IAMInstanceProfile: link, - ImageID: lc.ImageID, + ImageID: fi.String(ig.Spec.Image), InstanceMonitoring: lc.InstanceMonitoring, InstanceType: lc.InstanceType, RootVolumeOptimization: lc.RootVolumeOptimization, @@ -309,7 +309,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateHelper(c *fi.ModelBuil t := &awstasks.LaunchTemplate{ Name: fi.String(name), Lifecycle: b.Lifecycle, - ImageID: fi.String(ig.Spec.Image), InstanceMonitoring: ig.Spec.DetailedInstanceMonitoring, InstanceType: fi.String(strings.Split(ig.Spec.MachineType, ",")[0]), RootVolumeOptimization: ig.Spec.RootVolumeOptimization, From a1db8f1e827365f98f7cc036833ba6d349dc3512 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Mon, 10 May 2021 23:11:17 -0700 Subject: [PATCH 08/10] Refactor LaunchTemplate.InstanceInterruptionBehavior --- pkg/model/awsmodel/autoscalinggroup.go | 42 ++++++++++++-------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index eea6396114748..565f71d80d235 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -147,25 +147,26 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde } lt := &awstasks.LaunchTemplate{ - Name: fi.String(name), - Lifecycle: b.Lifecycle, - CPUCredits: fi.String(fi.StringValue(ig.Spec.CPUCredits)), - HTTPPutResponseHopLimit: fi.Int64(1), - HTTPTokens: fi.String(ec2.LaunchTemplateHttpTokensStateOptional), - IAMInstanceProfile: link, - ImageID: fi.String(ig.Spec.Image), - InstanceMonitoring: lc.InstanceMonitoring, - InstanceType: lc.InstanceType, - RootVolumeOptimization: lc.RootVolumeOptimization, - RootVolumeSize: lc.RootVolumeSize, - RootVolumeIops: lc.RootVolumeIops, - RootVolumeType: lc.RootVolumeType, - RootVolumeEncryption: lc.RootVolumeEncryption, - SSHKey: lc.SSHKey, - SecurityGroups: lc.SecurityGroups, - Tags: tags, - Tenancy: lc.Tenancy, - UserData: lc.UserData, + Name: fi.String(name), + Lifecycle: b.Lifecycle, + CPUCredits: fi.String(fi.StringValue(ig.Spec.CPUCredits)), + HTTPPutResponseHopLimit: fi.Int64(1), + HTTPTokens: fi.String(ec2.LaunchTemplateHttpTokensStateOptional), + IAMInstanceProfile: link, + ImageID: fi.String(ig.Spec.Image), + InstanceInterruptionBehavior: ig.Spec.InstanceInterruptionBehavior, + InstanceMonitoring: lc.InstanceMonitoring, + InstanceType: lc.InstanceType, + RootVolumeOptimization: lc.RootVolumeOptimization, + RootVolumeSize: lc.RootVolumeSize, + RootVolumeIops: lc.RootVolumeIops, + RootVolumeType: lc.RootVolumeType, + RootVolumeEncryption: lc.RootVolumeEncryption, + SSHKey: lc.SSHKey, + SecurityGroups: lc.SecurityGroups, + Tags: tags, + Tenancy: lc.Tenancy, + UserData: lc.UserData, } { @@ -247,9 +248,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde if ig.Spec.SpotDurationInMinutes != nil { lt.SpotDurationInMinutes = ig.Spec.SpotDurationInMinutes } - if ig.Spec.InstanceInterruptionBehavior != nil { - lt.InstanceInterruptionBehavior = ig.Spec.InstanceInterruptionBehavior - } if fi.BoolValue(ig.Spec.RootVolumeEncryption) && ig.Spec.RootVolumeEncryptionKey != nil { lt.RootVolumeKmsKey = ig.Spec.RootVolumeEncryptionKey } else { From d2adf498f65b7c1bc28bdfb8f97cd00f2cc141c8 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Mon, 10 May 2021 23:12:21 -0700 Subject: [PATCH 09/10] Refactor LaunchTemplate.InstanceMonitoring --- pkg/model/awsmodel/autoscalinggroup.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index 565f71d80d235..b816a3d1716b5 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -155,7 +155,7 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde IAMInstanceProfile: link, ImageID: fi.String(ig.Spec.Image), InstanceInterruptionBehavior: ig.Spec.InstanceInterruptionBehavior, - InstanceMonitoring: lc.InstanceMonitoring, + InstanceMonitoring: ig.Spec.DetailedInstanceMonitoring, InstanceType: lc.InstanceType, RootVolumeOptimization: lc.RootVolumeOptimization, RootVolumeSize: lc.RootVolumeSize, @@ -307,7 +307,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateHelper(c *fi.ModelBuil t := &awstasks.LaunchTemplate{ Name: fi.String(name), Lifecycle: b.Lifecycle, - InstanceMonitoring: ig.Spec.DetailedInstanceMonitoring, InstanceType: fi.String(strings.Split(ig.Spec.MachineType, ",")[0]), RootVolumeOptimization: ig.Spec.RootVolumeOptimization, RootVolumeSize: fi.Int64(int64(volumeSize)), From a4898c9d7d50711e6c60ee1c632c362fbde9cbf0 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Mon, 10 May 2021 23:13:08 -0700 Subject: [PATCH 10/10] Refactor LaunchTemplate.InstanceType --- pkg/model/awsmodel/autoscalinggroup.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index b816a3d1716b5..51b492b7faa5c 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -156,7 +156,7 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde ImageID: fi.String(ig.Spec.Image), InstanceInterruptionBehavior: ig.Spec.InstanceInterruptionBehavior, InstanceMonitoring: ig.Spec.DetailedInstanceMonitoring, - InstanceType: lc.InstanceType, + InstanceType: fi.String(strings.Split(ig.Spec.MachineType, ",")[0]), RootVolumeOptimization: lc.RootVolumeOptimization, RootVolumeSize: lc.RootVolumeSize, RootVolumeIops: lc.RootVolumeIops, @@ -307,7 +307,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateHelper(c *fi.ModelBuil t := &awstasks.LaunchTemplate{ Name: fi.String(name), Lifecycle: b.Lifecycle, - InstanceType: fi.String(strings.Split(ig.Spec.MachineType, ",")[0]), RootVolumeOptimization: ig.Spec.RootVolumeOptimization, RootVolumeSize: fi.Int64(int64(volumeSize)), RootVolumeType: fi.String(volumeType),