Closed arnaldo2792 closed 19 hours ago
Can you confirm that this configuration does not leak into the environment for orchestrated containers?
It doesn't:
bash-5.1# systemctl show ecs.service | grep AWS_SDK_LOAD_CONFIG -q && echo "Set!"
Set!
bash-5.1# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
52c2f0a4005e fedora:35 "sleep infinity" 4 minutes ago Up 4 minutes ecs-fedora-19-fedora-92f692fdbaa9cde89601
bash-5.1# docker exec -it 52c2f0a4005e bash
[root@52c2f0a4005e /]# env | grep AWS_SDK_LOAD_CONFIG || echo "Not Set!"
Not Set!
[root@52c2f0a4005e /]#
I'm still confirming your other question.
Have you confirmed via code inspection that this does nothing if the config file doesn't exist? (What if it's malformed?)
I created a simple Go client like so:
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sts"
)
func main() {
sess := session.Must(session.NewSession())
svc := sts.New(sess)
input := &sts.GetCallerIdentityInput{}
result, err := svc.GetCallerIdentity(input)
if err != nil {
fmt.Printf("Error!: %v", err)
return
}
fmt.Println(result)
}
And tested as follows with AWS_SDK_LOAD_CONFIG=true
~/.aws/.config
is missing, the client doesn't fail and uses other credentials providers in the chain (e.g. ~/.aws/credentials
)~/aws/.config
is malformed (as shown below), the client succeeds and in reads valid configurations only, so in the example provided, the client attempted to use the FIPS endpoints:[default]
use_fips_endpoint = true
# use_fips_endpoint = false
not_valid =
incomm
plete
Error!: RequestError: send request failed
caused by: Post "https://sts-fips.aws-global.amazonaws.com/": dial tcp: lookup sts-fips.aws-global.amazonaws.com: no such host⏎
WithAWS_SDK_LOAD_CONFIG=false
, the client still reads ~/.aws/credentials
:
❯ go run main.go
{
Account: "XXXXXXXXXXXX",
Arn: "arn:aws:sts::XXXXXXXXXXXX:assumed-role/<role>/<>",
UserId: "<>"
}
I tested similar cases in the ECS agent (e.g. malformed ~/.aws/config
) and the ECS agent still connected to the cluster.
Issue number:
Related: https://github.com/bottlerocket-os/bottlerocket/issues/1667
Description of changes:
The AWS SDK for Go doesn't use the
${HOME}/.aws/config
file unless theAWS_SDK_LOAD_CONFIG
env variable is set to a truthy value. This applies to both v1 and v2 versions of the AWS SDK for Go. The AWS SDK for Rust doesn't requireAWS_SDK_LOAD_CONFIG
to be set to read${HOME}/.aws/config
Testing done:
In an
aws-ecs-2-fips
variant which defaults to have an AWS config as:Without the environment variable set, the ECS agent used the default AWS endpoints. With the environment variable set and the same AWS confg as above, the ECS agent used the FIPS endpoints:
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.