asm: use httpclient for custom user-agent
The httpclient package sets a custom user-agent for all outbound http
requests, including those generated by the AWS SDK.  The custom
user-agent makes it easy to identify calls generated by the ECS agent in
AWS CloudTrail.
package factory
import (
+ "time"
+
"github.com/aws/amazon-ecs-agent/agent/credentials"
+ "github.com/aws/amazon-ecs-agent/agent/httpclient"
"github.com/aws/aws-sdk-go/aws"
awscreds "github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
@@ -22,6 +25,10 @@ import (
"github.com/aws/aws-sdk-go/service/secretsmanager/secretsmanageriface"
)
+const (
+ roundtripTimeout = 5 * time.Second
+)
+
type ClientCreator interface {
NewASMClient(region string, creds credentials.IAMRoleCredentials) secretsmanageriface.SecretsManagerAPI
}
@@ -34,7 +41,10 @@ type asmClientCreator struct{}
func (*asmClientCreator) NewASMClient(region string,
creds credentials.IAMRoleCredentials) secretsmanageriface.SecretsManagerAPI {
- cfg := aws.NewConfig().WithRegion(region).WithCredentials(
+ cfg := aws.NewConfig().
+ WithHTTPClient(httpclient.New(roundtripTimeout, false)).
+ WithRegion(region).
+ WithCredentials(
awscreds.NewStaticCredentials(creds.AccessKeyID, creds.SecretAccessKey,
creds.SessionToken))
sess := session.Must(session.NewSession(cfg))
