Skip to content

Commit

Permalink
Specifying region in EC2 and STS clients in entity store (#1347)
Browse files Browse the repository at this point in the history
Co-authored-by: Zhihong Lin <[email protected]>
  • Loading branch information
bryce-carey and zhihonl authored Sep 11, 2024
1 parent b31a818 commit 9c3ec82
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions extension/entitystore/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ package entitystore

import (
"context"
"net/http"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/client"
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
"github.com/aws/aws-sdk-go/service/sts"
Expand Down Expand Up @@ -88,6 +91,7 @@ func (e *EntityStore) Start(ctx context.Context, host component.Host) error {
ec2CredentialConfig := &configaws.CredentialConfig{
Profile: e.config.Profile,
Filename: e.config.Filename,
Region: e.config.Region,
}
switch e.mode {
case config.ModeEC2:
Expand Down Expand Up @@ -203,8 +207,11 @@ func (e *EntityStore) shouldReturnEntity() bool {
e.stsClient = sts.New(
e.nativeCredential,
&aws.Config{
LogLevel: configaws.SDKLogLevel(),
Logger: configaws.SDKLogger{},
Region: aws.String(e.config.Region),
LogLevel: configaws.SDKLogLevel(),
Logger: configaws.SDKLogger{},
STSRegionalEndpoint: endpoints.RegionalSTSEndpoint,
HTTPClient: &http.Client{Timeout: 1 * time.Minute},
})
}
assumedRoleIdentity, err := e.stsClient.GetCallerIdentity(&sts.GetCallerIdentityInput{})
Expand Down

0 comments on commit 9c3ec82

Please sign in to comment.