簡體   English   中英

獲取錯誤'NoCredentialProviders:鏈中沒有有效的提供者。 已棄用。 在 golang 中調用 acmpca.GetCertificate()

[英]Getting Error 'NoCredentialProviders: no valid providers in chain. Deprecated.' while calling acmpca.GetCertificate() in golang

我在調用 acmpca.GetCertificate() function 獲取證書時遇到錯誤,

NoCredentialProviders: no valid providers in chain
caused by: EnvAccessKeyNotFound: AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment
SharedCredsLoad: failed to load shared credentials file
caused by: FailedRead: unable to open file
caused by: open /root/.aws/credentials: no such file or directory
EC2RoleRequestError: no EC2 instance role found
caused by: RequestError: send request failed
caused by: Get "http://169.254.169.254/latest/meta-data/iam/security-credentials/": dial tcp 169.254.169.254:80: connect: no route to host

我的 AWS_ACCESS_KEY_ID 和 AWS_SECRET_ACCESS_KEY 存儲在 ~/.aws/credentials 文件中,下面是代碼

sess := acmpca.New(session.New(&aws.Config{
        Region: aws.String("us-east-1"),
    }))
    params := &acmpca.GetCertificateInput{
        CertificateArn:          aws.String("ARN"),
        CertificateAuthorityArn: aws.String("ARN"),
    }
    resp, err := sess.GetCertificate(params)
    if err != nil {
        fmt.Println("got error := ", err.Error())
    }
    fmt.Printf("++++ response ++++:= %+V", resp)

誰能幫我解決這個問題? 提前致謝!

您提供的憑據已過期或沒有為其設置適當的權限。 您可以嘗試創建具有足夠代碼權限的新憑據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM