final fix to make service account impersonation work with iap tunnels (#10054)
This commit is contained in:
parent
d05eb3401b
commit
61c6085651
|
@ -77,10 +77,11 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
||||||
Debug: b.config.PackerDebug,
|
Debug: b.config.PackerDebug,
|
||||||
},
|
},
|
||||||
&StepStartTunnel{
|
&StepStartTunnel{
|
||||||
IAPConf: &b.config.IAPConfig,
|
IAPConf: &b.config.IAPConfig,
|
||||||
CommConf: &b.config.Comm,
|
CommConf: &b.config.Comm,
|
||||||
AccountFile: b.config.AccountFile,
|
AccountFile: b.config.AccountFile,
|
||||||
ProjectId: b.config.ProjectId,
|
ImpersonateAccount: b.config.ImpersonateServiceAccount,
|
||||||
|
ProjectId: b.config.ProjectId,
|
||||||
},
|
},
|
||||||
&communicator.StepConnect{
|
&communicator.StepConnect{
|
||||||
Config: &b.config.Comm,
|
Config: &b.config.Comm,
|
||||||
|
|
|
@ -131,10 +131,11 @@ func (e RetryableTunnelError) Error() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
type StepStartTunnel struct {
|
type StepStartTunnel struct {
|
||||||
IAPConf *IAPConfig
|
IAPConf *IAPConfig
|
||||||
CommConf *communicator.Config
|
CommConf *communicator.Config
|
||||||
AccountFile string
|
AccountFile string
|
||||||
ProjectId string
|
ImpersonateAccount string
|
||||||
|
ProjectId string
|
||||||
|
|
||||||
tunnelDriver TunnelDriver
|
tunnelDriver TunnelDriver
|
||||||
}
|
}
|
||||||
|
@ -276,6 +277,10 @@ func (s *StepStartTunnel) Run(ctx context.Context, state multistep.StateBag) mul
|
||||||
"--zone", c.Zone, "--project", s.ProjectId,
|
"--zone", c.Zone, "--project", s.ProjectId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.ImpersonateAccount != "" {
|
||||||
|
args = append(args, fmt.Sprintf("--impersonate-service-account='%s'", s.ImpersonateAccount))
|
||||||
|
}
|
||||||
|
|
||||||
// This is the port the IAP tunnel listens on, on localhost.
|
// This is the port the IAP tunnel listens on, on localhost.
|
||||||
// TODO make setting LocalHostPort optional
|
// TODO make setting LocalHostPort optional
|
||||||
err = ApplyIAPTunnel(s.CommConf, s.IAPConf.IAPLocalhostPort)
|
err = ApplyIAPTunnel(s.CommConf, s.IAPConf.IAPLocalhostPort)
|
||||||
|
|
Loading…
Reference in New Issue