diff --git a/credentials/oidc_credential_provider.go b/credentials/oidc_credential_provider.go index 98ded60..928eb93 100644 --- a/credentials/oidc_credential_provider.go +++ b/credentials/oidc_credential_provider.go @@ -27,6 +27,7 @@ func (p *oidcCredentialsProvider) resolve() (*Config, error) { RoleArn: tea.String(roleArn), OIDCProviderArn: tea.String(oidcProviderArn), OIDCTokenFilePath: tea.String(oidcTokenFilePath), + RoleSessionName: tea.String("defaultSessionName"), } roleSessionName, ok := os.LookupEnv(ENVRoleSessionName) if ok { diff --git a/credentials/oidc_credential_provider_test.go b/credentials/oidc_credential_provider_test.go index fbf1029..67b9acb 100644 --- a/credentials/oidc_credential_provider_test.go +++ b/credentials/oidc_credential_provider_test.go @@ -31,6 +31,15 @@ func TestOidcCredentialsProvider(t *testing.T) { os.Setenv(ENVRoleArn, "roleArn") os.Setenv(ENVOIDCProviderArn, "oidcProviderArn") os.Setenv(ENVOIDCTokenFile, "oidcTokenFilePath") + os.Unsetenv(ENVRoleSessionName) + c, err = p.resolve() + assert.Nil(t, err) + assert.Equal(t, "roleArn", tea.StringValue(c.RoleArn)) + assert.Equal(t, "oidcProviderArn", tea.StringValue(c.OIDCProviderArn)) + assert.Equal(t, "oidcTokenFilePath", tea.StringValue(c.OIDCTokenFilePath)) + assert.Equal(t, "defaultSessionName", tea.StringValue(c.RoleSessionName)) + assert.Equal(t, "oidc_role_arn", tea.StringValue(c.Type)) + os.Setenv(ENVRoleSessionName, "roleSessionName") c, err = p.resolve() assert.Nil(t, err)