dongteng2534 2018-08-13 14:55
浏览 44
已采纳

从正在运行的CLI Go程序更新AWS凭证以访问其他帐户

Sorry if this is a very basic question, but I am new to AWS and have not found an answer in my research online. I am creating a CLI tool in Go that will pull down all the contents from an s3 bucket locally, then allow you to input new credentials, and then push those contents to a bucket in the new environment.

I am running into an issue where I am to input the new credentials. Here is the code:

type MyProvider struct{
    creds        credentials.Value
}

func getNewCredentials() {
    reader := bufio.NewReader(os.Stdin)
    fmt.Print("Copy new AWS Access Key: ")
    AK, _ := reader.ReadString('
')
    fmt.Print("Copy new AWS Secret Access Key: ")
    SAK, _ := reader.ReadString('
')
    fmt.Print("Copy new AWS session token: ")
    ST, _ := reader.ReadString('
')
    fmt.Print("New stage name(poc, dev, qa, prod): ")
    lib.Stage, _ = reader.ReadString('
')

    provider := MyProvider{
        creds: credentials.Value{AK, SAK, ST, ""},
    }

    creds := credentials.NewCredentials(&provider)

}

I am using a custom provider, and I have overwritten the provider functions Retrieve() and isExpired() (not shown in code snippet).

When I try and access the new bucket, it says the bucket does not exist, leading me to believe the credentials did not properly update. My guess is this has to do with the blank providername at the end of the Value struct. I am not sure what to put there.

Any guidance on how to fix this would be very helpful. The program is not throwing any errors, but rather just not actually updating the credentials.

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥30 靶向捕获测序探针设计自学
  • ¥15 写代码写代码单片机代码写代码写数字按键代码
  • ¥15 django按照距离进行排序
  • ¥15 (标签-微信|关键词-微信公众号)
  • ¥15 matlab中mjs用不了
  • ¥15 Ios抖音直播的时候如何添加自定义图片在直播间!
  • ¥60 riscv-pulpino总线上挂载axi从机
  • ¥15 ssh登录页面的问题
  • ¥50 关于在matlab上对曲柄摇杆机构上一点的运动学仿真
  • ¥15 jetson nano