Skip to content

Commit

Permalink
fix(cli): ec2ssm use runner region, not cfg region (#1122)
Browse files Browse the repository at this point in the history
Calls to the EC2 API currently fail when the region of the runner is
different from the region of the credentials used to authenticate the
request.

This commit modifies the EC2 clients that we create during
`ec2ssm` execution to use `run.Region` instead of `cfg.Region`.

Fixes RAIN-47298

Signed-off-by: nschmeller <[email protected]>
  • Loading branch information
nschmeller authored Jan 26, 2023
1 parent c463aad commit 2f31808
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lwrunner/awsrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (run AWSRunner) SendPublicKey(pubBytes []byte) error {
func (run AWSRunner) AssociateInstanceProfileWithRunner(cfg aws.Config, instanceProfile types.InstanceProfile) error {
c := ec2.New(ec2.Options{
Credentials: cfg.Credentials,
Region: cfg.Region,
Region: run.Region,
})

// Check to see if there are any instance profiles already associated with the runner
Expand Down Expand Up @@ -254,7 +254,7 @@ const SSMInstancePolicy string = "arn:aws:iam::aws:policy/AmazonSSMManagedInstan
func (run AWSRunner) RunSSMCommandOnRemoteHost(cfg aws.Config, operation string) (ssm.GetCommandInvocationOutput, error) {
c := ssm.New(ssm.Options{
Credentials: cfg.Credentials,
Region: cfg.Region,
Region: run.Region,
})

sendCommandOutput, err := c.SendCommand(
Expand Down

0 comments on commit 2f31808

Please sign in to comment.