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条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改