Skip to content

Add IMDS credential refresher - #4953

Merged
singholt merged 1 commit into
aws:devfrom
singholt:dev
May 7, 2026
Merged

singholt merged 1 commit into
aws:devfrom
singholt:dev

Conversation

@singholt

@singholt singholt commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add periodic IMDS credential scanning to the ECS agent, consuming the scanner from the shared library. The refresher retrieves rotated task credentials from IMDS and upserts them into the credentials manager. This feature is gated
behind the IMDSIAMRolesEnabled config (disabled by default).

Implementation details

  • ecs-agent/credentials/imds/: Parse role type from IMDS credential key, add RoleType field to TaskCredential. Add mock generation for Scanner interface.
  • agent/api/task/: Add GetCredentialsIDForRoleType method to map role type to the task's credentials ID.
  • agent/imdscreds/: New package with IMDSCredentialRefresher that runs on a 15-minute timer, builds a map of non-terminal tasks, scans IMDS, and upserts credentials using role type.
  • agent/app/: Extract getIMDSCredentialRefresher and wire it up in startAsyncRoutines, gated behind IMDSIAMRolesEnabled.
  • Vendor updated with ecs-agent/credentials/imds package and mocks.

Testing

New tests cover the changes: yes, added unit tests.

Also manually built the ECS agent and ran it on a test instance to verify that the new refresher isn't initialized yet, since the feature is disabled.

Integration tests to test the integration between the agent/app, agent/imdscreds, ecs-agent/credentials/imds/, mock task payloads, and a mock IMDS server, will be added in a followup PR.

Description for the changelog

Feature - Add IMDS credential refresher for periodic task credential rotation via IMDS (config-disabled for now).

Additional Information

Does this PR include breaking model changes? No

Does this PR include the addition of new environment variables in the README? No

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@singholt
singholt force-pushed the dev branch 2 times, most recently from 92aa4b2 to c3a258e Compare May 5, 2026 21:48
@singholt
singholt marked this pull request as ready for review May 6, 2026 16:06
@singholt
singholt requested a review from a team as a code owner May 6, 2026 16:06
@singholt
singholt enabled auto-merge (rebase) May 6, 2026 20:19
ShelbyZ
ShelbyZ previously approved these changes May 6, 2026
Comment thread agent/imdscreds/refresher.go Resolved
- ecs-agent/credentials/imds: Parse role type from credential key, add RoleType to TaskCredential.
- agent/api/task: Add GetCredentialsIDForRoleType method.
- agent/imdscreds: New package with periodic IMDS credential refresher.
- agent/app: Wire up refresher in startAsyncRoutines, gated behind IMDSIAMRolesEnabled.
@singholt
singholt merged commit 8cf2bed into aws:dev May 7, 2026
43 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants