-
Notifications
You must be signed in to change notification settings - Fork 271
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
Does SDK support to pick credentials from ~/.aliyun/config.json
file Where credentials store for Aliyun CLI?
#629
Comments
~/.aliyun/config.json
file Where credentials store for Aliyun CLI?~/.aliyun/config.json
file Where credentials store for Aliyun CLI?
Dear Team, Is there any update regarding the above message? |
Currently, the SDK's credentials not fit the CLI's profile well. We are planning to improve it in short term. |
Thanks for the information. Is there any ETA to add the support for CLI's profile? |
Before 7.1. |
Dear @ParthaI , We provide a CLIProfileCredentialsProvider to support your use case. You can use it like this: // create cli credentials provider
provider := NewCLIProfileCredentialsProviderBuilder().Build()
// init client with config and credentials provider
config := sdk.NewConfig().WithScheme("HTTPS")
client, err := sts.NewClientWithOptions("cn-hangzhou", config, provider) |
Thank you @JacksonTian, I will give it a try and let you know. |
Hi @JacksonTian, Apologies for the delayed response. I can confirm that the profile authentication suggestion you provided is working well. It would be great to add support for the In the SDK, there is already support for creating a client with StsToken. However, when executing code with the |
Hello @JacksonTian, Further to our work with profile authentication, we are now encountering timeout errors such as:
Despite setting the request timeout to Here is the relevant configuration: config := GetConfig(d.Connection)
defaultRegion := GetDefaultRegion(d.Connection)
defaultConfig := sdk.NewConfig() // initialize with default config
if config.AutoRetry != nil {
defaultConfig = defaultConfig.WithAutoRetry(*config.AutoRetry) // Value set as true
}
if config.MaxRetryTime != nil {
defaultConfig = defaultConfig.WithMaxRetryTime(*config.MaxRetryTime) // Set to 9
}
if config.Timeout != nil {
defaultConfig = defaultConfig.WithTimeout(time.Duration(*config.Timeout) * time.Second) // 60 seconds
} Do you have any suggestions on how to resolve this issue? Any advice would be greatly appreciated. Thanks! |
I am not recommend to support the short-term credentials in long-term configuration files. So in the new credentials provider, we didn't support it. |
Could you provide more stack for the timeout error? |
Below is a sample Go code to reproduce the error: package main
import (
"fmt"
"log"
"time"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
"github.com/aliyun/alibaba-cloud-sdk-go/services/kms"
)
func main() {
regions := []string{"us-east-1", "ap-south-1", "cn-hangzhou"}
for _, region := range regions {
log.Println("Listing keys in region: " + region)
// Load credentials using the CLI profile named "default"
creds := credentials.NewCLIProfileCredentialsProviderBuilder().
WithProfileName("default").Build()
log.Printf("Credential Provider: %v", creds.GetProviderName())
// SDK configuration with automatic retry enabled
config := sdk.NewConfig()
config.AutoRetry = true
config.Timeout = 30 * time.Second
config.MaxRetryTime = 9
config.Scheme = "HTTPS"
// Create a new KMS client with the loaded credentials
vc, err := kms.NewClientWithOptions(region, config, creds)
if err != nil {
log.Fatalf("Error creating KMS client: %v", err)
}
// Create a request to list KMS keys
request := kms.CreateListKeysRequest()
request.Scheme = "https"
// Make the API call to list keys
res, err := vc.ListKeys(request)
if err != nil {
log.Fatalf("Error listing keys: %v", err)
}
// Print out the key names
for _, key := range res.Keys.Key {
fmt.Println("KeyName:", key.KeyId)
}
}
} I'm encountering the error only for the region
|
The error message shows network issue that access KMS kms.ap-south-1 service failed from your region. Where are you called to KMS. |
Our default connect timeout is 5 seconds. You can custom it like following code: client.SetConnectTimeout(5 * time.Second) // Set client ConnectTimeout to 5 second. |
I have a stable network, I am encountering this error specifically in the
I also tried setting it with |
Dere team,
profile
.~/.aliyun/config.json
.aliyun configure
stores the credentials as described here: Aliyun CLI README.~/.aliyun/config.json
.~/.alibabacloud/credentials
, and the credential file format is different.~/.alibabacloud/credentials
, but I can still run the CLI command successfully and get the expected results.Is there a way for the Alibaba Cloud SDK to authenticate by providing the
profile
name, so it picks the credentials from~/.aliyun/config.json
?An early suggestion would be greatly appreciated.
Thanks!
The text was updated successfully, but these errors were encountered: