github cloudposse/atmos v1.199.0-rc.1

pre-release5 hours ago
feat: Add ui.Toast() pattern for status notifications @osterman (#1794) ## what - Add new `ui.Toast()` and `ui.Toastf()` functions for flexible toast-style status notifications - Extract toast functionality from the larger toolchain PR (#1686) for independent review and merge - Update documentation to show Toast pattern as the primary approach for status notifications

why

  • The toolchain PR (#1686) is large and complex - extracting independent features allows faster review and merge
  • Toast pattern provides a unified, flexible approach for all user-facing status messages
  • Custom icon support enables better visual communication without creating new wrapper functions
  • Improves code maintainability by establishing a clear pattern for status notifications

Implementation Details

New Functions:

// Primary toast pattern with custom icons
ui.Toast("📦", "Using latest version: 1.2.3")
ui.Toastf("🔧", "Tool %s is not installed", toolName)

// Existing convenience wrappers (now documented as Toast wrappers)
ui.Success("Done!")      // ✓ Done! (green)
ui.Error("Failed!")      // ✗ Failed! (red)
ui.Warning("Deprecated") // ⚠ Deprecated (yellow)
ui.Info("Processing...")  // ℹ Processing... (cyan)

Benefits:

  • ✅ Consistent pattern for all toast notifications
  • ✅ Flexible icon support (custom emojis or themed icons)
  • ✅ Automatic channel routing (stderr for UI)
  • ✅ Automatic secret masking via I/O layer
  • ✅ Zero breaking changes - all existing functions work as before

Documentation Updates:

  • Updated docs/io-and-ui-output.md with Toast API reference
  • Updated docs/prd/io-handling-strategy.md with Toast pattern examples
  • Enhanced comments in pkg/ui/formatter.go to clarify Toast pattern

Testing

  • ✅ All existing tests pass
  • ✅ Builds successfully
  • ✅ Linter checks pass
  • ✅ No breaking changes to existing API

references

  • Extracted from #1686 (toolchain PR)
  • Part of ongoing UI/UX improvements for Atmos CLI

Summary by CodeRabbit

  • New Features

    • Added toast-style notifications with icon support, multiline toasts, and consistent icon+text formatting.
    • Introduced convenience functions for success, error, warning, and info messages with formatting variants.
  • Documentation

    • Updated UI API docs with toast examples and a new Plain UI Text section (Write/Writef/Writeln examples).
  • Tests

    • Added comprehensive tests covering toast outputs, multiline/unicode handling, and formatting variants.
fix: Use YAML !env function in Sentry config examples @osterman (#1793) ## Summary
  • Fixed incorrect shell-style variable expansion to proper YAML !env function syntax in Sentry configuration examples
  • Removed redundant blog post sections (Real-World Impact, Why This Matters, What's Next)

Changes

Updated configuration examples to use !env VARIABLE_NAME instead of ${VARIABLE_NAME} syntax across documentation and blog post.

Summary by CodeRabbit

  • Documentation
    • Configuration syntax examples have been updated throughout documentation to provide improved clarity and consistency across all setup instructions and configuration best practices.
    • Blog post has been streamlined and refined with condensed narrative sections while fully preserving essential configuration examples, comprehensive technical guidance, and practical recommendations for users.
docs: Add identity provider file isolation PRDs @osterman (#1792) ## what
  • Create universal identity provider file isolation pattern PRD defining canonical pattern for all providers (AWS, Azure, GCP, etc.)
  • Document AWS authentication file isolation as reference implementation showing how existing code implements the pattern
  • Document Azure authentication file isolation as planned implementation following the universal pattern
  • Establish clear separation between Atmos-managed enterprise/customer credentials and developer's personal hobby accounts

why

  • Protect developer's personal credentials: Most developers have personal AWS/Azure/GCP accounts for hobby projects that are manually configured with aws configure, az login, gcloud init. Atmos must never modify these personal accounts.
  • Critical multi-customer use case: When managing infrastructure for multiple customers (Cloud Posse use case), need physically separate credential files to make it "provably impossible" to accidentally use wrong customer's credentials.
  • Establish universal pattern: All identity providers (AWS, Azure, GCP) must follow the same XDG-compliant file isolation pattern for consistency.
  • Enable clean logout: Deleting an Atmos identity removes all work credentials without affecting personal hobby accounts.
  • Azure needs implementation: Current Azure implementation writes to ~/.azure/ which breaks developer's personal Azure CLI setup. This PRD documents the required changes to match AWS pattern.

Key architectural decision: Atmos-managed credentials go in ~/.config/atmos/{cloud}/, personal credentials stay in default locations (~/.aws/, ~/.azure/, ~/.config/gcloud/).

references

  • Implements XDG Base Directory Specification for credential storage
  • Documents existing AWS implementation that successfully isolates credentials using AWS_SHARED_CREDENTIALS_FILE and AWS_CONFIG_FILE
  • Plans Azure implementation using AZURE_CONFIG_DIR environment variable for isolation
  • Related to ongoing Azure authentication work

Summary by CodeRabbit

  • Documentation
    • Added a universal authentication file isolation pattern covering per-provider credential isolation, logout/cleanup semantics, XDG-compliant storage, environment variable wiring, security guidance, testing strategy, and migration steps
    • Added AWS-specific implementation and environment mappings
    • Added Azure-specific implementation guidance, XDG storage guidance, environment mappings, migration guidance, and testing recommendations
fix: Upgrade CodeQL Action from v3 to v4 @osterman (#1790) ## what - Upgrade all CodeQL Action references from deprecated v3 to v4 - Updates github/codeql-action/init, autobuild, analyze, and upload-sarif actions - Resolves deprecation warning about v3 being removed in December 2026

why

CodeQL Action v3 is deprecated and will be removed on December 28, 2026. This PR ensures the workflow continues to function with the supported version.

references

Summary by CodeRabbit

  • Chores
    • Updated GitHub Actions workflow dependencies to latest compatible versions for improved reliability and security in the continuous integration pipeline.
feat: Migrate theme commands to StandardFlagParser @osterman (#1772) ## Summary

This PR has two main components:

  1. Theme Command Migration: Migrated theme list and show commands to use the modern StandardFlagParser pattern
  2. Error Handling Documentation: Comprehensive documentation improvements for the Atmos error handling system

Changes

Theme Commands

  • Theme list command: Removed global variables, added type-safe options struct, enabled environment variable support (ATMOS_RECOMMENDED), and implemented proper flag precedence (CLI > env > config > default)
  • Theme show command: Established consistent StandardFlagParser pattern for future flag additions
  • Error handling: Improved theme command errors to use builder pattern with actionable hints
  • Test coverage: Added 30 comprehensive test cases validating flag handling, Viper integration, and flag precedence behavior

Error Handling Documentation

  • atmos-errors agent: Created comprehensive agent guide (14.7KB) for designing user-friendly error messages
  • Key principles documented:
    • Hints = WHAT TO DO (actionable steps) - NOT "what happened"
    • Explanations = WHAT HAPPENED (educational context)
    • Context = WHERE/HOW (debugging details, non-redundant)
  • Critical patterns:
    • Subprocess exit code preservation with exec.ExitError
    • errors.Join() order non-preservation warning
    • Error builder pattern with formatted methods (WithHintf, WithExplanationf)
    • Avoiding redundancy across builder methods
  • Error docs improvements: Updated docs/errors.md with formatted builder methods and clearer examples

Benefits

Theme Commands

  • Type-safe options with proper encapsulation
  • Full flag precedence support (CLI > env > config > default)
  • Environment variable support for all flags
  • Consistency with other Atmos commands
  • Better error messages with actionable hints

Error Handling System

  • Clear guidance for developers on creating user-friendly errors
  • Prevents common anti-patterns (explanatory hints, redundancy, wrong exit codes)
  • Ensures consistent error experience across Atmos
  • Proactive agent that reviews error handling code

Testing

  • 30+ theme command test cases covering flag handling and precedence
  • All error documentation examples validated for correctness
  • Error builder pattern verified with proper separation of hints/explanations/context

Summary by CodeRabbit

  • New Features

    • Theme commands now respect ATMOS_THEME/THEME with consistent precedence (CLI > env > config > default).
    • Added a "recommended only" option and unified flag parsing for theme list/show.
    • New public theme errors for clearer "not found" and "invalid" theme cases.
  • Tests

    • Expanded coverage for flag/env/config precedence, option parsing, theme resolution, and command executions.
  • Documentation

    • Blog post documenting env-var support and usage examples.
  • Chores

    • CI: pin Helm version for Helmfile steps.
feat: Add native Azure authentication support @jamengual (#1768) ## Summary

This PR adds comprehensive native Azure authentication support to Atmos, enabling seamless authentication to Azure with full Terraform provider compatibility.

Features

Three Authentication Methods

  • Device Code Flow: Browser-based authentication for interactive developer sessions with MFA support
  • OIDC: Workload identity federation for GitHub Actions, GitLab CI, and Azure DevOps pipelines
  • Service Principals: Client credential authentication for automation and service accounts

Full Terraform Provider Support

Works seamlessly with all Azure Terraform providers out of the box:

  • azurerm - Complete Azure Resource Manager support including KeyVault operations
  • azuread - Azure Active Directory management
  • azapi - Alternative Azure management interface

Identical to az login Behavior

  • Writes credentials to ~/.azure/msal_token_cache.json (Azure CLI MSAL cache)
  • Updates ~/.azure/azureProfile.json with subscription configuration
  • Sets ARM_USE_CLI=true for Terraform providers
  • Drop-in replacement - existing Terraform code works without changes
  • Provides all three token scopes for complete Azure functionality:
    • https://management.azure.com/.default - Azure Resource Manager
    • https://graph.microsoft.com/.default - Azure AD operations
    • https://vault.azure.net/.default - Azure KeyVault operations

Multi-Subscription & Multi-Region Support

Easy switching between different Azure subscriptions, regions, and environments:

auth:
  identities:
    azure-dev:
      kind: azure/subscription
      principal:
        subscription_id: "DEV_SUBSCRIPTION_ID"
        location: "eastus"
    
    azure-prod:
      kind: azure/subscription
      principal:
        subscription_id: "PROD_SUBSCRIPTION_ID"
        location: "westus"

Quick Start

Configuration

auth:
  providers:
    azure-dev:
      kind: azure/device-code
      tenant_id: "12345678-1234-1234-1234-123456789012"
      subscription_id: "87654321-4321-4321-4321-210987654321"
      location: "eastus"

  identities:
    azure-dev-subscription:
      default: true
      kind: azure/subscription
      via:
        provider: azure-dev
      principal:
        subscription_id: "87654321-4321-4321-4321-210987654321"
        location: "eastus"

Usage

# Authenticate to Azure
atmos auth login

# Use with Terraform
atmos terraform plan my-component -s my-stack
atmos terraform apply my-component -s my-stack

# Switch subscriptions
atmos terraform apply my-component -s prod --identity azure-prod

Implementation Details

New Packages

pkg/auth/providers/azure/

  • device_code.go - Device code flow authentication with interactive browser flow
  • oidc.go - OIDC workload identity federation for CI/CD
  • service_principal.go - Client credentials authentication
  • cli.go - Azure CLI compatibility utilities
  • device_code_cache.go - Token caching and MSAL cache management

pkg/auth/identities/azure/

  • subscription.go - Azure subscription identity with location support

pkg/auth/cloud/azure/

  • setup.go - MSAL cache and Azure profile file management
  • env.go - Environment variable configuration for Terraform
  • files.go - Credential file operations with proper locking
  • console.go - Azure Portal URL generation

pkg/auth/types/

  • azure_credentials.go - Azure credential type implementation

Architecture

Follows Atmos architectural patterns:

  • Registry Pattern: Azure providers/identities register via factory
  • Interface-Driven: All components implement Provider/Identity interfaces
  • Provider-Agnostic Core: No Azure-specific code in core auth manager
  • Testable: Comprehensive unit tests with mocked dependencies

Complete Token Support

Atmos provides all three Azure token scopes (matching az login exactly):

  1. Management Token (https://management.azure.com/.default)

    • Used by azurerm and azapi providers
    • Enables all Azure Resource Manager operations
  2. Graph API Token (https://graph.microsoft.com/.default)

    • Used by azuread provider
    • Enables Azure AD operations (users, groups, service principals)
  3. KeyVault Token (https://vault.azure.net/.default)

    • Used by azurerm provider for KeyVault operations
    • Enables secret, key, and certificate management

This comprehensive token support ensures all Terraform resources work correctly, including KeyVault certificate contacts, secret management, and AD group operations.

CI/CD Integration Examples

GitHub Actions with OIDC

name: Deploy Infrastructure
on:
  push:
    branches: [main]

permissions:
  id-token: write  # Required for OIDC
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Atmos
        uses: cloudposse/github-action-setup-atmos@v2

      - name: Authenticate to Azure
        run: atmos auth login --identity azure-prod-ci
        env:
          AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
          AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
          AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

      - name: Deploy
        run: atmos terraform apply my-component -s prod

Service Principal Authentication

auth:
  providers:
    azure-automation:
      kind: azure/service-principal
      tenant_id: "YOUR_TENANT_ID"
      client_id: "YOUR_SERVICE_PRINCIPAL_CLIENT_ID"
      subscription_id: "YOUR_SUBSCRIPTION_ID"

  identities:
    azure-automation-prod:
      kind: azure/subscription
      via:
        provider: azure-automation
      principal:
        subscription_id: "YOUR_SUBSCRIPTION_ID"

Testing

Unit Test Coverage

Added comprehensive test coverage (3,401 lines of test code):

pkg/auth/cloud/azure/

  • files_test.go - File manager, locking, permissions (112 lines)
  • setup_test.go - MSAL cache updates, JWT extraction, profile management (336 lines)

pkg/auth/providers/azure/

  • device_code_test.go - Device code provider, validation, spinner UI (302 lines)
  • device_code_cache_test.go - Token caching, expiration, MSAL updates (286 lines)
  • cli_test.go - CLI provider validation and environment prep (179 lines)
  • oidc_test.go - OIDC provider with workload identity federation
  • service_principal_test.go - Service principal authentication

pkg/auth/identities/azure/

  • subscription_test.go - Subscription identity, location overrides (141 lines)

pkg/auth/types/

  • azure_credentials_test.go - Credential type, expiration, validation

Coverage Results

  • pkg/auth/cloud/azure: 81.9% ✅ (exceeded 80% target)
  • pkg/auth/providers/azure: 54.7%
  • pkg/auth/identities/azure: 62.5%
  • Overall patch coverage: 64.42% (comparable to AWS SSO at 62.64%)

Coverage gap is primarily in Azure SDK integration code (device code authentication flow, token acquisition) which follows the same pattern as AWS implementation (no SDK mocking).

Manual Testing

Verified with:

  • ✅ Device code authentication flow with browser interaction
  • ✅ Multi-subscription workflows with location overrides
  • ✅ Terraform azurerm provider with KeyVault resources
  • ✅ Terraform azuread provider with AD group operations
  • ✅ Terraform azapi provider
  • ✅ Token caching and automatic reuse
  • ✅ MSAL cache format compatibility with Azure CLI
  • ✅ Cross-platform testing (macOS, Linux, Windows)

Documentation

Comprehensive Tutorial

Created detailed Azure authentication guide:

  • website/docs/cli/commands/auth/tutorials/azure-authentication.mdx (689 lines)
  • Covers all three authentication methods with step-by-step examples
  • Multi-subscription workflows and CI/CD patterns
  • Troubleshooting guide and common scenarios
  • Security best practices

Updated Command Documentation

  • Updated website/docs/cli/commands/auth/auth-login.mdx with Azure examples
  • Added authentication methods comparison (AWS vs Azure)
  • Added provider-specific configuration examples

Feature Announcement Blog Post

  • website/blog/2025-11-07-azure-authentication-support.mdx (447 lines)
  • Feature announcement with usage examples
  • Migration guide from az login
  • CI/CD integration patterns (GitHub Actions, service principals)
  • Implementation details (MSAL cache, token scopes)
  • Security features and best practices

Migration from az login

Atmos is a drop-in replacement for az login:

Before:

az login
az account set --subscription "YOUR_SUBSCRIPTION_ID"
terraform apply

After:

atmos auth login --identity azure-dev
atmos terraform apply my-component -s my-stack

Both write to the same Azure CLI files (~/.azure/msal_token_cache.json and ~/.azure/azureProfile.json), so existing Terraform code works without any changes.

Security Features

  • Secure Storage: Credentials stored in OS keyring (Keychain on macOS, Secret Service on Linux, Credential Manager on Windows)
  • MSAL Cache Compatibility: Tokens also written to Azure CLI MSAL cache for Terraform provider compatibility
  • Token Expiration: Automatic detection and handling of expired tokens (1-hour default)
  • File Permissions: Credential files created with 0600 permissions (user read/write only)
  • Least Privilege: Supports Azure RBAC for minimal access configuration
  • No Plaintext Secrets: Service principal secrets stored in keyring, not on disk

Files Changed

New Implementation Files (27 files)

Core Azure Auth

  • pkg/auth/types/azure_credentials.go - Azure credential type
  • pkg/auth/cloud/azure/*.go - Azure cloud utilities (5 files)
  • pkg/auth/providers/azure/*.go - Azure providers (5 files)
  • pkg/auth/identities/azure/*.go - Azure identities (1 file)

Tests

  • pkg/auth/types/azure_credentials_test.go
  • pkg/auth/cloud/azure/*_test.go (2 files)
  • pkg/auth/providers/azure/*_test.go (3 files)
  • pkg/auth/identities/azure/*_test.go (1 file)

Integration

  • pkg/auth/factory/factory.go - Register Azure providers/identities
  • pkg/auth/types/constants.go - Azure provider kind constants
  • pkg/schema/schema.go - Azure auth context schema
  • errors/errors.go - Azure error definitions

Documentation Files (4 files)

  • website/docs/cli/commands/auth/tutorials/azure-authentication.mdx
  • website/docs/cli/commands/auth/auth-login.mdx (updated)
  • website/blog/2025-11-07-azure-authentication-support.mdx
  • website/blog/authors.yml (updated)

Modified Core Files (6 files)

  • internal/exec/terraform_generate_backend.go - Azure backend auth
  • internal/exec/terraform_utils.go - Azure provider auth
  • internal/exec/utils.go - Azure auth context handling
  • cmd/auth_console.go - Azure console URL support
  • go.mod / go.sum - Dependencies already present

Breaking Changes

None. This is a new feature that doesn't affect existing functionality.

Checklist

  • Code compiles successfully
  • All existing tests pass
  • Added comprehensive unit tests (3,401 lines)
  • Test coverage >80% on core packages
  • Cross-platform compatibility (macOS, Linux, Windows)
  • Manual testing with all Azure Terraform providers
  • Documentation added (tutorial + command docs + blog post)
  • Blog post required for minor feature ✅
  • No breaking changes
  • Follows conventional commits format
  • CodeQL security scan passing

Future Enhancements

Potential additions:

  • Azure Managed Identity support for VM/container workloads
  • Azure Government Cloud / sovereign cloud support
  • Azure CLI credential migration/import tools
  • Enhanced Azure-specific debugging and logging
  • Certificate-based service principal authentication

References


🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Summary by CodeRabbit

  • New Features

    • Native Azure authentication (device-code, CLI, OIDC), subscription-scoped identities, tenant-aware portal sign-in links, in-process credential handling, secure on-disk credential management, MSAL/token cache and Azure CLI profile sync, and environment preparation for Terraform/tool compatibility.
  • Bug Fixes

    • Azure console access now returns tenant-scoped portal links instead of an error.
  • Documentation

    • Added Azure auth guide, tutorials, CLI docs, and a blog post.
  • Tests

    • Extensive unit tests covering Azure providers, identities, file/cache, MSAL cache, console URLs, and env prep.
fix: Pin Helm to v3.19.2 to avoid Helm 4.0 plugin verification issues @osterman (#1785) ## what - Pins Helm to v3.19.2 (latest 3.x version) in CI workflows - Updates helmfile-action to use pinned helm-version parameter - Replaces apt-get helm installation with azure/setup-helm action for version control

why

Helm 4.0 was released with breaking changes to plugin verification that causes the helm-diff plugin installation to fail with "Error: plugin source does not support verification". Pinning to Helm 3.x ensures compatibility with the existing helm-diff plugin until it's updated to support Helm 4.0.

references

  • Closes plugin verification issues in Helm 4.0
  • Maintains compatibility with current helm-diff plugin

Summary by CodeRabbit

  • Chores
    • Updated test workflow configuration to explicitly specify Helm version for improved consistency and reliability in CI/CD testing infrastructure.

🚀 Enhancements

fix: Prevent usage error after successful workflow TUI execution @aknysh (#1796) ## what
  • Fixed workflow command to return immediately after successful TUI execution
  • Added comprehensive tests for ExecuteWorkflowCmd function
  • Increased workflow test coverage from 1.7% to 2.8% (+64.7%)
  • Added regression test to prevent future occurrences of this bug

why

  • When using the workflow TUI (atmos workflow with no args), the command would show "Incorrect Usage" message after successfully selecting and displaying a workflow
  • This happened because after the TUI execution returned successfully, the code continued to check for the --file flag, which was never set when using the TUI
  • The fix adds an early return nil after successful TUI execution to prevent the unwanted usage error
  • The regression test ensures that workflow execution with the --file flag continues to work correctly

references

Summary by CodeRabbit

  • Bug Fixes

    • Workflow command no longer displays spurious usage errors when run without arguments or without a file flag.
  • Tests

    • Added comprehensive tests covering workflow execution, flag handling, path resolution, dry-run, stack/from-step/identity flags, and error cases.
  • Chores

    • Bumped several dependency versions and updated license entries.
  • Fixtures

    • Added a test workflow that exercises a failing shell command scenario.
fix: Propagate auth context through nested `!terraform.state` functions @aknysh (#1786) ## what
  • Fixed authentication context not propagating through nested !terraform.state and !terraform.output YAML function evaluations
  • Added AuthManager field to ConfigAndStacksInfo struct to enable auth propagation through the execution pipeline
  • Implemented component-level authentication override for nested functions, allowing each component to optionally define its own auth: configuration
  • Enhanced auth resolver to check for default identities before creating component-specific AuthManager
  • Updated TerraformStateGetter and TerraformOutputGetter interfaces to accept authManager parameter
  • Added comprehensive test fixtures and test suites for nested authentication scenarios (18 tests covering 5 scenarios)
  • Fixed identity selector exit handling: Pressing Ctrl+C or ESC now immediately exits with proper POSIX exit code (130) instead of requiring multiple presses or continuing execution
  • Fixed authentication prompt for invalid components: Component validation now occurs before authentication, preventing identity selection prompts when the component doesn't exist

why

Problem 1: Nested Authentication Propagation

When executing Atmos commands with authentication enabled, nested !terraform.state functions failed with IMDS timeout errors even though the top-level command had valid authenticated credentials. This occurred when a component's configuration contained !terraform.state functions that referenced other components which themselves contained !terraform.state functions.

Root Cause: The GetTerraformState() function received an authContext parameter but did not have access to the AuthManager. When processing nested components, it called ExecuteDescribeComponent() without an AuthManager, breaking the authentication chain at level 2+ of nesting.

Example Failure:

# Level 1: tgw/routes (top-level, ✅ works)
tgw/routes:
  vars:
    routes:
      - attachment_id: !terraform.state tgw/attachment vpc_attachment_id

# Level 2: tgw/attachment (nested, ✅ works)
tgw/attachment:
  vars:
    transit_gateway_id: !terraform.state tgw/hub core-use2-network transit_gateway_id  # ❌ FAILS - no auth

# Level 3: tgw/hub (nested within nested, ❌ fails)

Solution: Added AuthManager to ConfigAndStacksInfo struct and threaded it through the entire execution pipeline, enabling all nested function evaluations to access authenticated credentials. Additionally implemented component-level auth override to support cross-account state reading in nested scenarios.


Problem 2: Identity Selector Exit Handling

When the identity selector appeared (either from --identity flag without value, or when processing YAML functions with no default identity configured), pressing Ctrl+C would not exit the program. Instead:

  • First Ctrl+C press was consumed by the huh TUI library but returned ErrUserAborted
  • The autoDetectDefaultIdentity() function intentionally swallowed ALL errors (including ErrUserAborted) for "backward compatibility"
  • The function returned ("", nil), causing execution to continue without authentication
  • User had to press Ctrl+C a second time to actually exit

Root Cause: The error handling in pkg/auth/manager_helpers.go:autoDetectDefaultIdentity() was catching ErrUserAborted from the identity selector and converting it to a successful empty result for backward compatibility, preventing proper exit handling.

Solution:

  1. Modified autoDetectDefaultIdentity() to propagate ErrUserAborted while preserving backward compatibility for other errors
  2. Added exit handlers in terraform.go and terraform_utils.go to immediately exit with code 130 when user aborts
  3. Enhanced identity selector with custom KeyMap to support both Ctrl+C and ESC keys
  4. Added visible instruction: "Press ctrl+c or esc to exit"
  5. Created constant ExitCodeSIGINT = 130 for POSIX-compliant signal exit codes

Problem 3: Authentication Before Component Validation

When running a command with an invalid component name, Atmos would prompt for identity selection before checking if the component exists:

atmos terraform apply bad-component -s core-euc1-network
# Prompted for identity selection first
# Then showed error: Could not find the component 'bad-component' in the stack

Root Cause: The authentication flow in ExecuteTerraform() was calling CreateAndAuthenticateManager() before the component existence check, causing unnecessary user interaction for invalid components.

Solution: Modified the component auth config retrieval logic to immediately exit if ExecuteDescribeComponent() returns ErrInvalidComponent, preventing authentication attempts for non-existent components.


Benefits:

  • ✅ Nested !terraform.state functions now work at any depth with proper authentication
  • ✅ Components can override authentication at any nesting level for cross-account scenarios
  • ✅ No IMDS timeout errors when processing nested component configurations
  • ✅ Identity selector no longer shows incorrectly for components without default identity
  • ✅ Cleaner debug logs with reduced noise from expected auth resolution paths
  • Ctrl+C and ESC immediately exit the identity selector (single keypress, exit code 130)
  • No error message displayed on user abort (clean exit)
  • Clear exit instructions shown to users in the selector UI
  • No authentication prompt for invalid components (validation happens first)

references

  • Related to PR #1769 (fixed authentication for YAML functions with --identity flag)
  • See docs/fixes/nested-terraform-state-auth-context-propagation.md for detailed technical analysis and implementation design

Summary by CodeRabbit

  • New Features

    • Component-level authentication overrides for nested Terraform functions enable fine-grained control over credentials in multi-account setups.
  • Bug Fixes

    • Fixed authentication context propagation through nested Terraform state and output evaluations.
    • Improved user experience when canceling interactive identity selection.
  • Documentation

    • Added comprehensive guides on authentication flows for Terraform YAML functions and nested authentication handling.
  • Chores

    • Updated AWS SDK and Go dependencies to latest versions.

Don't miss a new atmos release

NewReleases is sending notifications on new releases.