Skip to content

feat: assume role support for cross-account#455

Open
gnyahay wants to merge 2 commits into
anchore:mainfrom
gnyahay:gn/assume-role
Open

feat: assume role support for cross-account#455
gnyahay wants to merge 2 commits into
anchore:mainfrom
gnyahay:gn/assume-role

Conversation

@gnyahay

@gnyahay gnyahay commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

add support for assuming a role to allow centralizing agents

@gnyahay
gnyahay requested a review from a team as a code owner July 16, 2026 23:08
gnyahay added 2 commits July 22, 2026 09:21
Signed-off-by: Greg Nyahay <greg.nyahay@anchore.com>
Signed-off-by: Greg Nyahay <greg.nyahay@anchore.com>
Comment thread pkg/inventory/report.go
// credentials. The credentials cache resolves them lazily and refreshes them automatically
// as they expire, which suits the long-running daemon. The role may live in the same or a
// different AWS account.
if assumeRoleARN != "" {

@bradleyjones bradleyjones Jul 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test coverage for the new assume-role path.

Consider a small unit test asserting the provider is configured with the ARN + ExternalID when set, and skipped when assumeRoleARN == "".

Comment thread pkg/inventory/report.go
}

// If an assume-role ARN is configured, swap the config's credentials for STS assume-role
// credentials. The credentials cache resolves them lazily and refreshes them automatically

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cross-cycle refresh benefit described here is not actually realized. PeriodicallyGetInventoryReport (pkg/lib.go:24-32) calls GetInventoryReportsForRegion on every ticker tick, and this function rebuilds the entire aws.Config + NewAssumeRoleProvider + NewCredentialsCache from scratch each call. So the cache is discarded every poll cycle and a fresh AssumeRole is issued roughly every polling-interval-seconds (default 300s) regardless of the ~1h STS credential TTL — the automatic refresh across the daemon lifetime never happens.

Functionally harmless (one redundant STS call per cycle at default intervals), but the comment overstates the benefit. If you want the refresh behavior it describes, the config/cache would need to be built once and reused across poll cycles.

@bradleyjones bradleyjones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the test coverage is worth improving, otherwise it looks good to me would like to give this a live test before we merge but might need help in setting up the environment to do so

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.

2 participants