From 3f6b28b70ccb075c91c5f4ebb6fc6db35032f05f Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Wed, 29 Apr 2020 15:14:25 -0400 Subject: [PATCH] Add SSMTunnel step to other amazon builders, minus chroot --- builder/amazon/ebs/builder.go | 7 ++++--- builder/amazon/ebssurrogate/builder.go | 15 +++++++++++++++ builder/amazon/ebsvolume/builder.go | 15 +++++++++++++++ builder/amazon/instance/builder.go | 7 ++++--- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index f7289f2a6..589dd1bd2 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -257,9 +257,10 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack BuildName: b.config.PackerBuildName, }, &awscommon.StepCreateSSMTunnel{ - AWSSession: session, - DstPort: b.config.Comm.Port(), - SSMAgentEnabled: b.config.SSMAgentEnabled(), + AWSSession: session, + Region: *ec2conn.Config.Region, + RemotePortNumber: b.config.Comm.Port(), + SSMAgentEnabled: b.config.SSMAgentEnabled(), }, &communicator.StepConnect{ // StepConnect is provided settings for WinRM and SSH, but diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index 5926f4c23..9c290da08 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -262,6 +262,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack SecurityGroupIds: b.config.SecurityGroupIds, CommConfig: &b.config.RunConfig.Comm, TemporarySGSourceCidrs: b.config.TemporarySGSourceCidrs, + SkipSSHRuleCreation: b.config.SSMAgentEnabled(), }, &awscommon.StepIamInstanceProfile{ IamInstanceProfile: b.config.IamInstanceProfile, @@ -278,6 +279,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Timeout: b.config.WindowsPasswordTimeout, BuildName: b.config.PackerBuildName, }, + &awscommon.StepCreateSSMTunnel{ + AWSSession: session, + Region: *ec2conn.Config.Region, + RemotePortNumber: b.config.Comm.Port(), + SSMAgentEnabled: b.config.SSMAgentEnabled(), + }, &communicator.StepConnect{ Config: &b.config.RunConfig.Comm, Host: awscommon.SSHHost( @@ -285,6 +292,14 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack b.config.SSHInterface, b.config.Comm.Host(), ), + SSHPort: awscommon.Port( + b.config.SSHInterface, + b.config.Comm.Port(), + ), + WinRMPort: awscommon.Port( + b.config.SSHInterface, + b.config.Comm.Port(), + ), SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(), }, &common.StepProvision{}, diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index 01e5c38e2..43445533a 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -238,6 +238,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack SecurityGroupIds: b.config.SecurityGroupIds, CommConfig: &b.config.RunConfig.Comm, TemporarySGSourceCidrs: b.config.TemporarySGSourceCidrs, + SkipSSHRuleCreation: b.config.SSMAgentEnabled(), }, &awscommon.StepIamInstanceProfile{ IamInstanceProfile: b.config.IamInstanceProfile, @@ -255,6 +256,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Timeout: b.config.WindowsPasswordTimeout, BuildName: b.config.PackerBuildName, }, + &awscommon.StepCreateSSMTunnel{ + AWSSession: session, + Region: *ec2conn.Config.Region, + RemotePortNumber: b.config.Comm.Port(), + SSMAgentEnabled: b.config.SSMAgentEnabled(), + }, &communicator.StepConnect{ Config: &b.config.RunConfig.Comm, Host: awscommon.SSHHost( @@ -262,6 +269,14 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack b.config.SSHInterface, b.config.Comm.Host(), ), + SSHPort: awscommon.Port( + b.config.SSHInterface, + b.config.Comm.Port(), + ), + WinRMPort: awscommon.Port( + b.config.SSHInterface, + b.config.Comm.Port(), + ), SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(), }, &common.StepProvision{}, diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index 3ed464291..b44bde5a2 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -339,9 +339,10 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack BuildName: b.config.PackerBuildName, }, &awscommon.StepCreateSSMTunnel{ - AWSSession: session, - DstPort: b.config.Comm.Port(), - SSMAgentEnabled: b.config.SSMAgentEnabled(), + AWSSession: session, + Region: *ec2conn.Config.Region, + RemotePortNumber: b.config.Comm.Port(), + SSMAgentEnabled: b.config.SSMAgentEnabled(), }, &communicator.StepConnect{ // StepConnect is provided settings for WinRM and SSH, but