Merge pull request #9209 from hashicorp/ssm-panic-fix
builder/amazon Fix invalid pointer issue for non SSMAgengtEnabled builds
This commit is contained in:
commit
5b6f4a3286
|
@ -89,8 +89,18 @@ func (s *StepCreateSSMTunnel) Run(ctx context.Context, state multistep.StateBag)
|
||||||
|
|
||||||
// Cleanup terminates an active session on AWS, which in turn terminates the associated tunnel process running on the local machine.
|
// Cleanup terminates an active session on AWS, which in turn terminates the associated tunnel process running on the local machine.
|
||||||
func (s *StepCreateSSMTunnel) Cleanup(state multistep.StateBag) {
|
func (s *StepCreateSSMTunnel) Cleanup(state multistep.StateBag) {
|
||||||
|
if !s.SSMAgentEnabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
|
|
||||||
|
if s.session == nil || s.session.SessionId == nil {
|
||||||
|
msg := fmt.Sprintf("Unable to find a valid session to instance %q; skipping the termination step", s.instanceId)
|
||||||
|
ui.Error(msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ssmconn := ssm.New(s.AWSSession)
|
ssmconn := ssm.New(s.AWSSession)
|
||||||
_, err := ssmconn.TerminateSession(&ssm.TerminateSessionInput{SessionId: s.session.SessionId})
|
_, err := ssmconn.TerminateSession(&ssm.TerminateSessionInput{SessionId: s.session.SessionId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue