Skip to content

fix(secret): inherit the component's default identity for stores - #2746

Merged
Erik Osterman (Cloud Posse) (osterman) merged 5 commits into
cloudposse:mainfrom
jaguer0:fix/secret-cli-inherit-default-identity
Aug 13, 2026
Merged

Erik Osterman (Cloud Posse) (osterman) merged 5 commits into
cloudposse:mainfrom
jaguer0:fix/secret-cli-inherit-default-identity

Conversation

@jaguer0

@jaguer0 Juan A. (jaguer0) commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

what

  • atmos secret (set/get/init/validate) now inherits the component's effective identity for store-backed secrets whose store declares no explicit identity:, instead of falling back to the default AWS credential chain (→ EC2 IMDS, which fails off-EC2).

why

  • injectSecretStoreAuthResolver (cmd/secret/shared.go) called atmosConfig.Stores.SetAuthContextResolver(resolver), which passes an empty identity to every store, so an identity-less store fell back to the AWS default chain → EC2 IMDS and failed off-EC2 (e.g. no EC2 IMDS role found ... dial tcp 169.254.169.254:80: connect: host is down).
  • The terraform paths (cmd/terraform/utils.go, internal/exec/terraform_execute_helpers.go) already call SetAuthContextResolverWithDefaultIdentity; the secret CLI even computed the same DefaultIdentity (into SecretsAuth) but never applied it to the stores.
  • This aligns the code with documented behavior — website/docs/cli/configuration/secrets.mdx: "When omitted and the secret is resolved within a component scope, the component's effective identity is inherited."
  • Stores with an explicit identity, and an explicit --identity, are unaffected (defaultIdentityForStore only fills empty-identity stores). atmos terraform and atmos secret list behavior is unchanged.

Suggested label: patch (user-visible bug fix, no new surface; no blog/roadmap required).

references

@jaguer0
Juan A. (jaguer0) requested a review from a team as a code owner July 13, 2026 16:11
@atmos-pro

atmos-pro Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions github-actions Bot added the size/s Small size PR label Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e3db119a-8b80-463f-b69a-9f79e78868cb

📥 Commits

Reviewing files that changed from the base of the PR and between 2eb9787 and 2645c65.

📒 Files selected for processing (1)
  • docs/fixes/2026-07-13-secret-cli-inherit-default-identity.md

📝 Walkthrough

Walkthrough

The secret CLI now passes its computed default identity to store-backed authentication resolution. A regression test verifies identity inheritance. Documentation records the fallback behavior, compatibility rules, and affected commands.

Changes

Secret identity inheritance

Layer / File(s) Summary
Resolver wiring and validation
cmd/secret/shared.go, cmd/secret/shared_loaders_test.go
injectSecretStoreAuthResolver computes one default identity and applies it to store auth resolution and SecretsAuth. The test verifies inheritance from the auth-chain tail.
Fix documentation
docs/fixes/2026-07-13-secret-cli-inherit-default-identity.md
Documents the previous credential-chain fallback, resolver behavior, compatibility rules, test coverage, and affected atmos secret commands.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: 🔵 Low · up to 2645c

This PR changes secret-store identity inheritance so identity-less stores use the component’s effective identity instead of the default credential chain. The implementation is localized, but the accompanying fix document still uses imprecise wording about explicit-identity precedence and mock-store behavior, so the PR is mergeable with owner follow-up to correct the documentation.

Possibly related PRs

Suggested reviewers: aknysh

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: store-backed secrets inherit the component's default identity.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…ntity

The `atmos secret` CLI (set/get/init/validate) resolved a store-backed
secret through injectSecretStoreAuthResolver, which called
SetAuthContextResolver(resolver) and passed an empty identity to every
store. An identity-less store therefore kept no identity and fell back to
the AWS default credential chain -> EC2 IMDS, failing off-EC2.

Call SetAuthContextResolverWithDefaultIdentity(resolver, defaultIdentity),
reusing the defaultIdentity the function already computes for SecretsAuth.
This matches the terraform paths (cmd/terraform/utils.go,
internal/exec/terraform_execute_helpers.go) and the documented rule that a
store-backed secret with no explicit identity inherits the component's
effective identity.

Stores with an explicit identity, and an explicit --identity, are
unaffected (defaultIdentityForStore only fills empty-identity stores).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jaguer0
Juan A. (jaguer0) force-pushed the fix/secret-cli-inherit-default-identity branch from fa0ee3c to 41c35e8 Compare July 13, 2026 16:18
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 13, 2026
@osterman Erik Osterman (Cloud Posse) (osterman) added the patch A minor, backward compatible change label Jul 13, 2026
@codecov

codecov Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.97%. Comparing base (6c44717) to head (94fb4c2).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2746      +/-   ##
==========================================
- Coverage   82.98%   82.97%   -0.01%     
==========================================
  Files        1881     1881              
  Lines      183067   183068       +1     
==========================================
- Hits       151925   151908      -17     
- Misses      23317    23332      +15     
- Partials     7825     7828       +3     
Flag Coverage Δ
unittests 82.97% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cmd/secret/shared.go 81.25% <100.00%> (+0.13%) ⬆️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

auto-merge was automatically disabled August 13, 2026 00:34

Head branch was pushed to by a user without write access

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/fixes/2026-07-13-secret-cli-inherit-default-identity.md`:
- Line 19: Update the documentation describing injectSecretStoreAuthResolver and
SetAuthContextResolver to state that no default identity is provided to
identity-less stores, rather than saying an empty identity is passed to every
store. Revise the compatibility guidance to say explicit identities take
precedence regardless of store implementation or test double, and remove the
mock/concrete-type explanation.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b457d79c-51bb-4c75-8eed-0e6fe8d97f53

📥 Commits

Reviewing files that changed from the base of the PR and between a25bfb5 and 2eb9787.

📒 Files selected for processing (3)
  • cmd/secret/shared.go
  • cmd/secret/shared_loaders_test.go
  • docs/fixes/2026-07-13-secret-cli-inherit-default-identity.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/secret/shared_loaders_test.go
  • cmd/secret/shared.go

Comment thread docs/fixes/2026-07-13-secret-cli-inherit-default-identity.md Outdated
Juan A. (jaguer0) and others added 2 commits August 12, 2026 19:40
… split

The store split (NewSSMStore/SSMStoreOptions moved from pkg/store to
pkg/store/providers on main) broke this test after merging main into the
branch. Point it at the new providers package. Test-only; no behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jaguer0
Juan A. (jaguer0) force-pushed the fix/secret-cli-inherit-default-identity branch from 2eb9787 to 3475437 Compare August 13, 2026 00:41
Address CodeRabbit review: SetAuthContextResolver supplies no default
identity to identity-less stores (it does not overwrite explicit ones), and
the _ResolverOnly test asserts the store receives an empty identity name -
the prior 'receives its own identity' wording was inaccurate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@atmos-pro

atmos-pro Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

Merged via the queue into cloudposse:main with commit ba152b4 Aug 13, 2026
82 checks passed
@atmos-pro

atmos-pro Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions

Copy link
Copy Markdown

These changes were released in v1.226.0-rc.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/s Small size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants