Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion awsutil/generate_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ func (c *CredentialsConfig) generateAwsConfigOptions(ctx context.Context, opts o
assumeRoleCred := config.WithAssumeRoleCredentialOptions(func(options *stscreds.AssumeRoleOptions) {
options.RoleARN = c.RoleARN
options.RoleSessionName = c.RoleSessionName
options.ExternalID = aws.String(c.RoleExternalId)
if c.RoleExternalId != "" {
options.ExternalID = aws.String(c.RoleExternalId)
}
for k, v := range c.RoleTags {
options.Tags = append(options.Tags, types.Tag{
Key: aws.String(k),
Expand Down
19 changes: 19 additions & 0 deletions awsutil/generate_credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,25 @@ func TestGenerateAwsConfigOptions(t *testing.T) {
},
},
},
{
name: "assume role credential without external id",
cfg: func() *CredentialsConfig {
credCfg, err := NewCredentialsConfig(
WithRoleArn("foo"),
WithRoleSessionName("bar"),
)
require.NoError(t, err)
return credCfg
}(),
expectedLoadOptions: config.LoadOptions{
Region: "us-east-1",
},
expectedAssumeRoleOptions: &stscreds.AssumeRoleOptions{
RoleARN: "foo",
RoleSessionName: "bar",
ExternalID: nil,
},
},
{
name: "static credential",
cfg: func() *CredentialsConfig {
Expand Down