{"id":27253432,"url":"https://github.com/marselester/awscreds","last_synced_at":"2025-08-02T21:10:53.619Z","repository":{"id":37280068,"uuid":"505643138","full_name":"marselester/awscreds","owner":"marselester","description":"Improving AWS Go SDK latency on EKS https://github.com/aws/aws-sdk-go/issues/4385.","archived":false,"fork":false,"pushed_at":"2022-06-21T01:57:13.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T01:36:30.411Z","etag":null,"topics":["aws-eks","aws-sdk-go","aws-sts","latency"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marselester.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-21T00:53:13.000Z","updated_at":"2022-10-26T09:39:05.000Z","dependencies_parsed_at":"2022-08-18T03:51:57.636Z","dependency_job_id":null,"html_url":"https://github.com/marselester/awscreds","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/marselester/awscreds","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fawscreds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fawscreds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fawscreds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fawscreds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marselester","download_url":"https://codeload.github.com/marselester/awscreds/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fawscreds/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268454687,"owners_count":24253159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-eks","aws-sdk-go","aws-sts","latency"],"created_at":"2025-04-11T01:27:31.697Z","updated_at":"2025-08-02T21:10:53.552Z","avatar_url":"https://github.com/marselester.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS SDK latency\n\nIf you were debugging tail latency in AWS Go SDK,\nyou would probably try to trace the requests using\n[httptrace](https://github.com/aws/aws-sdk-go/tree/main/example/aws/request/httptrace)\nand realize that at least one second is spent at `Sign` step.\n\nJinli Liang from Rokt\n[wrote a great explanation](https://www.rokt.com/engineering-blog/improving-app-latency-eks)\nof what's going on.\nIn short, there are three issues:\n\n- by default all AWS STS requests go to a single endpoint at `https://sts.amazonaws.com`.\n  [AWS recommends](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html)\n  using Regional AWS STS endpoints instead of the global endpoint\n  to reduce latency, build in redundancy, and increase session token validity.\n- increased latency from AWS STS request made by an SDK client during application startup\n- increased latency when credentials expiry\n\nThis repository offers slightly refactored version of the code from the Rokt's post.\n\n\u003cdetails\u003e\n\n\u003csummary\u003eSwapper\u003c/summary\u003e\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"os/signal\"\n\n\t\"github.com/aws/aws-sdk-go/aws\"\n\t\"github.com/aws/aws-sdk-go/aws/session\"\n\t\"github.com/aws/aws-sdk-go/service/s3\"\n\t\"github.com/go-kit/log\"\n\t\"github.com/marselester/awscreds\"\n)\n\nfunc main() {\n\tlogger := log.NewJSONLogger(log.NewSyncWriter(os.Stderr))\n\n\tctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)\n\tdefer stop()\n\n\tsess := session.Must(session.NewSession(\u0026aws.Config{}))\n\ts3 := s3.New(sess)\n\n\ts, err := awscreds.NewSwapper(\n\t\tawscreds.New,\n\t\tawscreds.WithLogger(logger),\n\t)\n\tif err != nil {\n\t\tlogger.Log(\"msg\", \"failed to get aws credentials\", \"err\", err)\n\t\treturn\n\t}\n\ts.Attach(s3.Client)\n\ts.Run(ctx)\n}\n```\n\n\u003c/details\u003e\n\nThere is also an option to refresh existing credentials.\n\n\u003cdetails\u003e\n\n\u003csummary\u003eRefresher\u003c/summary\u003e\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"os/signal\"\n\n\t\"github.com/aws/aws-sdk-go/aws\"\n\t\"github.com/aws/aws-sdk-go/aws/session\"\n\t\"github.com/go-kit/log\"\n\t\"github.com/marselester/awscreds\"\n)\n\nfunc main() {\n\tlogger := log.NewJSONLogger(log.NewSyncWriter(os.Stderr))\n\n\tctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)\n\tdefer stop()\n\n\tsess := session.Must(session.NewSession(\u0026aws.Config{}))\n\n\tr, err := awscreds.NewRefresher(\n\t\tsess.Config.Credentials,\n\t\tawscreds.WithLogger(logger),\n\t)\n\tif err != nil {\n\t\tlogger.Log(\"msg\", \"failed to get aws credentials\", \"err\", err)\n\t\treturn\n\t}\n\tr.Run(ctx)\n}\n```\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarselester%2Fawscreds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarselester%2Fawscreds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarselester%2Fawscreds/lists"}