我正在尝试在我的应用程序中使用 aws-sdk-go。它在 EC2 实例上运行。现在在文档的配置凭证中,https://docs.aws.amazon.com/sdk-for-go/api/,它说它将查找
*Environment Credentials - Set of environment variables that are useful when sub processes are created for specific roles.
* Shared Credentials file (~/.aws/credentials) - This file stores your credentials based on a profile name and is useful for local development.
*EC2 Instance Role Credentials - Use EC2 Instance Role to assign credentials to application running on an EC2 instance. This removes the need to manage credential files in production.`
最好的顺序不是相反的顺序吗?但我的主要问题是我是否需要询问实例是否有角色,然后使用它来设置凭据(如果它有角色)?这是我不确定我需要做什么以及如何做的地方。
我确实尝试了一个简单的测试来创建一个空配置,基本上只设置区域并在具有角色的实例上运行它,它似乎“有效”但在这种情况下,我不确定是否需要显式设置作用与否。
awsSDK.Config{
Region: awsSDK.String(a.region),
MaxRetries: awsSDK.Int(maxRetries),
HTTPClient: http.DefaultClient,
}
我只想确认这样做是否正确。我的想法是我需要做类似下面的事情
role = use sdk call to get role on machine
set awsSDK.Config { Credentials: credentials form of role,
...
}
issue service command with returned client.
任何更多的文档/指针都会很棒!
慕标琳琳
偶然的你
相关分类