New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exception thrown on new AWS.SSOTokenProvider() #4435
Comments
Hi @scott-irwin , Sorry for the long wait. I'm able to confirm that this is a bug. aws-sdk-js/lib/token/sso_token_provider.js Line 125 in 9557694
Additionally, there is a lot of references to Reproduction steps:config file:
Using JS SDK v3 works as expected ✅ : const { S3Client, ListBucketsCommand } = require("@aws-sdk/client-s3");
const { fromIni } = require("@aws-sdk/credential-providers")
const client = new S3Client({
region: 'us-east-1',
credentials: fromIni({
profile: "my-sso"
})
});
const command = new ListBucketsCommand({});
client.send(command)
.then(response => {
console.log(response)
})
.catch(error => {
console.error('Error:', error);
}); Go SDK v2 works as expected ✅ : package main
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/s3"
"log"
)
func main() {
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-east-1"), config.WithClientLogMode(aws.LogResponseWithBody), config.WithSharedConfigProfile("my-sso"))
if err != nil {
log.Fatalf("unable to load SDK config, %v", err)
}
client := s3.NewFromConfig(cfg)
out, err := client.ListBuckets(context.TODO(), &s3.ListBucketsInput{})
if err != nil {
panic(err)
}
fmt.Println(len(out.Buckets))
} SDK v2's const AWS = require("aws-sdk")
const s3 = new AWS.S3({
credentialProvider: new AWS.SSOTokenProvider({
profile: "my-sso"
})
})
s3.listBuckets({}, (err, data)=>{
if(err){
console.log(err)
}else {
console.log(data)
}
}) Will result in:
and even after the fix with
The workaround is to remove the AWS_REGION=us-east-1 AWS_SDK_LOAD_CONFIG=1 AWS_PROFILE=my-sso node v2sample.js I will discuss this with the team and see if we can fix this. Thanks again, |
Describe the bug
I have a working sso token verified using 'aws s3 ls --profile prod'.
Configured using aws configure sso.
I'm attempting to get the credentials for building other AWS services.
However, the following exception is thrown 'ReferenceError: profileName is not defined'
Expected Behavior
the call returns the credentials associated with the current sso token.
that credential object can be passed to create other AWS classes.
for e.g.,
return new AWS.QuickSight({ apiVersion: '2018-04-01', region: region, credentials: creds });
Current Behavior
exception is thrown on new. Showing the error the following text is printed.
'ReferenceError: profileName is not defined'
Reproduction Steps
configure an aws sso token in your local environment.
Possible Solution
No response
Additional Information/Context
No response
SDK version used
"aws-sdk": "^2.1387.0"
Environment details (OS name and version, etc.)
windows 10 Version 10.0.19045 Build 19045
The text was updated successfully, but these errors were encountered: