From 1e4cc5437a75f44cee8d7181a5e06c6ea81e1620 Mon Sep 17 00:00:00 2001 From: Rohith Date: Wed, 20 Feb 2019 11:53:58 +0000 Subject: [PATCH] - adding a fix for associating public ip addresses to the launch template --- upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go b/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go index 3d872075ed..28bbc59256 100644 --- a/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go +++ b/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go @@ -76,9 +76,10 @@ func (t *LaunchTemplate) RenderAWS(c *awsup.AWSAPITarget, a, ep, changes *Launch if t.SSHKey != nil { lc.KeyName = t.SSHKey.Name } + var securityGroups []*string // @step: add the security groups for _, sg := range t.SecurityGroups { - lc.SecurityGroupIds = append(lc.SecurityGroupIds, sg.ID) + securityGroups = append(securityGroups, sg.ID) } // @step: add any tenacy details if t.Tenancy != nil { @@ -101,7 +102,11 @@ func (t *LaunchTemplate) RenderAWS(c *awsup.AWSAPITarget, a, ep, changes *Launch &ec2.LaunchTemplateInstanceNetworkInterfaceSpecificationRequest{ AssociatePublicIpAddress: t.AssociatePublicIP, DeleteOnTermination: aws.Bool(true), + DeviceIndex: fi.Int64(0), + Groups: securityGroups, }) + } else { + lc.SecurityGroupIds = securityGroups } // @step: add the userdata if t.UserData != nil {