diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index ccd026c124c..eb75d6e8f3e 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -175,7 +175,8 @@ jobs: # GO-2026-6597 (containerd/v2 < 2.3.6) landed — which exceeds the public # runner's 16GB RAM and gets the runner OOM-killed (seen as `Killed`, # exit 143 "shutdown signal", or "The operation was canceled"). Swap - # absorbs the overflow; request 30 GiB for the full scan. + # absorbs the overflow. 20G still let loaded runners thrash past the step + # timeout, so add 30G. - name: Add swap space uses: ./.github/actions/swap-space with: @@ -200,7 +201,7 @@ jobs: # tried earlier and rejected: it barely reduced peak memory # (govulncheck's SSA construction parallelizes via goroutines, which # -p doesn't govern) while nearly tripling run time. - GOMEMLIMIT: "32GiB" + GOMEMLIMIT: "42GiB" # The target also removes exact duplicate stacks from the report: the # SARIF schema requires them to be unique and the upload rejects the # report otherwise. See internal/ci/vulncheck. @@ -393,7 +394,7 @@ jobs: # Key settings: # - install-mode: none - Tells the action to use the binary already in PATH # (our custom-gcl that we just installed) - # - only-new-issues: true - Only report issues in changed code + # - only-new-issues / --new-from-merge-base - Only report issues in changed code # - SARIF output - For GitHub Advanced Security / CodeQL integration # - issues-exit-code: 0 - Always exit 0 so we upload SARIF to CodeQL # @@ -417,10 +418,17 @@ jobs: # can fail transiently. The subsequent lint command still parses and # validates the configuration, so skip the duplicate network preflight. verify: false - only-new-issues: true + # Pull requests filter with git (--new-from-merge-base) instead of the + # action's only-new-issues. only-new-issues downloads the PR diff from the + # GitHub API, which refuses diffs over 20000 lines; the action then silently + # falls back to linting the whole repository and uploads every pre-existing + # finding to code scanning. Git has no such limit. The two options cannot be + # combined, so only-new-issues stays on for the other events (merge queue). + only-new-issues: ${{ github.event_name != 'pull_request' }} args: > --output.sarif.path=golangci-lint.sarif --issues-exit-code=0 + ${{ github.event_name == 'pull_request' && format('--new-from-merge-base=origin/{0}', github.base_ref) || '' }} - name: Upload filtered SARIF results # merge_group's ephemeral gh-readonly-queue/... ref is deleted as soon diff --git a/.github/workflows/plugin-sdk.yml b/.github/workflows/plugin-sdk.yml index 2a77c25cfbf..7af1f3d75f9 100644 --- a/.github/workflows/plugin-sdk.yml +++ b/.github/workflows/plugin-sdk.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 with: persist-credentials: false - - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0 + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version-file: go.mod cache-dependency-path: | @@ -70,7 +70,7 @@ jobs: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 with: persist-credentials: false - - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0 + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version-file: go.mod architecture: ${{ runner.arch == 'ARM64' && 'arm64' || 'x64' }} diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index c66a6a7dc7d..fb89cbc90fd 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -2330,6 +2330,12 @@ func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []strin if doubleDashIndex > 0 { finalArgs = lo.Slice(args, 0, doubleDashIndex) argsAfterDoubleDash = lo.Slice(args, doubleDashIndex+1, len(args)) + } else if len(args) > 0 { + // Callers prepend the operation name; Cobra's separator index applies + // only to the remaining RunE arguments, after it consumed the literal --. + positional, separated := pkgFlags.SplitArgsAtDash(cmd, args[1:]) + finalArgs = append([]string{args[0]}, positional...) + argsAfterDoubleDash = separated } info, err := e.ProcessCommandLineArgs(commandName, cmd, finalArgs, argsAfterDoubleDash) diff --git a/cmd/helmfile/utils.go b/cmd/helmfile/utils.go index 3c0dff371ba..0a9b7816317 100644 --- a/cmd/helmfile/utils.go +++ b/cmd/helmfile/utils.go @@ -10,6 +10,7 @@ import ( errUtils "github.com/cloudposse/atmos/errors" e "github.com/cloudposse/atmos/internal/exec" cfg "github.com/cloudposse/atmos/pkg/config" + "github.com/cloudposse/atmos/pkg/flags" log "github.com/cloudposse/atmos/pkg/logger" "github.com/cloudposse/atmos/pkg/perf" "github.com/cloudposse/atmos/pkg/schema" @@ -62,6 +63,11 @@ func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []strin if doubleDashIndex > 0 { finalArgs = lo.Slice(args, 0, doubleDashIndex) argsAfterDoubleDash = lo.Slice(args, doubleDashIndex+1, len(args)) + } else if len(args) > 0 { + // The synthetic operation name is not part of Cobra's RunE argument slice. + positional, separated := flags.SplitArgsAtDash(cmd, args[1:]) + finalArgs = append([]string{args[0]}, positional...) + argsAfterDoubleDash = separated } info, err := e.ProcessCommandLineArgs(commandName, cmd, finalArgs, argsAfterDoubleDash) @@ -104,7 +110,8 @@ func resolveComponentPath(info *schema.ConfigAndStacksInfo, commandName string) return handlePathResolutionError(err) } - log.Debug("Resolved component from path", + log.Debug( + "Resolved component from path", "original_path", info.ComponentFromArg, "resolved_component", resolvedComponent, "stack", info.Stack, diff --git a/cmd/packer_passthrough_contract_test.go b/cmd/packer_passthrough_contract_test.go new file mode 100644 index 00000000000..45aafaf4ab2 --- /dev/null +++ b/cmd/packer_passthrough_contract_test.go @@ -0,0 +1,66 @@ +package cmd + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" +) + +// Exercise Cobra and the actual subprocess boundary, rather than copying separator logic. +func TestNativeCommandSeparatorPreservesArgv(t *testing.T) { + for _, family := range []string{"packer", "helmfile"} { + t.Run(family, func(t *testing.T) { + _ = NewTestKit(t) + root := t.TempDir() + require.NoError(t, os.MkdirAll(filepath.Join(root, "stacks"), 0o755)) + componentDir := filepath.Join(root, "components", family, "probe") + require.NoError(t, os.MkdirAll(componentDir, 0o755)) + executable, err := os.Executable() + require.NoError(t, err) + config := fmt.Sprintf("base_path: %q\ncomponents:\n %s:\n base_path: components/%s\n command: %q\nstacks:\n base_path: stacks\n included_paths: ['*.yaml']\n name_template: '{{ .vars.stage }}'\n", filepath.ToSlash(root), family, family, filepath.ToSlash(executable)) + require.NoError(t, os.WriteFile(filepath.Join(root, "atmos.yaml"), []byte(config), 0o600)) + stack := fmt.Sprintf("vars: {stage: dev}\ncomponents:\n %s:\n probe: {}\n", family) + require.NoError(t, os.WriteFile(filepath.Join(root, "stacks", "dev.yaml"), []byte(stack), 0o600)) + require.NoError(t, os.WriteFile(filepath.Join(componentDir, "main.pkr.hcl"), []byte("// fake engine fixture\n"), 0o600)) + require.NoError(t, os.WriteFile(filepath.Join(componentDir, "helmfile.yaml"), []byte("releases: []\n"), 0o600)) + t.Chdir(root) + t.Setenv("ATMOS_CLI_CONFIG_PATH", root) + capture := filepath.Join(root, "argv.json") + t.Setenv("_ATMOS_TEST_DUMP_ARGS", capture) + operation, native := "validate", []string{"-syntax-only", "-var", "label=probe probe", "-var", "name=probe"} + if family == "helmfile" { + operation, native = "template", []string{"--set", "label=probe probe", "--set", "name=probe"} + } + args := append([]string{family, operation, "probe", "-s", "dev", "--"}, native...) + RootCmd.SetArgs(args) + require.NoError(t, Execute()) + raw, err := os.ReadFile(capture) + require.NoError(t, err, "the native process must actually execute") + var actual []string + require.NoError(t, json.Unmarshal(raw, &actual)) + // Extra Atmos-generated args may precede/follow native args. Find the entire + // contiguous sequence to assert ordering, spacing, and duplicate values. + found := false + for i := 0; i+len(native) <= len(actual); i++ { + match := true + for j := range native { + if actual[i+j] != native[j] { + match = false + break + } + } + if match { + found = true + break + } + } + require.True(t, found, "native argv %q missing from actual %q", native, actual) + require.Contains(t, actual, operation) + require.NotContains(t, actual, "--") + }) + } +} diff --git a/cmd/root.go b/cmd/root.go index e5669ef8b44..edd523315b3 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -110,11 +110,13 @@ import ( "github.com/cloudposse/atmos/pkg/proexec" atmosprofile "github.com/cloudposse/atmos/pkg/profile" "github.com/cloudposse/atmos/pkg/profiler" + "github.com/cloudposse/atmos/pkg/provisioner/source" "github.com/cloudposse/atmos/pkg/schema" "github.com/cloudposse/atmos/pkg/startup" "github.com/cloudposse/atmos/pkg/telemetry" "github.com/cloudposse/atmos/pkg/terminal" terminalenv "github.com/cloudposse/atmos/pkg/terminal/env" + tfoutput "github.com/cloudposse/atmos/pkg/terraform/output" "github.com/cloudposse/atmos/pkg/toolchain" "github.com/cloudposse/atmos/pkg/ui" "github.com/cloudposse/atmos/pkg/ui/heatmap" @@ -1753,6 +1755,10 @@ func Execute() error { atmosGit.ResetRootTagCache() defer atmosGit.ResetRootTagCache() defer initcmd.SetAtmosConfig(nil) + tfoutput.ResetWorkdirProvisionCache() + defer tfoutput.ResetWorkdirProvisionCache() + restoreSourceInvocation := source.BeginInvocation() + defer restoreSourceInvocation() executionID, restoreInvocation := proexec.BeginInvocation() defer restoreInvocation() defer perf.Track(&atmosConfig, "cmd.Execute")() diff --git a/cmd/terraform/backend/backend_commands_test.go b/cmd/terraform/backend/backend_commands_test.go index aafeb1e817a..d11dbcfc09c 100644 --- a/cmd/terraform/backend/backend_commands_test.go +++ b/cmd/terraform/backend/backend_commands_test.go @@ -166,6 +166,7 @@ func TestExecuteDeleteCommandWithValues(t *testing.T) { } } +// TestSetConfigInitializer tests the SetConfigInitializer function. func TestSetConfigInitializer(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() diff --git a/cmd/terraform/backend/backend_contract_test.go b/cmd/terraform/backend/backend_contract_test.go new file mode 100644 index 00000000000..6142633bddf --- /dev/null +++ b/cmd/terraform/backend/backend_contract_test.go @@ -0,0 +1,82 @@ +package backend + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + + cfg "github.com/cloudposse/atmos/pkg/config" + "github.com/cloudposse/atmos/pkg/function/yamlsource" + "github.com/cloudposse/atmos/pkg/schema" + u "github.com/cloudposse/atmos/pkg/utils" +) + +func TestBackendEnvironmentResolutionIsScoped(t *testing.T) { + dir := t.TempDir() + require.NoError(t, os.MkdirAll(filepath.Join(dir, "stacks"), 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(dir, "atmos.yaml"), []byte(`base_path: . +components: + terraform: + base_path: components/terraform +stacks: + base_path: stacks + included_paths: ['*.yaml'] + name_template: '{{ .vars.stage }}' +`), 0o600)) + require.NoError(t, os.WriteFile(filepath.Join(dir, "stacks", "dev.yaml"), []byte(`vars: {stage: dev} +components: + terraform: + probe: + env: {FIELD_BUCKET: component-bucket} + vars: + untouched: !terraform.output missing dev value + backend_type: s3 + backend: + s3: + bucket: !env FIELD_BUCKET + key: !env FIELD_KEY fallback.tfstate + region: us-east-1 + endpoints: + s3: !env FIELD_ENDPOINT + account: !terraform.state missing dev account + workspace_key_prefix: '!env FIELD_BUCKET' + fallback: !env FIELD_TEST_UNSET default-value +`), 0o600)) + t.Chdir(dir) + t.Setenv("ATMOS_CLI_CONFIG_PATH", dir) + t.Setenv("FIELD_BUCKET", "process-bucket") + t.Setenv("FIELD_KEY", "reviewed.tfstate") + t.Setenv("FIELD_ENDPOINT", "http://127.0.0.1:4566") + t.Setenv("FIELD_TEST_UNSET", "") + require.NoError(t, os.Unsetenv("FIELD_TEST_UNSET")) + config, err := CreateDescribeComponentFunc(nil)("probe", "dev") + require.NoError(t, err) + backend := config["backend"].(map[string]any) + require.Equal(t, "component-bucket", backend["bucket"]) + require.Equal(t, "reviewed.tfstate", backend["key"]) + require.Equal(t, "http://127.0.0.1:4566", backend["endpoints"].(map[string]any)["s3"]) + account, ok := yamlsource.Decode(backend["account"].(string)) + require.True(t, ok, "state lookup must stay deferred") + require.Equal(t, "!terraform.state", account.Tag) + require.Equal(t, "!env FIELD_BUCKET", backend["workspace_key_prefix"], "ordinary strings must retain explicit-tag policy") + require.Equal(t, "default-value", backend["fallback"]) + // Explicit auth disable still bypasses any configured identity selection. + loaded, context, err := InitConfigAndAuth("probe", "dev", cfg.IdentityFlagDisabledValue, false, false) + require.NoError(t, err) + require.Nil(t, context) + // Config initialization intentionally does not load stacks; the production + // callback must still perform its own stack discovery before evaluation. + resolved, err := createDescribeComponentFunc(loaded, nil)("probe", "dev") + require.NoError(t, err) + require.Equal(t, "component-bucket", resolved["backend"].(map[string]any)["bucket"]) +} + +func TestBackendEnvironmentRejectsMalformedTag(t *testing.T) { + config := map[string]any{"backend": map[string]any{"bucket": yamlsource.Source{Tag: "!env"}.Encode()}} + _, err := resolveBackendEnvironment(&schema.AtmosConfiguration{}, config, "probe", "dev") + require.ErrorIs(t, err, u.ErrInvalidAtmosYAMLFunction) +} + +var _ = schema.ConfigAndStacksInfo{ComponentEnvSection: nil} diff --git a/cmd/terraform/backend/backend_delete.go b/cmd/terraform/backend/backend_delete.go index 91ee3007dc0..c1592485035 100644 --- a/cmd/terraform/backend/backend_delete.go +++ b/cmd/terraform/backend/backend_delete.go @@ -17,8 +17,9 @@ var deleteCmd = &cobra.Command{ Short: "Delete backend infrastructure", Long: `Permanently delete backend infrastructure. -Requires the --force flag for safety. The backend must be empty -(no state files) before it can be deleted.`, +Requires --force even when the backend is empty. With --force, stored state +and other backend contents are permanently deleted before the backend is removed. +Back up any state you need before forcing deletion.`, Example: ` atmos terraform backend delete vpc --stack dev --force`, // Args validator is auto-set by parser via SetPositionalArgs with prompt-aware validation. RunE: func(cmd *cobra.Command, args []string) error { @@ -71,7 +72,7 @@ func init() { deleteParser = flags.NewStandardParser( flags.WithStackFlag(), flags.WithIdentityFlag(), - flags.WithBoolFlag("force", "", false, "Force deletion without confirmation"), + flags.WithBoolFlag("force", "", false, "Delete backend contents, including stored Terraform state, before deleting the backend"), flags.WithEnvVars("force", "ATMOS_FORCE"), // Enable prompting for missing stack flag. flags.WithCompletionPrompt("stack", "Choose a stack", shared.StackFlagCompletion), diff --git a/cmd/terraform/backend/backend_helpers.go b/cmd/terraform/backend/backend_helpers.go index ec409afa948..e3f55c3e1c3 100644 --- a/cmd/terraform/backend/backend_helpers.go +++ b/cmd/terraform/backend/backend_helpers.go @@ -5,6 +5,7 @@ package backend import ( "errors" "fmt" + "strings" errUtils "github.com/cloudposse/atmos/errors" e "github.com/cloudposse/atmos/internal/exec" @@ -12,6 +13,7 @@ import ( cfg "github.com/cloudposse/atmos/pkg/config" "github.com/cloudposse/atmos/pkg/provisioner" "github.com/cloudposse/atmos/pkg/schema" + u "github.com/cloudposse/atmos/pkg/utils" ) // ConfigInitializer abstracts configuration and auth initialization for testability. @@ -149,6 +151,7 @@ func InitConfigAndAuth(component, stack, identity string, componentPrompted, sta ProcessYamlFunctions: false, Skip: nil, AuthManager: nil, // Don't need auth to describe component + AuthDisabled: true, }) if err != nil { return nil, nil, fmt.Errorf("failed to load component config: %w", err) @@ -190,16 +193,56 @@ func InitConfigAndAuth(component, stack, identity string, componentPrompted, sta // CreateDescribeComponentFunc creates a describe component function with the given authManager. func CreateDescribeComponentFunc(authManager auth.AuthManager) func(string, string) (map[string]any, error) { + return createDescribeComponentFunc(nil, authManager) +} + +// createDescribeComponentFunc resolves only backend environment references after authentication. +// Other functions remain deferred: provisioning a backend must not require its own state. +func createDescribeComponentFunc(atmosConfig *schema.AtmosConfiguration, authManager auth.AuthManager) func(string, string) (map[string]any, error) { return func(component, stack string) (map[string]any, error) { - return e.ExecuteDescribeComponent(&e.ExecuteDescribeComponentParams{ + effectiveConfig := atmosConfig + config, err := e.ExecuteDescribeComponent(&e.ExecuteDescribeComponentParams{ Component: component, Stack: stack, ProcessTemplates: false, ProcessYamlFunctions: false, Skip: nil, AuthManager: authManager, + AuthDisabled: authManager == nil, }) + if err != nil { + return nil, err + } + if effectiveConfig == nil { + loaded, err := cfg.InitCliConfig(schema.ConfigAndStacksInfo{ComponentFromArg: component, Stack: stack}, false) + if err != nil { + return nil, err + } + effectiveConfig = &loaded + } + return resolveBackendEnvironment(effectiveConfig, config, component, stack) + } +} + +func resolveBackendEnvironment(atmosConfig *schema.AtmosConfiguration, config map[string]any, component, stack string) (map[string]any, error) { + // Use the normal evaluator so explicit-tag provenance, edition policy, defaults, + // and component-env precedence remain the same as other stack consumers. + skip := make([]string, 0, len(u.AtmosYamlTags)) + for _, tag := range u.AtmosYamlTags { + if tag != u.AtmosYamlFuncEnv { + skip = append(skip, strings.TrimPrefix(tag, "!")) + } + } + env, _ := config[cfg.EnvSectionName].(map[string]any) + info := &schema.ConfigAndStacksInfo{ComponentFromArg: component, Stack: stack, ComponentEnvSection: env} + backend, err := e.ProcessCustomYamlTags(atmosConfig, schema.AtmosSectionMapType{ + "backend": config["backend"], "backend_type": config["backend_type"], + }, stack, skip, info) + if err != nil { + return nil, fmt.Errorf("failed to resolve backend environment: %w", err) } + config["backend"], config["backend_type"] = backend["backend"], backend["backend_type"] + return config, nil } // executeProvisionCommandWithValues is the internal implementation that accepts already-parsed values. @@ -220,19 +263,9 @@ func executeProvisionCommandWithValues(component, stack, identity string, prompt return err } - // Create describe component callback. - // Note: We don't need to pass authContext to the describe function for backend provisioning - // since we already loaded the component config in InitConfigAndAuth. - describeFunc := func(component, stack string) (map[string]any, error) { - return e.ExecuteDescribeComponent(&e.ExecuteDescribeComponentParams{ - Component: component, - Stack: stack, - ProcessTemplates: false, - ProcessYamlFunctions: false, - Skip: nil, - AuthManager: nil, // Auth already handled. - }) - } + // Authentication is already complete. Only environment references are evaluated; + // the selected auth context is passed directly to the backend provisioner below. + describeFunc := createDescribeComponentFunc(atmosConfig, nil) // Execute provision command using injected provisioner. return prov.CreateBackend(&CreateBackendParams{ @@ -263,7 +296,7 @@ func executeDeleteCommandWithValues(component, stack, identity string, force boo } // Create describe component callback. - describeFunc := CreateDescribeComponentFunc(nil) // Auth already handled in InitConfigAndAuth. + describeFunc := createDescribeComponentFunc(atmosConfig, nil) // Execute delete command using injected provisioner. return prov.DeleteBackend(&DeleteBackendParams{ diff --git a/cmd/terraform/plan.go b/cmd/terraform/plan.go index 7e05807ce53..177b10eb47d 100644 --- a/cmd/terraform/plan.go +++ b/cmd/terraform/plan.go @@ -45,6 +45,14 @@ For complete Terraform/OpenTofu documentation, see: // component, so the global error call is suppressed to avoid double-firing. defer func() { if runErr != nil && !wasMultiComponentExecution { + // Detailed exit 2 is a successful plan. Cobra still skips PostRunE, + // so dispatch once here and honor failures from required after-hooks. + if terraformHookOutcome(h.AfterTerraformPlan, runErr).Status == h.RunSuccess { + if hookErr := runHooksWithResult(h.AfterTerraformPlan, cmd, args, capturedPlanOutput, runErr); hookErr != nil { + runErr = hookErr + } + return + } runHooksOnErrorWithOutput(h.AfterTerraformPlan, cmd, args, runErr, capturedPlanOutput) } }() diff --git a/cmd/terraform/plan_hook_outcome_test.go b/cmd/terraform/plan_hook_outcome_test.go new file mode 100644 index 00000000000..90edbbc2fac --- /dev/null +++ b/cmd/terraform/plan_hook_outcome_test.go @@ -0,0 +1,216 @@ +package terraform + +import ( + "errors" + "fmt" + "os" + "path/filepath" + "testing" + + "github.com/spf13/cobra" + "github.com/stretchr/testify/require" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/ci" + githubCI "github.com/cloudposse/atmos/pkg/ci/providers/github" + h "github.com/cloudposse/atmos/pkg/hooks" +) + +func TestTerraformHookOutcomePreservesDetailedPlanStatus(t *testing.T) { + for _, test := range []struct { + name string + event h.HookEvent + err error + status h.RunStatus + code int + }{ + {"unchanged plan", h.AfterTerraformPlan, nil, h.RunSuccess, 0}, + {"changed plan", h.AfterTerraformPlan, fmt.Errorf("plan: %w", errUtils.ExitCodeError{Code: 2}), h.RunSuccess, 2}, + {"failed plan", h.AfterTerraformPlan, errUtils.ExitCodeError{Code: 1}, h.RunFailure, 1}, + {"apply exit two", h.AfterTerraformApply, errUtils.ExitCodeError{Code: 2}, h.RunFailure, 2}, + {"policy denied after changes", h.AfterTerraformPlan, errors.Join(errUtils.ExitCodeError{Code: 2}, errUtils.ErrPolicyDenied), h.RunFailure, 2}, + {"policy evaluation after changes", h.AfterTerraformPlan, errors.Join(errUtils.ExitCodeError{Code: 2}, errUtils.ErrPolicyEvaluation), h.RunFailure, 2}, + {"exit two from init", h.AfterTerraformPlan, errUtils.AsPrerequisiteError(errUtils.ExitCodeError{Code: 2}), h.RunFailure, 2}, + {"exit two from wrapped workspace selection", h.AfterTerraformPlan, fmt.Errorf("workspace: %w", errUtils.AsPrerequisiteError(errUtils.ExitCodeError{Code: 2})), h.RunFailure, 2}, + {"exit two from before hook", h.AfterTerraformPlan, fmt.Errorf("%w: %w", errUtils.ErrPerComponentHookFailed, errUtils.AsPrerequisiteError(errUtils.ExitCodeError{Code: 2})), h.RunFailure, 2}, + } { + t.Run(test.name, func(t *testing.T) { + actual := terraformHookOutcome(test.event, test.err) + require.Equal(t, test.status, actual.Status) + require.Equal(t, test.code, actual.ExitCode) + if test.status == h.RunSuccess { + require.NoError(t, actual.Err) + } else { + require.ErrorIs(t, actual.Err, test.err) + } + require.Equal(t, test.code, errUtils.GetExitCode(test.err), "external command exit remains unchanged") + }) + } +} + +func TestDetailedPlanEnforcesRequiredAfterHook(t *testing.T) { + root := t.TempDir() + require.NoError(t, os.MkdirAll(filepath.Join(root, "stacks"), 0o755)) + require.NoError(t, os.MkdirAll(filepath.Join(root, "components", "terraform", "probe"), 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(root, "atmos.yaml"), []byte(`base_path: . +components: + terraform: + base_path: components/terraform +stacks: + base_path: stacks + included_paths: ['*.yaml'] + name_template: '{{ .vars.stage }}' +`), 0o600)) + require.NoError(t, os.WriteFile(filepath.Join(root, "stacks", "dev.yaml"), []byte(`vars: {stage: dev} +components: + terraform: + probe: + hooks: + required-after: + kind: step + type: script + events: [after.terraform.plan] + on_failure: fail + with: + interpreter: starlark + script: 'fail("required-after-plan-was-enforced")' +`), 0o600)) + t.Chdir(root) + t.Setenv("ATMOS_CLI_CONFIG_PATH", root) + withoutCIDetection(t) + command := newHookTestCmd() + require.NoError(t, command.Flags().Set("stack", "dev")) + require.ErrorContains(t, runHooksWithResult(h.AfterTerraformPlan, command, []string{"probe"}, "", errUtils.ExitCodeError{Code: 2}), "required-after-plan-was-enforced") + // A failed engine plan must not run this success-only hook. + require.NoError(t, runHooksWithResult(h.AfterTerraformPlan, command, []string{"probe"}, "", errUtils.ExitCodeError{Code: 1})) + // A before-hook exit 2 must not run success hooks for a plan that never executed. + beforeErr := fmt.Errorf("%w: %w", errUtils.ErrPerComponentHookFailed, errUtils.AsPrerequisiteError(errUtils.ExitCodeError{Code: 2})) + require.NoError(t, runHooksWithResult(h.AfterTerraformPlan, command, []string{"probe"}, "", beforeErr)) +} + +// Exercise planCmd's deferred dispatch with a real child process returning Terraform's +// detailed exit code, rather than invoking the hook dispatcher directly. +func TestPlanCommandDispatchesSuccessHookOnDetailedExit(t *testing.T) { + root := t.TempDir() + require.NoError(t, os.MkdirAll(filepath.Join(root, "stacks"), 0o755)) + require.NoError(t, os.MkdirAll(filepath.Join(root, "components", "terraform", "probe"), 0o755)) + executable, err := os.Executable() + require.NoError(t, err) + require.NoError(t, os.WriteFile(filepath.Join(root, "atmos.yaml"), []byte(fmt.Sprintf(`base_path: . +components: + terraform: + base_path: components/terraform + command: %q + auto_generate_backend_file: false +stacks: + base_path: stacks + included_paths: ['*.yaml'] + name_template: '{{ .vars.stage }}' +`, executable)), 0o600)) + require.NoError(t, os.WriteFile(filepath.Join(root, "stacks", "dev.yaml"), []byte(`vars: {stage: dev} +components: + terraform: + probe: + hooks: + required-after: + kind: step + type: script + events: [after.terraform.plan] + on_failure: fail + with: + interpreter: starlark + script: 'fail("required-after-plan-was-enforced")' +`), 0o600)) + t.Chdir(root) + t.Setenv("ATMOS_CLI_CONFIG_PATH", root) + t.Setenv("_ATMOS_TEST_PLAN_EXIT_TWO", "1") + withoutCIDetection(t) + initOutputTestIO(t) + rootCmd := &cobra.Command{Use: "atmos"} + rootCmd.PersistentFlags().String("base-path", "", "") + rootCmd.PersistentFlags().StringSlice("config", nil, "") + rootCmd.PersistentFlags().StringSlice("config-path", nil, "") + rootCmd.PersistentFlags().StringSlice("profile", nil, "") + oldParent := terraformCmd.Parent() + rootCmd.AddCommand(terraformCmd) + t.Cleanup(func() { + rootCmd.RemoveCommand(terraformCmd) + if oldParent != nil { + oldParent.AddCommand(terraformCmd) + } + }) + stackFlag := terraformCmd.PersistentFlags().Lookup("stack") + oldStack, stackChanged := stackFlag.Value.String(), stackFlag.Changed + skipInitFlag := terraformCmd.PersistentFlags().Lookup("skip-init") + oldSkipInit, skipInitChanged := skipInitFlag.Value.String(), skipInitFlag.Changed + t.Cleanup(func() { + _ = terraformCmd.PersistentFlags().Set("stack", oldStack) + stackFlag.Changed = stackChanged + _ = terraformCmd.PersistentFlags().Set("skip-init", oldSkipInit) + skipInitFlag.Changed = skipInitChanged + }) + require.NoError(t, terraformCmd.PersistentFlags().Set("stack", "dev")) + require.NoError(t, terraformCmd.PersistentFlags().Set("skip-init", "true")) + require.ErrorContains(t, planCmd.RunE(planCmd, []string{"probe"}), "required-after-plan-was-enforced") +} + +func TestPrerequisiteErrorKeepsMessageAndChain(t *testing.T) { + require.NoError(t, errUtils.AsPrerequisiteError(nil)) + original := fmt.Errorf("init failed: %w", errUtils.ExitCodeError{Code: 3}) + wrapped := errUtils.AsPrerequisiteError(original) + require.EqualError(t, wrapped, original.Error()) + require.ErrorIs(t, wrapped, original) + require.Equal(t, 3, errUtils.GetExitCode(wrapped)) +} + +// A required after-hook that fails on a detailed plan must not suppress the CI result: the CI hooks +// publish the plan summary first and the hook failure is returned afterwards. +func TestDetailedPlanPublishesCIResultBeforeReturningRequiredHookFailure(t *testing.T) { + root := t.TempDir() + require.NoError(t, os.MkdirAll(filepath.Join(root, "stacks"), 0o755)) + require.NoError(t, os.MkdirAll(filepath.Join(root, "components", "terraform", "probe"), 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(root, "atmos.yaml"), []byte(`base_path: . +components: + terraform: + base_path: components/terraform +stacks: + base_path: stacks + included_paths: ['*.yaml'] + name_template: '{{ .vars.stage }}' +ci: + enabled: true +`), 0o600)) + require.NoError(t, os.WriteFile(filepath.Join(root, "stacks", "dev.yaml"), []byte(`vars: {stage: dev} +components: + terraform: + probe: + hooks: + required-after: + kind: step + type: script + events: [after.terraform.plan] + on_failure: fail + with: + interpreter: starlark + script: 'fail("required-after-plan-was-enforced")' +`), 0o600)) + t.Chdir(root) + t.Setenv("ATMOS_CLI_CONFIG_PATH", root) + summary := filepath.Join(root, "summary.md") + restoreRegistry := ci.SwapRegistryForTest() + t.Cleanup(restoreRegistry) + ci.Register(githubCI.NewProvider()) + t.Setenv("GITHUB_ACTIONS", "true") + t.Setenv("GITHUB_STEP_SUMMARY", summary) + initOutputTestIO(t) + command := newHookTestCmd() + require.NoError(t, command.Flags().Set("stack", "dev")) + require.NoError(t, command.Flags().Set("ci", "true")) + + planOutput := "Terraform will perform the following actions:\n\nPlan: 1 to add, 0 to change, 0 to destroy.\n" + err := runHooksWithResult(h.AfterTerraformPlan, command, []string{"probe"}, planOutput, errUtils.ExitCodeError{Code: 2}) + require.ErrorContains(t, err, "required-after-plan-was-enforced") + published, readErr := os.ReadFile(summary) + require.NoError(t, readErr, "the CI hooks must still publish the plan result") + require.Contains(t, string(published), "1 to add") +} diff --git a/cmd/terraform/shell.go b/cmd/terraform/shell.go index 73213788748..c07608066b7 100644 --- a/cmd/terraform/shell.go +++ b/cmd/terraform/shell.go @@ -69,7 +69,6 @@ as you would in a typical setup, but within the configured Atmos environment.`, processFunctions := v.GetBool("process-functions") skip := v.GetStringSlice("skip") dryRun := v.GetBool("dry-run") - identity := v.GetString("identity") withSecrets := v.GetBool("with-secrets") // --skip-init is a shared terraform persistent flag (inherited from terraformCmd); // honor it so users can enter the shell without running `terraform init`. @@ -116,7 +115,7 @@ as you would in a typical setup, but within the configured Atmos environment.`, Component: component, Stack: stack, DryRun: dryRun, - Identity: identity, + Identity: globalFlags.Identity.Value(), WithSecrets: withSecrets, SkipInit: skipInit, ProcessingOptions: e.ProcessingOptions{ diff --git a/cmd/terraform/testmain_test.go b/cmd/terraform/testmain_test.go index 5ea044aa8a2..eadf3dd38a7 100644 --- a/cmd/terraform/testmain_test.go +++ b/cmd/terraform/testmain_test.go @@ -18,6 +18,14 @@ import ( // wrapping-contract test in // utils_exit_wrapping_test.go. func TestMain(m *testing.M) { + if os.Getenv("_ATMOS_TEST_PLAN_EXIT_TWO") == "1" { + for _, arg := range os.Args[1:] { + if arg == "plan" { + os.Exit(2) + } + } + os.Exit(0) + } if os.Getenv("_ATMOS_TEST_LIFECYCLE_LOG") != "" { os.Exit(runLifecycleTestProcess()) } diff --git a/cmd/terraform/utils.go b/cmd/terraform/utils.go index d36ad79075b..1e8a6163eba 100644 --- a/cmd/terraform/utils.go +++ b/cmd/terraform/utils.go @@ -288,7 +288,7 @@ var runHooksOnErrorWithOutput = func(event h.HookEvent, cmd_ *cobra.Command, arg // failed"). Cobra skips PostRunE on error, so the success-path runHooks // never runs — this is the only place user hooks see a failed operation. // Errors here are advisory: never mask the original command error. - outcome := h.Outcome{Status: h.RunFailure, Err: cmdErr, ExitCode: errUtils.GetExitCode(cmdErr)} + outcome := terraformHookOutcome(event, cmdErr) if err := runUserHooks(&hctx, event, cmd_, args, outcome); err != nil { log.Warn("hook failed on error path", "error", err) } @@ -311,6 +311,30 @@ var runHooksOnErrorWithOutput = func(event h.HookEvent, cmd_ *cobra.Command, arg } } +// terraformHookOutcome treats a detailed plan with changes as a successful operation. +// The caller still returns the original exit status, and policy failures stay failures. +func terraformHookOutcome(event h.HookEvent, commandErr error) h.Outcome { + if commandErr == nil { + return h.Outcome{Status: h.RunSuccess} + } + outcome := h.Outcome{Status: h.RunFailure, Err: commandErr, ExitCode: errUtils.GetExitCode(commandErr)} + if event.Normalize() != h.AfterTerraformPlan || outcome.ExitCode != 2 { + return outcome + } + // Exit 2 is the plan's own "changes present" status only when the plan subcommand produced it; + // an exit 2 from init or workspace selection is an ordinary failure. + var prerequisiteErr *errUtils.PrerequisiteError + if errors.As(commandErr, &prerequisiteErr) { + return outcome + } + for _, policyErr := range []error{errUtils.ErrPolicyInvalid, errUtils.ErrPolicyPlan, errUtils.ErrPolicyDenied, errUtils.ErrPolicyEvaluation, errUtils.ErrPolicyRequirements} { + if errors.Is(commandErr, policyErr) { + return outcome + } + } + return h.Outcome{Status: h.RunSuccess, ExitCode: outcome.ExitCode} +} + // hookContext bundles the fully-resolved component info and Atmos config shared // by user hooks and CI hooks, so helpers can pass it as one argument. type hookContext struct { @@ -464,15 +488,23 @@ func runUserHooks(hctx *hookContext, event h.HookEvent, cmd_ *cobra.Command, arg } func runHooksWithOutput(event h.HookEvent, cmd_ *cobra.Command, args []string, output string) error { + return runHooksWithResult(event, cmd_, args, output, nil) +} + +// runHooksWithResult preserves detailed plan status while enforcing successful-operation hooks. +func runHooksWithResult(event h.HookEvent, cmd_ *cobra.Command, args []string, output string, commandErr error) error { hctx, err := prepareHookContext(cmd_, args) if err != nil { return err } // Success path: user hooks see a successful outcome (when: success / always). - if err := runUserHooks(&hctx, event, cmd_, args, h.Outcome{Status: h.RunSuccess}); err != nil { - return err + userErr := runUserHooks(&hctx, event, cmd_, args, terraformHookOutcome(event, commandErr)) + if userErr != nil && commandErr == nil { + return userErr } + // A detailed plan (exit 2) reaches here with a command error. A failing required user hook must + // still be returned, but only after the CI hooks publish the plan result. // Check for --ci flag or CI environment variable. resolveCIMode reads // directly from the Cobra flag first (not Viper) because pflags are only @@ -490,23 +522,25 @@ func runHooksWithOutput(event h.HookEvent, cmd_ *cobra.Command, args []string, o // Run CI hooks based on component provider bindings. // This is separate from user-defined hooks and runs automatically when CI is enabled. - // Success path: cmdErr is nil and exit code is 0. + // Preserve exit 2 for CI change detection, even though user hooks see success. if err := h.RunCIHooks(&h.RunCIHooksOptions{ - Event: event, - AtmosConfig: &hctx.atmosConfig, - Info: &hctx.info, - Output: output, - ForceCIMode: forceCIMode, + Event: event, + AtmosConfig: &hctx.atmosConfig, + Info: &hctx.info, + Output: output, + ForceCIMode: forceCIMode, + CommandError: commandErr, + ExitCode: errUtils.GetExitCode(commandErr), }); err != nil { // A misconfigured provider (invalid API URL) fails the command; every other // CI hook error is reported and the command result stands. if errors.Is(err, errUtils.ErrInvalidURL) { - return err + return errors.Join(userErr, err) } log.Warn(ciHookFailedMsg, "error", err) } - return nil + return userErr } // resolveVerifyPlanMode resolves the explicit planfile-verify override from the @@ -1182,10 +1216,7 @@ func (n *terraformNodeHooks) AfterWithWriters(_ context.Context, info *schema.Co // scheduler node, so its resolver must be restored before after-hooks use it. injectHookStoreAuthResolver(&atmosConfig, info) - outcome := h.Outcome{Status: h.RunSuccess} - if execErr != nil { - outcome = h.Outcome{Status: h.RunFailure, Err: execErr, ExitCode: errUtils.GetExitCode(execErr)} - } + outcome := terraformHookOutcome(n.afterEvent, execErr) hookErr := n.runUserHooksForNodeWithWriters(&atmosConfig, info, n.afterEvent, outcome, writers) if !n.skipPerNodeCI { diff --git a/cmd/testkit_test.go b/cmd/testkit_test.go index 2f6a7809ff3..e50cc05c332 100644 --- a/cmd/testkit_test.go +++ b/cmd/testkit_test.go @@ -77,7 +77,10 @@ func NewTestKit(tb testing.TB) *TestKit { tb.Setenv("ATMOS_XDG_CACHE_HOME", tb.TempDir()) // Shared command startup prepends installed project tools to the process PATH. tb.Setenv("PATH", os.Getenv("PATH")) - tb.Setenv(installedProjectPathEnv, os.Getenv(installedProjectPathEnv)) + // The test runner's tools are prerequisites, not a previous project selected by + // this test. `atmos test` supplies this marker; inheriting it would remove Packer + // and other runner tools when a test switches to a fixture without a manifest. + tb.Setenv(installedProjectPathEnv, "") // Credential stores must never reach the developer's real OS keychain (macOS prompts). A // backend the test already chose (or the package default from TestMain) is left untouched. credtest.EnsureIsolated(tb) diff --git a/cmd/toolchain_environment_inheritance_test.go b/cmd/toolchain_environment_inheritance_test.go index 70e81ebd212..c7e9d37de7f 100644 --- a/cmd/toolchain_environment_inheritance_test.go +++ b/cmd/toolchain_environment_inheritance_test.go @@ -19,7 +19,11 @@ func TestInstalledProjectToolsChildProcess(t *testing.T) { if root == "" { return } + // This child specifically tests inherited project selections; restore the + // marker that ordinary test fixtures isolate from the test runner. + inheritedProjectPath := os.Getenv(installedProjectPathEnv) _ = NewTestKit(t) + t.Setenv(installedProjectPathEnv, inheritedProjectPath) config := &schema.AtmosConfiguration{BasePathAbsolute: root} config.Toolchain.InstallPath = os.Getenv("_ATMOS_TEST_INSTALL_PATH") config.Toolchain.Install = schema.ToolchainInstallNever diff --git a/docs/developing-component-plugins.md b/docs/developing-component-plugins.md index 8a198796cbd..0a1bd9c1d68 100644 --- a/docs/developing-component-plugins.md +++ b/docs/developing-component-plugins.md @@ -11,7 +11,7 @@ Atmos supports pluggable component types through the component registry pattern. - **Component Provider**: An implementation of the `ComponentProvider` interface that defines how Atmos interacts with a specific component type. - **Component Registry**: A global registry that manages all component providers using thread-safe registration. - **Plugin Configuration**: Component-specific settings stored in the `Components.Plugins` map in `atmos.yaml`. -- **Self-Registration**: Providers automatically register themselves via `init()` functions. +- **Self-Registration**: Custom providers can register themselves via `init()` functions. The host registers the built-in Terraform provider with its required runtime services. ## When to Create a Component Plugin @@ -64,6 +64,9 @@ type ComponentProvider interface { // ExecutionContext provides all information needed to execute a component command. type ExecutionContext struct { + Context context.Context + Options []ExecutionOption + WorkingDir string AtmosConfig *schema.AtmosConfiguration ComponentType string Component string @@ -135,6 +138,10 @@ func DefaultConfig() Config { Create your provider implementation: +The example below registers a custom `yourtype` provider on package import. Choose a unique type name. Registering the same type again replaces its existing provider; use this behavior only for an intentional override. + +The built-in Terraform provider follows a different pattern. Importing `pkg/component/terraform` does not register it. The host calls `component.Register(terraformcomponent.New(terraformExecutor))` in `internal/exec/terraform.go`. `NewTerraformExecutor` binds shared host services to the component-owned runtime. A custom provider that registers as `terraform` replaces that host registration if it runs later. + ```go // pkg/component/yourtype/yourtype.go package yourtype @@ -532,7 +539,7 @@ import ( ) ``` -The blank import triggers the `init()` function which registers the provider. +For the custom provider in this guide, the blank import triggers the `init()` function that registers it. The built-in Terraform provider requires host registration instead. ## Configuration @@ -826,10 +833,11 @@ output, err := cmd.CombinedOutput() The component registry pattern is designed to eventually migrate all component types to plugins: -**Phase 1-3 (Current)**: Built-in types (terraform, helmfile, packer) remain static -**Phase 4**: New types use plugin pattern -**Phase 5**: Migrate built-in types to plugin implementations -**Phase 6**: Unified plugin architecture +The host registers the built-in Terraform provider with a component-owned `Executor`. The compatibility entry point selects the registered provider for single and scheduled operations. Terraform execution, initialization, workspaces, authentication orchestration, shell sessions, UI routing, policy, generation, plan comparison, and state/output lookup live in `pkg/component/terraform`. The executor receives shared stack, template, process, authentication, and reporting services through instance bindings. `internal/exec/terraform.go` contains registration, service composition, and compatibility entry points. The component package does not import `internal/exec`. + +Execution callers can pass streams, environment, cancellation, and reporting callbacks through `ExecutionContext.Options`. The internal `ShellCommandOption` API remains a compatibility alias. Providers must preserve these options when delegating execution. + +Helmfile and Packer still use their existing execution paths. External component plugins and independent discovery and preparation capabilities remain separate steps. See the [Terraform refactor plan](prd/terraform-component-registry-refactor.md) for the dependency order and acceptance criteria. Your plugin will be compatible with this migration path as long as it implements the `ComponentProvider` interface. @@ -838,7 +846,7 @@ Your plugin will be compatible with this migration path as long as it implements - Review the mock component implementation: `pkg/component/mock/` - Check the component registry pattern PRD: `docs/prd/component-registry-pattern.md` - See interface definition: `pkg/component/provider.go` -- Look at existing built-in types for patterns (though they don't use the registry yet) +- Look at `pkg/component/terraform` for a provider with injected lifecycle services, and `pkg/component/helm` for an existing registered component. ## Summary @@ -846,7 +854,7 @@ Creating a component plugin involves: 1. ✅ Define your Config struct with component-specific settings 2. ✅ Implement the ComponentProvider interface (8 methods) -3. ✅ Self-register via init() function +3. ✅ Register your custom provider via an init() function, or supply required services through host registration 4. ✅ Write comprehensive tests (>90% coverage) 5. ✅ Document your configuration structure 6. ✅ Use sentinel errors for error handling diff --git a/docs/fixes/2026-10-26-terraform-component-registry.md b/docs/fixes/2026-10-26-terraform-component-registry.md new file mode 100644 index 00000000000..29144493af2 --- /dev/null +++ b/docs/fixes/2026-10-26-terraform-component-registry.md @@ -0,0 +1,35 @@ +# Fix: Give Terraform a component-owned runtime + +**Date:** 2026-10-26 + +## Summary + +Terraform and OpenTofu now select a registered component provider whose runtime lives in `pkg/component/terraform`. The same PR reduces `internal/exec` from 34 `terraform*.go` production files to one host adapter, `terraform.go`. + +## Context + +Terraform execution bypassed the component registry and owned its lifecycle in `internal/exec`. Other configuration providers could not reuse the lifecycle without adding special cases to the shared execution package. Execution options and shared data contracts also belonged to that package. + +## Changes + +- Register `pkg/component/terraform.Provider` with a component-owned `Executor`. Keep registry dispatch and shared-service composition in one host adapter. +- Move initialization, workspaces, authentication orchestration, hooks, arguments, retries, policy, UI routing, shell sessions, bulk/query/affected execution, generation, plans, and state/output lookup into the component package. +- Bind shared host services per executor. `NewTerraformExecutor` creates an independent executor without changing the registry. The component package does not import `internal/exec`. +- Move execution options and shared data contracts into `pkg/component`. Retain compatibility entry points and type aliases. Preserve streams, capture, cancellation, explicit empty environments, credentials, cache identity, and reporting callbacks. +- Move unit tests with the implementation. Bind tests that need real stack/process services through an external host fixture. Keep host integration tests and test-only compatibility helpers in `internal/exec`. +- Add portable affected-dispatch tests using temporary Git repositories and tests for execution-service failures, scheduler selection, authentication, and wrapper forwarding. Preserve the existing assertions when moving tests. +- Update the provider guide and the [refactor requirements](../prd/terraform-component-registry-refactor.md) to describe the completed lifecycle boundary. + +## Validation + +Counts and local coverage below are refreshed from the final run for the [CI follow-up](2026-10-27-terraform-component-ci.md). + +- `go build ./...` passed. +- Full tests for `pkg/component/terraform`, `internal/exec`, `pkg/component`, and `cmd/terraform` passed: **8,604 passing test/subtest events, 51 skips, zero failures**. No existing test declarations were lost. +- Local rename-aware patch coverage: **1,694/1,801 added executable lines (94.06%)**. Counting all 40 uninstrumented syntax/label lines as misses gives **92.02%**. The run instruments the component, Terraform component, and host packages across all four test packages. This is scoped coverage; CI Codecov remains authoritative. +- Patch-scoped `custom-gcl` lint passed with zero issues. Existing lookup and shell control flow retains narrow function annotations to preserve behavior during extraction. +- Mock generation, offline links in the changed guides, `git diff --check`, and the fix-document validator passed. + +## Follow-ups + +Define independent discovery and preparation capabilities, then adapt them to the external plugin protocol and Terragrunt integration. These remain separate work in the [refactor plan](../prd/terraform-component-registry-refactor.md). diff --git a/docs/fixes/2026-10-27-terraform-component-ci.md b/docs/fixes/2026-10-27-terraform-component-ci.md new file mode 100644 index 00000000000..5723b6f5d3e --- /dev/null +++ b/docs/fixes/2026-10-27-terraform-component-ci.md @@ -0,0 +1,34 @@ +# Fix: Terraform component CI failures and retry cancellation + +**Date:** 2026-10-27 + +## Summary + +Correct the Terraform query test's executor binding and the stack lifecycle test's concurrent counter. Use the caller's context for subprocess retry waits. + +## Context + +Linux and Windows acceptance shard 6 failed because the query setup-error test patched its parent executor but called separate executors from its subtests. The race suite also found concurrent writes to a stack lifecycle test counter. Review found that retry backoff used a background context and could delay cancellation. + +## Changes + +- Reuse the patched executor in the query setup-error subtests. Cover describe-error propagation with a portable test that also runs on macOS ARM64. +- Synchronize the lifecycle test's invocation counter. Preserve the assertions that grouped output failures prevent execution and that ungrouped execution runs all three components. +- Pass the caller's process context to retry backoff. Check that cancellation returns the context error and prevents another attempt. +- Add portable coverage of authentication failure handling, default identities, Terraform RC composition, workspace failure boundaries, and init recovery with provider locking. Select these cases from the CI coverage profile. +- Document the auth-context wrapper's supported operations and output-stream forwarding. Align the PR description and fix records with the latest saved test run. + +## Validation + +- Reproduced the retry cancellation regression before the fix; all 10 retry tests pass afterward. +- The portable query describe-error regression and the full Terraform component package pass. The existing gomonkey setup-error test skips on macOS ARM64; the Linux and Windows acceptance runs passed. +- Reproduced the lifecycle counter race and lost update locally. The corrected test passes 1,000 repetitions with `-race`; the full lifecycle package passes 10 repetitions with CI's shuffle seed and parallelism. +- The new coverage tests also pass with CI's Go 1.26.10 toolchain. Against the downloaded CI profile, they cover 23 previously missed blocks containing 29 statements. +- Patch-scoped lint passes with zero issues. +- `go build ./...` passes. +- Full tests for `pkg/component/terraform`, `internal/exec`, `pkg/component`, and `cmd/terraform` pass: 8,604 passing test/subtest events, 51 skips, and zero failures. The run instruments the three implementation packages. +- Local rename-aware patch coverage is 1,694/1,801 added executable lines (94.06%). This scoped approximation does not replace CI Codecov. + +## Follow-ups + +The acceptance and race suites passed in [CI run 40594955477](https://github.com/cloudposse/atmos/actions/runs/40594955477). Its Codecov report measured 89.56% patch coverage, below the required 90%, despite the higher local approximation. The additional tests target branches missed by that CI run; their new Codecov result remains to be confirmed. The canceled release-milestone workflow passed on rerun. diff --git a/docs/fixes/2026-10-28-aws-credential-file-locking.md b/docs/fixes/2026-10-28-aws-credential-file-locking.md new file mode 100644 index 00000000000..c2d7b3f343a --- /dev/null +++ b/docs/fixes/2026-10-28-aws-credential-file-locking.md @@ -0,0 +1,27 @@ +# Fix: Serialize AWS credential writes on Windows + +**Date:** 2026-10-28 + +## Summary + +Protect shared AWS credentials and configuration files with native file locks on Windows as well as Unix. + +## Context + +Windows acceptance shard 10 failed in `TestManager_AuthenticateIsolated_Concurrent` while loading a credentials file. AWS file transactions used the cache lock, whose Windows implementation intentionally does not lock. Concurrent load/modify/save transactions could therefore read an incomplete file or overwrite another profile's update. + +## Changes + +Use `pkg/filelock` for the existing sibling `.lock` file. Preserve the ten-second acquisition timeout and the `ErrFileLockTimeout` and `ErrCacheLocked` error identities. Leave general cache locking unchanged. + +Add a concurrent-write regression that verifies every profile survives in both files, and run the existing acquisition-failure assertion on Windows too. + +## Validation + +- Full tests for `pkg/auth/cloud/aws` and `pkg/auth` pass, including with the race detector. +- The concurrent profile-write and isolated-authentication tests pass 25 repetitions. +- The AWS package test binary cross-compiles for Windows amd64. Native Windows CI remains the platform-specific validation. + +## Follow-ups + +Confirm Windows acceptance shard 10 passes on the published stack head. diff --git a/docs/fixes/2026-10-28-native-command-passthrough.md b/docs/fixes/2026-10-28-native-command-passthrough.md new file mode 100644 index 00000000000..e0293e4c7c7 --- /dev/null +++ b/docs/fixes/2026-10-28-native-command-passthrough.md @@ -0,0 +1,25 @@ +# Fix: Preserve native Packer and Helmfile arguments after double dash + +**Date:** 2026-10-28 + +## Summary + +Packer `validate ... -- -syntax-only` reaches Packer with the native argument intact. + +## Context + +Cobra consumes `--` before RunE. The legacy adapter then reparsed the remaining native `-syntax-only` as Atmos shorthand, losing the boundary. Both current main and reconciled PR failed twice against the pinned Packer 1.16.0 builtin-null fixture. + +## Changes + +The shared command adapter and Helmfile adapter use `flags.SplitArgsAtDash` on Cobra RunE arguments before the synthetic operation prefix is interpreted. Explicit separators from legacy direct callers remain supported. No new flags or Packer-specific string rewrite were added. No stored configuration/default meaning changes; edition gating does not apply. + +## Validation + +Portable `TestNativeCommandSeparatorPreservesArgv` passed for Packer and Helmfile using the actual test subprocess, preserving order, duplicate values and embedded spaces. Real pinned Packer 1.16.0 init, validate and `-- -syntax-only` each passed twice in independent isolated fixtures. Terraform real plan and plan-diff controls also passed on Terraform 1.15.6 and OpenTofu 1.12.5. + +Live evidence and exact command records are retained under `.context/terraform-repair-20261028/contracts/`; `*-isolated-*` cases explicitly use per-fixture encrypted file keyrings. + +## Follow-ups + +Final integrated validation, website build and affected help-cast regeneration are coordinated in the approved Terraform field-findings repair plan. Real cloud IAM and destructive production state operations were not tested. diff --git a/docs/fixes/2026-10-28-plugin-bundle-local-paths.md b/docs/fixes/2026-10-28-plugin-bundle-local-paths.md new file mode 100644 index 00000000000..76f4233fd71 --- /dev/null +++ b/docs/fixes/2026-10-28-plugin-bundle-local-paths.md @@ -0,0 +1,25 @@ +# Fix: Validate local paths at the plugin archive boundary + +**Date:** 2026-10-28 + +## Summary + +Check archive entry names with `filepath.IsLocal` before exposing them through plugin bundle inventories. + +## Context + +CodeQL reported archive entry names flowing through the bundle inventory to filesystem operations. The existing custom validator already rejected parent traversal and absolute slash paths, but its validation was not recognized along this flow. Colon-containing names remain ordinary file names on Unix and are rejected on Windows. + +## Changes + +Add an explicit local-path guard at the archive reader boundary. Keep the stricter canonical-path, hidden-file, entry-type, and credential-material checks. Preserve legal filenames containing consecutive dots. The bundle guard test is a build input of `auth-secrets`; it ships with the package's 1.1.1 version bump, which satisfies the plugin release gate. + +## Validation + +- Full `pkg/plugin/oci` tests pass with the race detector, including hostile archive rejection before extraction. +- Added cases cover legal consecutive dots within filenames. +- CodeQL's Go path-traversal library models `filepath.IsLocal` as a sanitizer guard. Hosted CodeQL analysis must confirm the reported flow is eliminated; no alert suppression was added. + +## Follow-ups + +Confirm hosted CodeQL analysis passes on the published stack head. diff --git a/docs/fixes/2026-10-28-provisioning-auth-fingerprints.md b/docs/fixes/2026-10-28-provisioning-auth-fingerprints.md new file mode 100644 index 00000000000..d3e221db69c --- /dev/null +++ b/docs/fixes/2026-10-28-provisioning-auth-fingerprints.md @@ -0,0 +1,27 @@ +# Fix: Use keyed fingerprints for provisioning auth scopes + +**Date:** 2026-10-28 + +## Summary + +Use HMAC-SHA256 with a random process-local secret for source and output provisioning cache identities that include authentication material. + +## Context + +CodeQL flagged unkeyed SHA-256 fingerprints of serialized authentication configuration in both provisioning caches. These are in-memory reuse keys, not password-verification records, but an unkeyed digest can still reveal whether a guessed credential matches a retained key. + +## Changes + +Share a fingerprint helper with a secret initialized once per process. Never persist the secret or fingerprints. Preserve all identity inputs, including checkout, component, source version, and auth scope, so unchanged inputs reuse provisioning and changed credentials cause another attempt. + +Add an HMAC test vector, concurrent key-stability coverage, and source/output regressions for unchanged versus rotated credentials. + +## Validation + +Full `pkg/auth/fingerprint`, `pkg/provisioner/source`, and `pkg/terraform/output` suites pass with the race detector, including the credential-rotation regressions. + +Hosted CodeQL must confirm the two reported flows are eliminated. No suppression or password-hashing exception was added. + +## Follow-ups + +Confirm the updated lifecycle PR's CodeQL analysis and native Windows acceptance tests. diff --git a/docs/fixes/2026-10-28-source-identity-disable-and-workdir-precedence.md b/docs/fixes/2026-10-28-source-identity-disable-and-workdir-precedence.md new file mode 100644 index 00000000000..13612b161e5 --- /dev/null +++ b/docs/fixes/2026-10-28-source-identity-disable-and-workdir-precedence.md @@ -0,0 +1,42 @@ +# Fix: Source authentication opt-outs and explicit workdir placement + +**Date:** 2026-10-28 + +## Summary + +Source commands and Terraform shell use normalized identity-disable values. Explicit source +working directories now have consistent placement with an edition boundary and migration guard. + +## Context + +Main and the reconciled PR rejected `--identity=false` for source pull, and ignored an explicit +working directory when workdir provisioning was enabled. The metadata spelling was absent from +the manifest schema. + +## Changes + +Source and shell parsing uses the shared identity selector; library boundaries normalize false +aliases, and shell preserves disabled authentication during nested evaluation. Source placement +uses `ResolveTarget` for provisioning, execution reconstruction, output and local-state lookup. +The 2026-10-28 behavior transition preserves generated paths for older edition pins. A nonempty +old workdir blocks an implicit move; Atmos never moves or discards Terraform state automatically. +The manifest schema accepts the metadata override. +The shared resolver validates explicit-target ownership before state or output lookup, +including when automatic output provisioning is disabled. Publication retains its +under-lock ownership recheck. + +## Validation + +Flag/library tests cover false aliases and retained named-identity parsing. Edition tests cover +before/on/after, unpinned and invalid pins, metadata/settings overrides, and byte-preserved old +state on migration refusal. Real source pull and root/nested override apply/plan/output pass twice +on Terraform 1.15.6 and OpenTofu 1.12.5. Full validation evidence is retained under +`.context/terraform-repair-20261028/`. +Same-stack and cross-stack owner collisions are rejected by state/output lookups +without changing the owner's files. Source/output suites, local backend tests and +repeated ownership concurrency race checks pass. + +## Follow-ups + +Existing projects adopting the new precedence must explicitly migrate an old workdir when present; +the migration contract is documented in `docs/prd/source-provisioner.md`. diff --git a/docs/fixes/2026-10-28-terraform-detailed-plan-hooks.md b/docs/fixes/2026-10-28-terraform-detailed-plan-hooks.md new file mode 100644 index 00000000000..cb34b5deff5 --- /dev/null +++ b/docs/fixes/2026-10-28-terraform-detailed-plan-hooks.md @@ -0,0 +1,25 @@ +# Fix: Run success hooks for Terraform plans with changes + +**Date:** 2026-10-28 + +## Summary + +Detailed plan exit 2 runs success/always after-hooks once, retains external exit 2 and enforces required hook failures. + +## Context + +Fresh tests twice per main/reconciled revision and engine showed a plan with changes running its failure hook and skipping its default success hook. Lifecycle documentation defines after-hooks as success-only by default. + +## Changes + +Single-component and graph-node hook outcomes classify plan exit 2 as success, while retaining the raw exit code for CI and the external command. Policy errors remain failures. The single-component plan defer uses the result-aware success path because Cobra skips PostRunE on nonzero status; required after-hook errors propagate instead of being logged and discarded. Other nonzero command statuses remain failures. This restores the existing success-hook contract without changing configuration defaults or adding an edition transition. + +## Validation + +Focused command tests passed for unchanged/changed/failed plans, non-plan exit 2, policy errors, and actual required success-hook failure with a negative failed-engine control. Both real engines passed twice: before/success hooks fired once, failure hook did not fire, exit stayed 2. A required after-hook failure returned 1 on both engines; same/different plan-diff controls retained 0/2. + +Live evidence and exact command records are retained under `.context/terraform-repair-20261028/contracts/`; `*-isolated-*` cases explicitly use per-fixture encrypted file keyrings. + +## Follow-ups + +Final integrated validation, website build and affected help-cast regeneration are coordinated in the approved Terraform field-findings repair plan. Real cloud IAM and destructive production state operations were not tested. diff --git a/docs/fixes/2026-10-28-terraform-dry-run-and-output-streams.md b/docs/fixes/2026-10-28-terraform-dry-run-and-output-streams.md new file mode 100644 index 00000000000..f0c9f31f8bc --- /dev/null +++ b/docs/fixes/2026-10-28-terraform-dry-run-and-output-streams.md @@ -0,0 +1,42 @@ +# Fix: Terraform dry-run provisioning and prerequisite output streams + +**Date:** 2026-10-28 + +## Summary + +Dry-run Terraform commands no longer invoke SDK provisioners, refresh source/workdirs, +invalidate initialization markers, or delete plan/variable files. Prerequisite initialization +for output/show/state-pull commands sends diagnostics to stderr. + +## Context + +Paired field tests reproduced S3 bucket creation during dry-run and invalid JSON stdout during +cold output on both main `7e43ddf900` and reconciled PR tree `1935d330b4`. + +## Changes + +The typed provisioner execution context carries dry-run intent. Source/workdir preparation +resolves and validates paths without provisioning; init housekeeping and cleanup preserve disk +artifacts. Real provisioning remains independent of the opportunistic engine-init decision. +Data-command prerequisites retain diagnostic/retry capture without entering the caller's data stream. +The merged stderr display and capture destinations share a write lock so concurrent +subprocess stdout/stderr pumps cannot race a caller's diagnostic buffer. + +## Validation + +Additional tests assert that provider-recovery preparation failures prevent both explicit and +implicit init from launching the engine, dry-run cleanup retains caller plan bytes, shell dry-run +preserves disabled authentication without fetching source, and partial diagnostic streams do not +pollute data stdout. Invalid dry-run source paths still fail before filesystem mutation. + +Portable subprocess and provisioner-spy tests pass. On Terraform 1.15.6 and OpenTofu 1.12.5, +two fresh runs per engine kept absent Floci buckets absent after plan/apply/init dry-runs and +preserved existing object-version lists, versioning configuration, and local state/plan hashes. +Normal explicit init and backend provisioning with skipped engine init still work. Cold native +JSON output parses in its entirety after prerequisite initialization on local and Git sources. +Concurrent diagnostic display/capture and real subprocess routing tests pass twice +under the race detector, including a caller sharing one diagnostic buffer. + +## Follow-ups + +Validation covers isolated S3 emulation; it does not establish parity for other live backend services. diff --git a/docs/fixes/2026-10-28-terraform-extraction-test-isolation.md b/docs/fixes/2026-10-28-terraform-extraction-test-isolation.md new file mode 100644 index 00000000000..4a295b8f0a8 --- /dev/null +++ b/docs/fixes/2026-10-28-terraform-extraction-test-isolation.md @@ -0,0 +1,48 @@ +# Fix: Preserve test isolation when integrating the Terraform extraction + +**Date:** 2026-10-28 + +## Summary + +The extracted Terraform component tests retain upstream credential isolation, and +command test fixtures preserve tools supplied by the repository test runner. + +## Context + +The Terraform extraction and incoming main both changed the host test runner. +Main added credential isolation while the extraction moved CI-dependent tests to +the component package. Keeping only one side would lose either isolation or the +new package's test dependencies. + +The maintained `atmos test` wrapper also supplies installed tools through PATH. +Its project-selection marker must not make ordinary test fixtures remove those +test prerequisites when they switch to disposable projects. + +## Changes + +- Resolve the host import conflict while retaining main's credential isolation. +- Apply the same isolation to the moved Terraform component test runner without + changing its portable subprocess modes or cache cleanup. +- Treat the wrapper's initial tools as test prerequisites in `NewTestKit`. +- Explicitly restore the inherited project marker in the child-process test that + verifies real project-selection replacement. Its exact PATH assertions remain. +- Update plan-diff caller tests to verify the returned difference status and + unique-copy ownership rather than the removed exit interception behavior. + +## Validation + +The final CLI and `go build ./...` pass. Full `cmd` and `internal/exec` package +tests pass through the maintained wrapper. Component tests execute successfully, +including portable subprocess, dry-run, stream and plan ownership checks. +`atmos lint --changed` and the final scoped lint pass with zero issues. + +Broad tests are tracked in the repair report. Earlier runs with a global memory +keyring override were invalid for tests intentionally sharing credentials across +store instances; removing that override lets the existing mocked AWS identity +suite pass. No production authentication behavior was changed for these tests. + +## Follow-ups + +Finish the repository-wide validation gates recorded in the Terraform repair +report before declaring the integration ready. No commits or publication are +part of this local repair. diff --git a/docs/fixes/2026-10-28-terraform-managed-registry-fingerprint.md b/docs/fixes/2026-10-28-terraform-managed-registry-fingerprint.md new file mode 100644 index 00000000000..8692bf5782f --- /dev/null +++ b/docs/fixes/2026-10-28-terraform-managed-registry-fingerprint.md @@ -0,0 +1,29 @@ +# Fix: Keep registry-cache init fingerprints stable across proxy restarts + +**Date:** 2026-10-28 + +## Summary + +A new ephemeral Atmos registry-proxy port no longer invalidates a successful init marker. Each invocation still starts a live proxy and passes its current endpoint to Terraform/OpenTofu. + +## Context + +The generated Terraform RC file changed on every registry-enabled invocation because the proxy listens on an available loopback port. Hashing those generated bytes caused redundant init calls on both main and the reconciled component-provider extraction, despite unchanged component dependencies. + +## Changes + +The cache contributes a separate semantic representation containing the same provider/module installation rules and a symbolic Atmos-owned endpoint. The identity includes the cache root, TLS certificate, metadata policy, registry hosts, and effective user RC configuration. + +Generated RC files have explicit, process-local provenance. A concurrency-safe registry binds each temporary path and exact generated-content digest to its semantic identity; pipeline cleanup removes the registration and file. Modified generated content falls back to its actual bytes. User-managed files and user-specified localhost endpoints retain exact content identity and existing override precedence. No URL pattern is stripped from arbitrary user configuration. + +Root configuration, provider locks, backend configuration, init variables and ordinary environment fingerprint inputs remain in the fingerprint. This is a bug fix with no configuration or edition migration. Existing markers can require one initialization when moving to the corrected identity format. + +## Validation + +A regression using two simultaneously running real local proxy listeners failed before the fix and now proves different live RC bytes yield the same semantic fingerprint. Unit tests cover user endpoint/cache-root/policy/credential changes, generated-file edits, cleanup, concurrency, and user RC precedence. Autoinit, RC, and cache suites passed; the full Terraform component short suite passed. Race tests passed for autoinit and RC. + +Real Linux Terraform 1.15.6 and OpenTofu 1.12.5 passed all four plugin/registry-cache combinations: cold init followed by warm plan, a fresh process, apply, and JSON output. Registry modules also initialize once and skip warm init. Explicit user RC file localhost changes and lockfile edits still trigger init. Registry-enabled variable-dependent local modules select and apply v1 then v2 with the expected fingerprint/init change; warm runs and pass-vars opt-out/restore remain correct. Unsupported Terraform nonconst sources remain rejected while its const-variable counterpart passes. Network-disabled containers verified warm registry modules, manifest-retained module recovery, and filesystem-mirror provider reinstallation. Provider-constraint/backend changes and same-path explicit user RC edits retain the expected init/reconfigure behavior. Parallel fleet execution still suppresses the unsafe shared plugin cache and skips warm init. Scoped provider/module inspection, deletion, pruning, dry runs, and TLS-file exclusion passed. Native macOS retained its expected untrusted-cache refusal without engine startup. + +## Follow-ups + +The broader field-findings repair plan tracks final combined acceptance and repository-wide validation. Native macOS registry TLS continues to require the existing OS trust mechanism; this repair does not install certificates or bypass verification. diff --git a/docs/fixes/2026-10-28-terraform-manual-backend-contracts.md b/docs/fixes/2026-10-28-terraform-manual-backend-contracts.md new file mode 100644 index 00000000000..7dc45ae0843 --- /dev/null +++ b/docs/fixes/2026-10-28-terraform-manual-backend-contracts.md @@ -0,0 +1,25 @@ +# Fix: Manual backend environment values and accurate command contracts + +**Date:** 2026-10-28 + +## Summary + +Manual backend create, update, and delete resolve explicit `!env` values while keeping unrelated configuration functions deferred. Unsupported backend inspection now returns its intended error without authenticating. + +## Context + +The field test reproduced environment-backed backend creation failure on both current main and the reconciled extraction. Literal configuration worked. List attempted to describe an empty component before reaching its unsupported result; help also incorrectly said forced deletion required an empty backend. + +## Changes + +The callback loads the component without evaluating functions, then evaluates only backend fields with the shared YAML evaluator and all non-env tags skipped. Component environment precedence, defaults, explicit-tag policy and disabled/named identity handling are retained. List/describe keep argument validation but skip unnecessary auth/config work. Help and docs say list/describe are not implemented and deletion requires `--force` even when empty; forced deletion removes stored state. No deletion semantics, flags, configuration defaults, or edition interpretation changed. + +## Validation + +`GOMAXPROCS=4 go test -p 2 ./cmd/terraform/backend -count=1` passed. Portable tests cover backend scope, explicit versus literal tags, malformed tags, component/process/default environment precedence, disabled identity and production callback stack loading. Fresh isolated Floci cases passed twice for literal and environment-backed CRUD, named/disabled identities, unknown-identity refusal, nonempty deletion refusal and forced removal. Empty deletion without force also refuses as designed. + +Live evidence and exact command records are retained under `.context/terraform-repair-20261028/contracts/`; `*-isolated-*` cases explicitly use per-fixture encrypted file keyrings. + +## Follow-ups + +Final integrated validation, website build and affected help-cast regeneration are coordinated in the approved Terraform field-findings repair plan. Real cloud IAM and destructive production state operations were not tested. diff --git a/docs/fixes/2026-10-28-terraform-output-workdir-cache-isolation.md b/docs/fixes/2026-10-28-terraform-output-workdir-cache-isolation.md new file mode 100644 index 00000000000..fbd7b844b5a --- /dev/null +++ b/docs/fixes/2026-10-28-terraform-output-workdir-cache-isolation.md @@ -0,0 +1,45 @@ +# Fix: Terraform output provisioning cache isolation across checkouts + +**Date:** 2026-10-28 + +## Summary + +Output provisioning caches no longer reuse a HEAD workdir result for a BASE checkout with the +same stack/component names. Nested module output lookup resolves the module subdirectory. + +## Context + +Evaluated affected discovery failed writing a generated backend file into a missing temporary +BASE workdir. The provisioning cache was keyed only by stack and component, unlike the existing +reference-value caches that include the configuration root. + +## Changes + +The cache and concurrent-work key includes checkout, effective path, source configuration and +hashed authentication context. Missing target directories trigger provisioning again. CLI +invocation boundaries clear reuse records. Source subdirectories resolve after provisioning. + +## Validation + +Unit tests assert separate calls across HEAD/BASE, version changes and deleted targets while warm +repeats reuse a valid target. The complete output package short suite passes. A reduced source +producer/template consumer fails twice on each engine with main and reconciled binaries; fixed +Terraform 1.15.6 and OpenTofu 1.12.5 runs succeed twice and select the source-changed component. +No-evaluation discovery remains successful. + +Cold and cached preparation tests also verify nested module selection, inheritance fallback, +and classified errors for invalid file or absolute module paths. Reconstructed explicit source +workdirs resolve the existing nested module and state without creating a second workdir. + +## Follow-ups + +Evaluated affected discovery still permits output lookup to refresh HEAD source files and generate +execution artifacts. This repair isolates HEAD/BASE caches; it does not make evaluated discovery +read-only. Strict no-write staging and general relative-path-preserving workdirs are deferred: +the user prefers preserving today's workdir design over introducing the proposed execution-tree +architecture in this PR. No new layout or migration is implemented. The deferred design is retained +in `.context/plans/terraform-workdir-context-plan.md`; the reusable +`tests/fixtures/scenarios/terraform-registry-field-test/relative-context/` fixture now reproduces +the inherited nested-module failure on main and the repaired binary, twice per engine. Those checks +establish the problem, not a fix. All field commands ran against disposable directories, never +production state or the user's source checkout. diff --git a/docs/fixes/2026-10-28-terraform-partial-provider-recovery.md b/docs/fixes/2026-10-28-terraform-partial-provider-recovery.md new file mode 100644 index 00000000000..18cb60591d3 --- /dev/null +++ b/docs/fixes/2026-10-28-terraform-partial-provider-recovery.md @@ -0,0 +1,31 @@ +# Fix: Recover incomplete Terraform provider installations + +**Date:** 2026-10-28 + +## Summary + +Smart init detects missing provider executables and unusable package links even when the provider directory still exists. Terraform workspace selection and OpenTofu provider-install diagnostics now receive the same bounded init recovery as plan/apply. + +## Context + +Field tests reproduced this on current main and the reconciled component-provider extraction. Removing only a provider executable left the old directory-existence precondition satisfied. Terraform could fail during workspace selection before reaching plan recovery; OpenTofu reported a checksum/install diagnostic that was not classified. Init itself could then fail on an incomplete local package, a dangling symlink, or an incomplete shared plugin-cache package. + +## Changes + +- Check locked provider packages and executable availability for the current platform, with valid same-OS alternate architectures supported for emulated engines, including versioned and unversioned executable names, registry and legacy layouts, symlinks, and `TF_DATA_DIR`. Package contents are not hashed on every warm command. +- Once initialization is authorized, preserve incomplete owned modern package directories under `atmos-incomplete-provider-*` in the data directory and unlink unusable installation references. Shared target contents, valid packages, and aggregate legacy plugin directories are preserved. +- When a shared package is incomplete, scope `TF_PLUGIN_CACHE_DIR` to a persistent `atmos-provider-recovery` directory under this component's data directory for init. Its installed links remain valid afterward; ordinary configuration and warm fingerprints remain unchanged. This environment override also takes precedence over an RC `plugin_cache_dir`. +- Retry workspace initialization once using existing opt-out and upgrade policies. Unknown provider, authentication, and state-lock errors do not authorize recovery. Failed init still invalidates its marker. +- Preserve existing modified executables: a checksum diagnostic permits one init attempt, not blanket deletion of locally modified packages. OpenTofu can still reject such a package. + +This repairs existing initialization behavior without changing defaults, configuration semantics, or requiring an edition migration. Recovery artifacts are regenerable provider data and are removed with the Terraform data directory by normal cleanup. + +## Validation + +Failing behavior tests were run before implementation. The autoinit, RC, and cache package suites passed; the full Terraform component short suite passed. Race tests passed for autoinit and managed RC registration/cleanup. Unit cases cover native/alternate-architecture executable/platform/version selection, valid/broken links, outside-target preservation, permission failures, environment isolation, opt-outs, unrelated errors, and a persistent failure's single retry. + +Real Terraform 1.15.6 and OpenTofu 1.12.5 each passed two fresh native runs with plugin cache enabled and disabled, filesystem-only mirrors, default/custom data directories, missing executables, broken package links, warm runs, and skip/never/upgrade-never controls. Shared-cache artifact hashes and local state bytes stayed unchanged; actual engine argv confirmed bounded recovery. A modified OpenTofu executable retained its deliberate installation error after one attempt. Disposable Linux checks covered both tools and all four plugin/registry-cache combinations. + +## Follow-ups + +The broader field-findings repair plan tracks combined acceptance and repository-wide validation. Cross-architecture engine binaries running under emulation were not field-tested. No universal scheduling guarantee is added for independent processes modifying the same component directory. diff --git a/docs/fixes/2026-10-28-terraform-plan-diff-ownership.md b/docs/fixes/2026-10-28-terraform-plan-diff-ownership.md new file mode 100644 index 00000000000..df1ebdfcddd --- /dev/null +++ b/docs/fixes/2026-10-28-terraform-plan-diff-ownership.md @@ -0,0 +1,25 @@ +# Fix: Preserve caller plans during plan-diff + +**Date:** 2026-10-28 + +## Summary + +`plan-diff` preserves its caller-owned saved plans and cleans only temporary files it created. + +## Context + +Twice per engine and revision, a known-good default plan and a byte-identical copy were compared. Prerequisite init deleted the default plan, making comparison fail. The external-plan copy helper could also overwrite a same-named file in the component directory. + +## Changes + +Plan-diff marks the canonical caller plan as supplied during its nested init, preventing unrelated cleanup from deleting it. External plans use uniquely created temporary files with cleanup on copy/close failure; directory membership uses path-relative boundaries rather than a string prefix. Different plans now return the existing detailed exit 2 instead of exiting within the library, allowing deferred cleanup. No configuration defaults or edition interpretation changed. + +## Validation + +Focused component tests passed for caller-plan preservation, sibling-prefix paths, relative/absolute inputs, same-name collisions, owned-copy cleanup, same/different comparison status and unchanged source bytes. The existing plan-diff/deployment-verification policy matrix also passes with explicit returned difference-sentinel and exit-2 assertions. Real Terraform 1.15.6 and OpenTofu 1.12.5 passed identical comparison twice with exact saved-plan hashes retained; additional distinct-plan comparisons returned 2 and retained both files. + +Live evidence and exact command records are retained under `.context/terraform-repair-20261028/contracts/`; `*-isolated-*` cases explicitly use per-fixture encrypted file keyrings. + +## Follow-ups + +Final integrated validation, website build and affected help-cast regeneration are coordinated in the approved Terraform field-findings repair plan. Real cloud IAM and destructive production state operations were not tested. diff --git a/docs/fixes/2026-10-28-terraform-source-refresh-safety.md b/docs/fixes/2026-10-28-terraform-source-refresh-safety.md new file mode 100644 index 00000000000..a0565ac070e --- /dev/null +++ b/docs/fixes/2026-10-28-terraform-source-refresh-safety.md @@ -0,0 +1,150 @@ +# Fix: Terraform source refresh preserves runtime artifacts and source provenance + +**Date:** 2026-10-28 + +## Summary + +Source refresh now preserves Terraform runtime artifacts, reuses successful provisioning within +one command, and records the fetched source identity. + +## Context + +Terraform source provisioning previously replaced an existing vendored directory wholesale. +Changing a Git source version or refreshing a zero-TTL source could delete local state, +provider/module installations, generated files, and saved plans. A later plan could therefore +propose creating resources that already existed. A zero-TTL source could also refresh several +times within one CLI invocation when hooks and output lookups resolved separate component maps. + +## Changes + +Custom state detection streams top-level state metadata without a file-size cutoff. +Inspection I/O failures stop publication. Refresh locking resolves existing ancestor +symlinks so aliases of the same physical directory cannot publish concurrently. + +Windows acceptance testing exposed that the cache lock used for publication is deliberately +best-effort on Windows. Source publication now uses `pkg/filelock` directly for native and +in-process exclusion on every platform. A second publisher waits for the lock under the caller's +context instead of failing after a fixed two-second bound, and warns after two seconds that another +Atmos process is refreshing the directory. Once it acquires the lock it finds the target up to date +or republishes the same files. The legacy workdir migration guard checks the path type +before reading it: Windows can classify `ReadDir` on a regular file as not-found, which must +not allow Atmos to switch away from existing caller data. +The unused pre-receipt download wrapper is removed, and source progress setup passes its +expanded target options by pointer rather than copying them. + +Terraform `source:` refresh and `terraform source pull --force` stage the complete download +before changing the live source. A `.atmos/source-files.json` receipt identifies files owned by +the fetched source. Refresh removes obsolete owned files, installs the new source, and preserves +files created by Terraform, Atmos, or hooks, provided those paths are not recorded as source-owned. +Generators must avoid inventoried source paths: rewriting one does not transfer its ownership, and a +later refresh can replace or remove it. The component directory and runtime artifacts stay +in place. Publication journals each touched source file and its provenance receipts; a copy, +publication, metadata, or cancellation failure rolls back the changed files. A rollback that +itself fails retains its journal and reports its location. + +Protection includes nested module roots, configured local backend paths and workspace directories, +state backups, `.terraform`, canonical/per-instance provider locks, generated files, and saved +plans with custom filenames. Actual state/plan contents are recognized when they have replaced a +previously source-owned file. A source collision with a runtime artifact is rejected before +publication; provider locks remain under the lock restore/persist lifecycle. Active local state +lock markers and destination symlink traversal also prevent publication. Separate instances use +separate target locks; this does not introduce a universal scheduler for independent Terraform +processes sharing one mutable directory. + +When `auto_generate_backend_file` is enabled, a source that ships `backend.tf.json` in a module root +is rejected before publication: the source copy and the generated backend would otherwise overwrite +each other. A source update that changes a path between a file and a directory is also rejected +before publication, because refresh replaces files in place and cannot change a path's type +transactionally. The error names the conflicting path. To recover, move only that path out of the +component directory, keeping anything it holds that is still needed, and refresh again. Back up and +migrate local state, saved plans, and other runtime artifacts in that path, and update their configured +paths before running Terraform again. If the source replaces a directory with a file, its former +contents cannot be restored at their original paths. Do not delete +the whole component directory or run `source delete`: that also removes local state, `.terraform`, +and saved plans. + +Legacy workdirs have no source ownership inventory. Their unknown files are retained, ordinary +incoming Terraform configuration is adopted as source, and ambiguous non-Terraform collisions +fail safely. This intentionally cannot prove that an unmatched legacy file is stale. Incoming `.tf` +and `.tf.json` files are adopted without comparing contents, so on the first refresh of a legacy +workdir a source file with the same name as a hook-generated or hand-written configuration file +(for example `generated.tf`) replaces it. Before that first refresh, back up any generated +configuration that shares a name with a source file, or change the generator to write a name the +source does not ship. Once an +inventory has been recorded, subsequent refreshes remove obsolete source-owned files. A source +fixture named `examples/terraform.tfstate` remains ordinary source content unless it is the +configured runtime location or contains actual state; the filename alone does not protect it. + +Successful source provisioning is reused across hooks and nested lookups for the current CLI +invocation. The cache key includes the destination checkout, component instance, full source +specification, and authentication scope. Failed attempts are not cached; changed sources or +missing targets are reprovisioned. The next invocation starts a new scope, so zero TTL continues +to refresh on the next command. Outside an invocation scope, a component's own completion marker is reused only +while the workdir metadata still names the same instance, stack, and source; a target re-vendored +by another selector is provisioned again. A reused result preserves the runtime's already-resolved module +subdirectory. Refresh retains `.terraform`; normal init fingerprinting decides whether changed +inputs require initialization or backend reconfiguration. + +Git provenance now uses the commit captured by the downloader before `.git` is removed, including +Git URI subdirectories. Materialized content without its own verifiable Git root uses a +`sha256:` content identity. It no longer inherits the consuming repository's HEAD. Receipt fields +remain compatible, and shared-source receipts also expose the source identity and kind. + +Explicit source workdirs additionally record the component **instance** as owner. The new +working-directory precedence behavior validates ownership both on warm reuse and again while +holding the publication lock. Two instances cannot silently claim the same explicit target. +Existing aliases whose legacy receipt records only the base component require an explicit +ownership migration; the safety check does not infer that another instance owns their state. +The working-directory precedence transition and edition gate are documented separately. + +## Validation + +Windows job `123115466755` reproduced concurrent publication through an ancestor alias, +two successful ownership claims on one explicit workdir, and acceptance of a regular file at +the legacy workdir path. The existing tests remain enabled. An additional regression checks +cancellation while waiting for publication, no target creation on failure, and successful retry. +The complete source and filelock suites pass locally, including the race detector; source +package lint reports zero issues and the Windows source test binary cross-compiles. Native Windows execution +of this correction still requires CI; cross-compilation alone cannot verify Windows locking. + +Additional portable tests verify rollback after a backup failure, preservation when an owned +source file becomes a nonempty runtime directory, refusal of unverifiable explicit-workdir +ownership and receipt-path conflicts, and propagation of state-header read errors. Git sources +with unborn or invalid metadata fall back to an identity derived from the staged content. These +tests also assert unchanged state/source bytes on failure; no production behavior was changed +by this coverage follow-up. + +Archived pre-fix code fails regression tests for deletion/replacement of valid custom +state larger than 64 MiB and for aliased concurrent ownership claims. The fixed code +passes these cases, a large non-state source control, the complete source suite, and +the complete source race suite. Source lint reports zero issues. + +The reconciled PR and current main reproduced state loss, zero-TTL saved-plan failure, and wrong +Git provenance twice on both Terraform 1.15.6 and OpenTofu 1.12.5. Fixed real-engine repetitions +preserve nested local-state lineage, serial, resources and values while planning the actual +source change; receipts match the fetched commit. Zero-TTL saved-plan applies succeed after +stack variables change and retain the reviewed values. Further cases use nested modules, +`state/custom.bin`, and `reviewed/release.artifact`: forced source refresh preserves both file +hashes, and a failed Git refresh preserves source metadata, state and plan bytes. + +Go regression tests cover source-owned deletion versus runtime preservation, unchanged runtime +inodes, injected publication failure and cancellation rollback, metadata failure, symlink and +active-lock refusal, saved-plan/state collisions, concurrent fresh component maps, failed-fetch +retry, authentication/checkout isolation, changed selectors, missing targets, and invocation +reset. Downloader tests exclude enclosing consumer repositories from provenance. + +Evidence is retained in `.context/terraform-repair-20261028/sources/`. These local tests do not +establish authenticated private HTTP/OCI source behavior or Windows execution. The final +integrated acceptance suite and field matrix remain the PR-wide verification gate. + +## Follow-ups + +These source safety and provenance corrections do not change a configuration default or the +meaning of the configured source/version/TTL: source refresh continues to update source-owned +content, and zero TTL expires between commands. They repair unintended deletion of runtime +artifacts and incorrect receipts, so no destructive legacy code path is retained behind an +edition gate. The separate change to explicit working-directory precedence is edition-gated. + +Legacy workdirs without ownership inventories retain unmatched files because their provenance +cannot be established safely. Authenticated private HTTP/OCI sources and Windows execution +remain outside this local field matrix. diff --git a/docs/prd/native-ci/overview.md b/docs/prd/native-ci/overview.md index 01e0d349472..4a7f218b0c7 100644 --- a/docs/prd/native-ci/overview.md +++ b/docs/prd/native-ci/overview.md @@ -190,7 +190,7 @@ Users currently using the GitHub Actions can migrate incrementally: - [Existing CI Detection](../../../pkg/telemetry/ci.go) - Detects 24+ CI providers - [Lifecycle Hooks](../../../pkg/hooks/) - Hook system for terraform events -- [Plan-Diff](../../../internal/exec/terraform_plan_diff.go) - Semantic plan comparison (implemented) +- [Plan-Diff](../../../pkg/component/terraform/plan_diff.go) - Semantic plan comparison (implemented) - [Store Registry](../../../pkg/store/registry.go) - Pattern for planfile stores - Terraform Output Package (`pkg/terraform/output/`) - Output formatting and `FlattenMap()` for CI export - [tfcmt](https://github.com/suzuki-shunsuke/tfcmt) - Inspiration for PR comments diff --git a/docs/prd/source-provisioner.md b/docs/prd/source-provisioner.md index 472cf350514..28e0bcea165 100644 --- a/docs/prd/source-provisioner.md +++ b/docs/prd/source-provisioner.md @@ -93,6 +93,39 @@ After the workdir PR (#1852) merges: 2. Local component directory (if exists) 3. `source` (JIT vendor if component missing) +### Working-directory migration (2026-10-28) + +The `components.source.working_directory_precedence` behavior transition makes an explicit +`metadata.working_directory` (or `settings.working_directory`) override the generated path when +source workdir provisioning is enabled. Metadata takes precedence over settings; relative override +paths resolve against the Atmos base path. Explicit source commands, execution, shell, and state/output +lookups use the same resolver. Projects pinned before 2026-10-28 retain the generated workdir path. + +Adopting the new behavior does not automatically migrate state: if the old workdir contains any files, +Atmos stops before provisioning into the new path. Migrate the complete workdir, including hidden files, +local state, saved plans, provider locks and custom backend paths, or retain the earlier edition pin. +No journaled literal defaults change. State-preservation, dry-run, and authentication fixes apply to all +editions; they do not retain destructive behavior behind an edition pin. + +### Concurrent use of a shared component directory + +Terraform source refresh holds a cross-process lock while it stages and publishes. The lock file +lives under the process temporary directory, so it coordinates only processes using the same temporary +directory on the same host; separate hosts or temporary directories need external coordination. +A second process waits under the caller's context and warns while blocked. The context may have no +deadline; the vendor download timeout begins after the lock is acquired. + +**Remaining work (required before this feature is complete):** the refresh lock covers only the +source refresh itself (staging and publication), not the rest of the command: backend generation, +init, plan and apply run after it is released. Without workdir provisioning, every stack that uses a component shares its directory +for the whole command: generated `backend.tf.json`, varfiles and provider overrides, `.terraform` +(init, provider installation and its incomplete-package cleanup, the selected workspace), the +planfile, and plan/apply. Parallel atmos processes on such a directory can still interleave those +steps. The complete fix is one per-directory lock held from provisioning to the end of the command +for non-workdir components, re-entrant within one invocation so in-process callers (such as +`plan --all`) do not deadlock on themselves. It serializes stacks that share a component directory; +workdir provisioning remains the way to run them in parallel. + --- ## CLI Commands @@ -1242,25 +1275,25 @@ components: ```text 1. Check cache exists? (component-type scoped) - └─ $XDG_CACHE_HOME/atmos/sources/terraform/git/github.com/cloudposse/terraform-aws-components/.git + └─ $XDG_CACHE_HOME/atmos/sources/terraform/git/github.com/cloudposse/terraform-aws-components/.git 2. If no cache: - └─ git clone --bare + └─ git clone --bare 3. Fetch latest refs: - └─ git fetch --all --tags (only if stale or forced) + └─ git fetch --all --tags (only if stale or forced) 4. Check worktree exists for version+path combo? - └─ worktrees/v1.2.3--modules-vpc/ + └─ worktrees/v1.2.3--modules-vpc/ 5. If no worktree: - a. git worktree add --no-checkout worktrees/v1.2.3--modules-vpc v1.2.3 - b. cd worktrees/v1.2.3--modules-vpc - c. git sparse-checkout set --cone modules/vpc # Only checkout subpath! - d. git checkout + a. git worktree add --no-checkout worktrees/v1.2.3--modules-vpc v1.2.3 + b. cd worktrees/v1.2.3--modules-vpc + c. git sparse-checkout set --cone modules/vpc # Only checkout subpath! + d. git checkout 6. Copy to component directory (using otiai10/copy): - └─ cp.Copy(worktrees/v1.2.3--modules-vpc/modules/vpc, components/terraform/vpc) + └─ cp.Copy(worktrees/v1.2.3--modules-vpc/modules/vpc, components/terraform/vpc) ``` ### Subpath Support via Sparse Checkout @@ -1412,12 +1445,12 @@ func copyFromCache(srcPath, dstPath string, opts *CopyOptions) error { **Concurrency Safety:** ```text -Component A (vpc v1.2.3) ──┬── Copy to components/terraform/vpc-a/ - │ -Component B (vpc v1.2.3) ──┴── Copy to components/terraform/vpc-b/ - │ - └── Both read from same cached worktree - No write conflicts! +Component A (vpc v1.2.3) ─────┬── Copy to components/terraform/vpc-a/ + │ +Component B (vpc v1.2.3) ─────┴── Copy to components/terraform/vpc-b/ + │ + └── Both read from same cached worktree + No write conflicts! ``` Each component instance has its own target directory, avoiding the write conflicts that would occur with symlinks. diff --git a/docs/prd/terraform-component-registry-refactor.md b/docs/prd/terraform-component-registry-refactor.md new file mode 100644 index 00000000000..d4d21cb53ac --- /dev/null +++ b/docs/prd/terraform-component-registry-refactor.md @@ -0,0 +1,58 @@ +# Terraform component registry refactor + +## Objective + +Route Terraform and OpenTofu operations through the component registry. Move Terraform lifecycle ownership out of `internal/exec` in reviewable steps. Preserve existing commands, configuration, state addresses, execution order, and reporting. + +This work supplies reusable host interfaces for the separate Terragrunt integration. It does not depend on the environment registry initiative or include the Terragrunt prototype. + +## Delivery sequence + +1. **Terraform component extraction (one PR).** Register the built-in provider. Move single, bulk, query, and affected execution, initialization, workspaces, hooks, shell sessions, policy, UI routing, artifact generation, and state/output lookup into `pkg/component/terraform`. Keep one Terraform production adapter in `internal/exec`. Inject shared Atmos services. Preserve current commands and behavior. +2. **Component capabilities.** Define independent discovery, preparation, state resolution, and provenance capabilities. Inventory and state reads must not run the execution lifecycle. Keep component family separate from configuration format and selected executable. +3. **External plugin adapter.** Extend the existing plugin PR stack with these capabilities. Preserve the host scheduler, cancellation, scoped credentials, streams, and structured results across the process boundary. +4. **Terragrunt integration.** Replace the prototype's injected callbacks with those capabilities. Native HCL units remain Terraform component instances and use the same execution lifecycle as native YAML instances. + +Each layer must build and pass its own tests. Each layer must meet at least 90% patch coverage. CI coverage is authoritative; local coverage reports must state their package scope. + +## Scope of the initial PR + +`pkg/component/terraform.Provider` implements the existing component interface. The host registers it with an injected runtime. `internal/exec.ExecuteTerraform` becomes the compatibility dispatcher, so single execution, scheduler nodes, migration, and plan comparison all select the provider. The component-owned `Executor` implements the runtime. Its private pipeline runs through the provider. + +`component.ExecutionContext.Options` carries the existing execution options. The internal `ShellCommandOption` type is an alias, not a second options implementation. Preserve option order, writer identity, the difference between nil and empty environments, and reporting callbacks. The request context is authoritative for execution. This is an in-process host contract. External plugins must use the separate typed protocol and host services; callbacks and writers are not wire payloads. + +`GenerateArtifacts` accepts an already resolved configuration, `ConfigAndStacksInfo`, and a working directory. The component package owns the backend, generated-file, provider-override, and required-provider generation sequence. The explicit single and bulk varfile commands also live in this package. The component execution pipeline decides when to prepare its automatic varfile. This method must not initialize Terraform or select a workspace. A reusable prepared-component capability remains a separate requirement. + +`Executor` receives `Services`, which includes the `OperationServices` interface used by `Operations`. The host supplies stack processing, templates, deferred YAML resolution, naming, generated-file processing, registry dispatch, process execution, affected analysis, authentication services, and reporting. The component owns the order in which these services run. Do not install process-global callbacks or introduce a dependency from the component package to `internal/exec`. Keep deferred-context types in `pkg/component` and internal aliases to preserve type assertions across the boundary. + +Move complete source files when their dependencies permit it. Extract Terraform-only code from mixed files. Keep compatibility entry points for current callers. Remove unused private wrappers. Co-locate pure behavioral tests with the implementation; keep host integration tests in `internal/exec` and instrument both packages when measuring extraction coverage. + +The provider validates the resolved backend type's shape. Existing policy and module validation stay in the execution pipeline, where stack and authentication context are available. Command metadata must not become a passthrough allowlist. + +## Extraction acceptance criteria + +- The Terraform provider and its interfaces must not import `internal/exec`. +- `internal/exec` must contain one Terraform production adapter file. Do not meet this requirement by renaming or combining Terraform business logic inside that package. +- Each extraction must remove the superseded implementation and move its behavioral tests with it. A second copy does not count as extraction. +- Preserve Terraform/OpenTofu selection, initialization, workspace selection, saved plans, dry-run behavior, hooks, retries, and policy enforcement. +- Preserve single, bulk, query, and affected dispatch, including reverse destruction order. +- Preserve stdout/stderr destination and capture, UI execution, cancellation, detailed exit codes, auth, and execution reporting. +- Preserve inventory identities used by list/describe, state functions, and Atmos Pro. +- Tests that replace the global registry must restore all providers they found. + +The remaining host adapter composes services and preserves existing entry points. `NewTerraformExecutor` creates an independent set of service bindings without changing the registry. Component execution, artifact generation, and reference getters use those bindings. The component retains the existing process-wide state and authentication caches; preserve their keys and invalidation rules. + +## Ownership boundary + +| Owner | Responsibility | +| --- | --- | +| `pkg/component/terraform` | Terraform/OpenTofu lifecycle, arguments, authentication orchestration, initialization, workspaces, hooks, policy, retries, UI routing, shell sessions, generation, plan comparison, and state/output lookup. | +| `internal/exec/terraform.go` | Service composition, built-in provider registration, and compatibility entry points. This is the only Terraform production file in `internal/exec`. | +| Shared Atmos host services | Stack and template evaluation, deferred authentication, generic affected analysis, process execution, validation, and reporting. These remain reusable by other component types. | +| `pkg/component` | Execution options and shared data contracts. Internal aliases preserve existing callers and type assertions. | + +The component must not import `internal/exec`. Service callbacks are in-process dependencies, not an external plugin protocol. An external plugin must use typed requests and host capabilities instead of serializing callbacks or writers. + +Move unit tests with the implementation. Keep tests of real host adapters in `internal/exec`, or use an external test harness to bind an independent executor to the host. Terraform-named test files in `internal/exec` do not count as production implementation. Preserve existing assertions when moving tests. + +This PR does not implement external plugin transport, Terragrunt support, or the new discovery and prepared-component capabilities. diff --git a/errors/exit_code.go b/errors/exit_code.go index 3b866f22726..a4c2917bad0 100644 --- a/errors/exit_code.go +++ b/errors/exit_code.go @@ -99,3 +99,27 @@ func GetExitCode(err error) int { return 1 // default } + +// PrerequisiteError marks a failure from a phase that runs before the main subcommand (for example +// `terraform init` or workspace selection). Its exit status describes the prerequisite, not the +// subcommand, so callers that interpret subcommand exit codes (such as plan's detailed exit code 2) +// must not treat it as the subcommand's own result. The message and the wrapped chain are unchanged. +type PrerequisiteError struct { + Err error +} + +func (e *PrerequisiteError) Error() string { + return e.Err.Error() +} + +func (e *PrerequisiteError) Unwrap() error { + return e.Err +} + +// AsPrerequisiteError marks err as a prerequisite failure. A nil error stays nil. +func AsPrerequisiteError(err error) error { + if err == nil { + return nil + } + return &PrerequisiteError{Err: err} +} diff --git a/internal/exec/helmfile_test.go b/internal/exec/helmfile_test.go index cfa2fe10cad..9eb78b5fd62 100644 --- a/internal/exec/helmfile_test.go +++ b/internal/exec/helmfile_test.go @@ -560,3 +560,14 @@ func TestHelmDiffColorEnabled(t *testing.T) { assert.True(t, helmDiffColorEnabled(term)) }) } + +// A dry run never downloads source, so a cold source Helmfile component must not be rejected as missing. +// Helmfile dry runs return through previewHelmfile before the component directory check. +func TestExecuteHelmfile_DryRunAcceptsColdSourceComponent(t *testing.T) { + writeColdSourceProject(t, "helmfile", "cold") + info := schema.ConfigAndStacksInfo{ + Stack: "dev", ComponentType: "helmfile", ComponentFromArg: "cold", SubCommand: "diff", + ProcessTemplates: true, ProcessFunctions: true, DryRun: true, + } + require.NoError(t, ExecuteHelmfile(info)) +} diff --git a/internal/exec/packer.go b/internal/exec/packer.go index c54b00417fa..5d427f6ee5e 100644 --- a/internal/exec/packer.go +++ b/internal/exec/packer.go @@ -150,7 +150,7 @@ func ExecutePacker( if err != nil { return err } - if !componentPathExists { + if !componentPathExists && !component.DryRunDefersMissingPath(info) { basePath, _ := u.GetComponentBasePath(&atmosConfig, componentTypePacker) return fmt.Errorf( "%w: '%s' points to the Packer component '%s', but it does not exist in '%s'", diff --git a/internal/exec/packer_test.go b/internal/exec/packer_test.go index 8422282afac..c9e2297bc62 100644 --- a/internal/exec/packer_test.go +++ b/internal/exec/packer_test.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "net/url" "os" "path/filepath" "strings" @@ -997,3 +998,100 @@ func TestExecutePackerCommandWithRetry_NonMatchingError_FailsFast(t *testing.T) require.NoError(t, readErr) assert.Len(t, counterBytes, 1, "non-matching error must fail fast on the first attempt") } + +// writeColdSourceProject creates a project whose single component of the given type declares a JIT +// source that has not been provisioned, so its component directory does not exist. +func writeColdSourceProject(t *testing.T, componentType, component string) { + t.Helper() + root := t.TempDir() + require.NoError(t, os.MkdirAll(filepath.Join(root, "stacks"), 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(root, "atmos.yaml"), []byte(`base_path: . +components: + `+componentType+`: + base_path: components/`+componentType+` +stacks: + base_path: stacks + included_paths: ['*.yaml'] + name_template: '{{ .vars.stage }}' +`), 0o600)) + require.NoError(t, os.WriteFile(filepath.Join(root, "stacks", "dev.yaml"), []byte(`vars: {stage: dev} +components: + `+componentType+`: + `+component+`: +`+coldSourceComponentBody()), 0o600)) + t.Chdir(root) + t.Setenv("ATMOS_CLI_CONFIG_PATH", root) + t.Setenv("ATMOS_BASE_PATH", root) +} + +func coldSourceComponentBody() string { + return ` source: + uri: github.com/cloudposse/atmos-test-nonexistent//modules/cold + version: v0.0.0 + vars: {name: cold} +` +} + +// A dry run never downloads source, so a cold source component must not be rejected as missing. +func TestExecutePacker_DryRunAcceptsColdSourceComponent(t *testing.T) { + writeColdSourceProject(t, "packer", "cold") + info := schema.ConfigAndStacksInfo{ + Stack: "dev", ComponentType: "packer", ComponentFromArg: "cold", SubCommand: "validate", + ProcessTemplates: true, ProcessFunctions: true, DryRun: true, + } + require.NoError(t, ExecutePacker(&info, &PackerFlags{})) + _, err := os.Stat(filepath.Join("components", "packer", "cold")) + require.ErrorIs(t, err, os.ErrNotExist) +} + +// A dry run still rejects a missing component that has no source. +func TestExecutePacker_DryRunStillRejectsMissingLocalComponent(t *testing.T) { + writeColdSourceProject(t, "packer", "local") + root, err := os.Getwd() + require.NoError(t, err) + require.NoError(t, os.WriteFile(filepath.Join(root, "stacks", "dev.yaml"), []byte(`vars: {stage: dev} +components: + packer: + local: + vars: {name: local} +`), 0o600)) + info := schema.ConfigAndStacksInfo{ + Stack: "dev", ComponentType: "packer", ComponentFromArg: "local", SubCommand: "validate", + ProcessTemplates: true, ProcessFunctions: true, DryRun: true, + } + assert.ErrorIs(t, ExecutePacker(&info, &PackerFlags{}), errUtils.ErrInvalidComponent) +} + +func TestExecutePacker_ProvisionsColdSourceComponent(t *testing.T) { + writeColdSourceProject(t, "packer", "cold") + root, err := os.Getwd() + require.NoError(t, err) + source := t.TempDir() + require.NoError(t, os.WriteFile(filepath.Join(source, "template.pkr.hcl"), []byte("packer {}\n"), 0o600)) + sourceURL := (&url.URL{Scheme: "file", Path: filepath.ToSlash(source)}).String() + require.NoError(t, os.WriteFile(filepath.Join(root, "stacks", "dev.yaml"), []byte(`vars: {stage: dev} +components: + packer: + cold: + source: + uri: '`+sourceURL+`' + vars: {name: cold} +`), 0o600)) + + original := executePackerShellCommand + t.Cleanup(func() { executePackerShellCommand = original }) + var capturedDir string + executePackerShellCommand = func(_ schema.AtmosConfiguration, _ string, _ []string, dir string, _ []string, _ bool, _ string, _ ...ShellCommandOption) error { + capturedDir = dir + return nil + } + info := schema.ConfigAndStacksInfo{ + Stack: "dev", ComponentType: "packer", ComponentFromArg: "cold", SubCommand: "validate", + ProcessTemplates: true, ProcessFunctions: true, + } + require.NoError(t, ExecutePacker(&info, &PackerFlags{})) + require.Equal(t, filepath.Join(root, "components", "packer", "cold"), capturedDir) + content, err := os.ReadFile(filepath.Join(capturedDir, "template.pkr.hcl")) + require.NoError(t, err) + require.Equal(t, "packer {}\n", string(content)) +} diff --git a/internal/exec/terraform_plan_diff_main_test.go b/internal/exec/terraform_plan_diff_main_test.go index 6c14297bab6..3cf67b516da 100644 --- a/internal/exec/terraform_plan_diff_main_test.go +++ b/internal/exec/terraform_plan_diff_main_test.go @@ -372,21 +372,30 @@ func TestCopyPlanFileIfNeeded(t *testing.T) { err := os.WriteFile(externalPlanFile, []byte("external plan data"), 0o644) require.NoError(t, err) + // A caller-owned plan with the same basename must survive copying and cleanup. + existingPlan := filepath.Join(componentDir, filepath.Base(externalPlanFile)) + require.NoError(t, os.WriteFile(existingPlan, []byte("existing caller plan"), 0o644)) result, cleanup, err := copyPlanFileIfNeeded(externalPlanFile, componentDir) - assert.NoError(t, err) - assert.NotNil(t, cleanup) + require.NoError(t, err) + require.NotNil(t, cleanup) + t.Cleanup(cleanup) assert.Equal(t, componentDir, filepath.Dir(result)) - assert.NotEqual(t, filepath.Join(componentDir, "external.plan"), result) + assert.NotEqual(t, existingPlan, result) - // Verify the file was copied + // Verify the private copy has the source bytes. copiedData, err := os.ReadFile(result) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, "external plan data", string(copiedData)) - // Call cleanup and verify file is removed + // Cleanup removes only the helper-owned copy, retaining both caller files. cleanup() - _, err = os.Stat(result) - assert.True(t, os.IsNotExist(err)) + assert.NoFileExists(t, result) + originalData, err := os.ReadFile(externalPlanFile) + require.NoError(t, err) + assert.Equal(t, "external plan data", string(originalData)) + existingData, err := os.ReadFile(existingPlan) + require.NoError(t, err) + assert.Equal(t, "existing caller plan", string(existingData)) }) // Test 3: Non-existent source file diff --git a/internal/exec/terraform_plan_diff_test.go b/internal/exec/terraform_plan_diff_test.go index b07537ec987..9986246bbe3 100644 --- a/internal/exec/terraform_plan_diff_test.go +++ b/internal/exec/terraform_plan_diff_test.go @@ -540,7 +540,7 @@ func setupPlanDiffPolicyTest(t *testing.T, tc *planDiffCallerTestCase) (schema.A // TestPlanDiffPolicyCallers verifies that plan-diff and deployment verification both honor the // configured exclusions. It runs serially because it changes the working directory, sets -// environment variables, and replaces errUtils.OsExit. Policy and display details are covered +// environment variables. Policy and display details are covered // in pkg/terraform/plandiff. func TestPlanDiffPolicyCallers(t *testing.T) { for _, caller := range []string{"plan-diff", "verification"} { @@ -564,16 +564,13 @@ func TestPlanDiffPolicyCallers(t *testing.T) { } return } - oldExit := errUtils.OsExit - t.Cleanup(func() { errUtils.OsExit = oldExit }) - exitCode := 0 - errUtils.OsExit = func(code int) { exitCode = code } info.AdditionalArgsAndFlags = []string{"--orig=" + orig, "--new=" + fresh} - require.NoError(t, TerraformPlanDiff(&config, &info)) + err := TerraformPlanDiff(&config, &info) if tc.wantDiff { - assert.Equal(t, 2, exitCode) + require.ErrorIs(t, err, errUtils.ErrPlanHasDiff) + assert.Equal(t, 2, errUtils.GetExitCode(err)) } else { - assert.Zero(t, exitCode) + require.NoError(t, err) } }) } diff --git a/internal/terraform_backend/source_workdir_state_test.go b/internal/terraform_backend/source_workdir_state_test.go new file mode 100644 index 00000000000..fc32a527c09 --- /dev/null +++ b/internal/terraform_backend/source_workdir_state_test.go @@ -0,0 +1,80 @@ +package terraform_backend_test + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + + errUtils "github.com/cloudposse/atmos/errors" + tb "github.com/cloudposse/atmos/internal/terraform_backend" + "github.com/cloudposse/atmos/pkg/provisioner/workdir" + "github.com/cloudposse/atmos/pkg/schema" +) + +func TestSourceWorkdirStateUsesOverrideAndNestedModule(t *testing.T) { + for _, explicitBackend := range []bool{false, true} { + t.Run(map[bool]string{false: "workspace", true: "backend-path"}[explicitBackend], func(t *testing.T) { + base := t.TempDir() + config := &schema.AtmosConfiguration{BasePath: base} + sections := map[string]any{ + "atmos_component": "instance", "atmos_stack": "dev", "workspace": "dev", + "source": "./source", "component": "module", + "metadata": map[string]any{"working_directory": "custom", "component": "modules/child"}, + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + } + relativeState := filepath.Join("terraform.tfstate.d", "dev", "terraform.tfstate") + if explicitBackend { + relativeState = "saved-state.json" + sections["backend"] = map[string]any{"path": relativeState} + } + statePath := filepath.Join(base, "custom", "modules", "child", relativeState) + require.NoError(t, os.MkdirAll(filepath.Dir(statePath), 0o755)) + state := []byte(`{"version":4,"serial":7,"lineage":"preserved","outputs":{}}`) + require.NoError(t, os.WriteFile(statePath, state, 0o600)) + require.NoError(t, workdir.WriteMetadata(filepath.Join(base, "custom"), &workdir.WorkdirMetadata{Component: "instance", Stack: "dev"})) + got, err := tb.ReadTerraformBackendLocal(config, §ions, nil) + require.NoError(t, err) + require.Equal(t, state, got) + + // An occupied legacy target must produce a migration error, never a + // missing-state fallback or a read from a different instance. + legacy, err := workdir.BuildPath(base, "terraform", "instance", "dev", sections) + require.NoError(t, err) + require.NoError(t, os.MkdirAll(legacy, 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(legacy, "terraform.tfstate"), []byte("legacy state"), 0o600)) + _, err = tb.ReadTerraformBackendLocal(config, §ions, nil) + require.ErrorIs(t, err, errUtils.ErrWorkdirProvision) + after, err := os.ReadFile(statePath) + require.NoError(t, err) + require.Equal(t, state, after) + }) + } +} + +func TestSourceWorkdirStateRejectsOtherOwner(t *testing.T) { + for _, owner := range []struct{ component, stack string }{{"other", "dev"}, {"instance", "prod"}} { + t.Run(owner.component+"-"+owner.stack, func(t *testing.T) { + base := t.TempDir() + config := &schema.AtmosConfiguration{BasePath: base} + sections := map[string]any{ + "atmos_component": "instance", "atmos_stack": "dev", "workspace": "default", + "source": "./source", "component": "module", + "metadata": map[string]any{"working_directory": "custom"}, + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + } + target := filepath.Join(base, "custom") + require.NoError(t, workdir.WriteMetadata(target, &workdir.WorkdirMetadata{Component: owner.component, Stack: owner.stack})) + state := []byte(`{"version":4,"outputs":{"private":{"value":"other-instance"}}}`) + statePath := filepath.Join(target, "terraform.tfstate") + require.NoError(t, os.WriteFile(statePath, state, 0o600)) + got, err := tb.ReadTerraformBackendLocal(config, §ions, nil) + require.ErrorIs(t, err, errUtils.ErrWorkdirProvision) + require.Nil(t, got) + after, err := os.ReadFile(statePath) + require.NoError(t, err) + require.Equal(t, state, after) + }) + } +} diff --git a/internal/terraform_backend/terraform_backend_local.go b/internal/terraform_backend/terraform_backend_local.go index 8e21559b411..5bab5d70d6d 100644 --- a/internal/terraform_backend/terraform_backend_local.go +++ b/internal/terraform_backend/terraform_backend_local.go @@ -9,8 +9,10 @@ import ( "time" errUtils "github.com/cloudposse/atmos/errors" + componentpath "github.com/cloudposse/atmos/pkg/component" log "github.com/cloudposse/atmos/pkg/logger" "github.com/cloudposse/atmos/pkg/perf" + provSource "github.com/cloudposse/atmos/pkg/provisioner/source" provWorkdir "github.com/cloudposse/atmos/pkg/provisioner/workdir" "github.com/cloudposse/atmos/pkg/schema" u "github.com/cloudposse/atmos/pkg/utils" @@ -33,6 +35,10 @@ func ReadTerraformBackendLocal( workspace := GetTerraformWorkspace(componentSections) componentPath := resolveLocalBackendComponentPath(atmosConfig, componentSections) + componentPath, err := resolveSourceLocalBackendPath(atmosConfig, componentSections, componentPath) + if err != nil { + return nil, err + } var tfStateFilePath string if backendPath := configuredLocalBackendPath(componentSections); backendPath != "" { @@ -69,6 +75,20 @@ func ReadTerraformBackendLocal( return content, nil } +// resolveSourceLocalBackendPath shares source target and nested-module placement with execution. +func resolveSourceLocalBackendPath(config *schema.AtmosConfiguration, sections *map[string]any, fallback string) (string, error) { + if !provSource.HasSource(*sections) || !provWorkdir.IsWorkdirEnabled(*sections) { + return fallback, nil + } + target, err := provSource.ResolveTarget(config, "terraform", getAtmosComponentInstanceFromSections(sections), *sections) + if err != nil { + return "", err + } + metadata, _ := (*sections)["metadata"].(map[string]any) + subpath, _ := metadata["component"].(string) + return componentpath.ResolveWorkdirSubpath(subpath, target.Dir) +} + func configuredLocalBackendPath(sections *map[string]any) string { backend := GetComponentBackend(sections) if backend == nil { diff --git a/pkg/auth/cloud/aws/files.go b/pkg/auth/cloud/aws/files.go index a1e99833326..526838d3895 100644 --- a/pkg/auth/cloud/aws/files.go +++ b/pkg/auth/cloud/aws/files.go @@ -108,7 +108,7 @@ func withFileLock(ctx context.Context, path string, fn func() error) error { // intentionally best-effort on Windows. Keep the stable sibling lock path. if err := filelock.New(path+".lock").WithExclusive(lockCtx, fn); err != nil { if errors.Is(err, filelock.ErrAcquire) { - return fmt.Errorf("%w: %w", ErrFileLockTimeout, err) + return errors.Join(ErrFileLockTimeout, errUtils.ErrCacheLocked, err) } return err } diff --git a/pkg/auth/deferred/manager_test.go b/pkg/auth/deferred/manager_test.go index c3a7cd9bd88..73f62318ec9 100644 --- a/pkg/auth/deferred/manager_test.go +++ b/pkg/auth/deferred/manager_test.go @@ -173,7 +173,8 @@ func TestManagerDelegatesScopedIdentityOwnership(t *testing.T) { err := operation(ctx, &schema.AuthContext{Environment: map[string]string{"VAULT_TOKEN": "synthetic-reader"}}) events = append(events, "released") return err - }) + }, + ) err := manager.WithIsolatedIdentity(t.Context(), "reader", func(ctx context.Context, auth *schema.AuthContext) error { events = append(events, "operation") require.Same(t, t.Context(), ctx) diff --git a/pkg/auth/fingerprint/fingerprint.go b/pkg/auth/fingerprint/fingerprint.go new file mode 100644 index 00000000000..de6059978c2 --- /dev/null +++ b/pkg/auth/fingerprint/fingerprint.go @@ -0,0 +1,30 @@ +// Package fingerprint produces opaque keys for process-local caches containing auth scopes. +package fingerprint + +import ( + "crypto/hmac" + "crypto/rand" + "crypto/sha256" + "encoding/hex" + "sync" + + "github.com/cloudposse/atmos/pkg/perf" +) + +// Keep the secret only in memory. Cache keys must not be reusable across processes +// or act as unkeyed digests of low-entropy credentials. +var processSecret = sync.OnceValue(rand.Text) + +// Key fingerprints a serialized cache identity, including any authentication material. +// The result is stable within this process only; never persist it or use it to verify passwords. +func Key(identity []byte) string { + defer perf.Track(nil, "fingerprint.Key")() + + return keyedDigest([]byte(processSecret()), identity) +} + +func keyedDigest(secret, identity []byte) string { + mac := hmac.New(sha256.New, secret) + _, _ = mac.Write(identity) + return hex.EncodeToString(mac.Sum(nil)) +} diff --git a/pkg/auth/fingerprint/fingerprint_test.go b/pkg/auth/fingerprint/fingerprint_test.go new file mode 100644 index 00000000000..1f19ff327d6 --- /dev/null +++ b/pkg/auth/fingerprint/fingerprint_test.go @@ -0,0 +1,36 @@ +package fingerprint + +import ( + "bytes" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestKeyedDigest(t *testing.T) { + // RFC 4231, test case 1, checks that both the secret and input reach HMAC-SHA256. + secret := bytes.Repeat([]byte{0x0b}, 20) + identity := []byte("Hi There") + digest := keyedDigest(secret, identity) + require.Equal(t, "b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7", digest) + require.NotEqual(t, digest, keyedDigest([]byte("another process secret"), identity)) + require.NotEqual(t, digest, keyedDigest(secret, []byte("another auth scope"))) +} + +func TestKeyUsesProcessSecret(t *testing.T) { + identity := []byte("same auth scope") + require.Equal(t, keyedDigest([]byte(processSecret()), identity), Key(identity)) +} + +func TestKeyStableAcrossConcurrentCallers(t *testing.T) { + const callers = 32 + results := make(chan string, callers) + for range callers { + go func() { results <- Key([]byte("same auth scope")) }() + } + want := <-results + for range callers - 1 { + require.Equal(t, want, <-results) + } + require.NotEqual(t, want, Key([]byte("rotated auth scope"))) +} diff --git a/pkg/auth/providers/github/oidc_retry_test.go b/pkg/auth/providers/github/oidc_retry_test.go index 5b0bb4cf7fc..319b4d8c3a2 100644 --- a/pkg/auth/providers/github/oidc_retry_test.go +++ b/pkg/auth/providers/github/oidc_retry_test.go @@ -116,9 +116,15 @@ func startTokenServer(t *testing.T, http2 bool, handlers ...http.HandlerFunc) *t ts.conns.Add(1) } } + release := make(chan struct{}) + ts.Config.BaseContext = func(net.Listener) context.Context { + return context.WithValue(context.Background(), hangReleaseKey{}, release) + } ts.EnableHTTP2 = http2 ts.StartTLS() t.Cleanup(ts.Close) + // Cleanups run last-in first-out: release hanging handlers before Close waits for them. + t.Cleanup(func() { close(release) }) return ts } @@ -141,9 +147,16 @@ func respondBody(body string) http.HandlerFunc { } // respondHang blocks until the client gives up on the request. +// The hangReleaseKey type carries the token server's release channel into each request context. +type hangReleaseKey struct{} + +// respondHang never answers: it holds the request until the test ends, so the client's own +// timeout always ends the attempt. Waiting only on the request context is not enough, because a +// context that ends first returns an empty 200 response that the client reads as EOF. func respondHang() http.HandlerFunc { return func(_ http.ResponseWriter, r *http.Request) { - <-r.Context().Done() + release, _ := r.Context().Value(hangReleaseKey{}).(chan struct{}) + <-release } } diff --git a/pkg/component/kubernetes/executor.go b/pkg/component/kubernetes/executor.go index 514e5c18af5..8c47535cfce 100644 --- a/pkg/component/kubernetes/executor.go +++ b/pkg/component/kubernetes/executor.go @@ -206,7 +206,7 @@ func ensureComponentInputExists( if err != nil { return err } - if componentPathExists || len(manifestsInput) > 0 || len(pathsInput) > 0 { + if componentPathExists || component.DryRunDefersMissingPath(info) || len(manifestsInput) > 0 || len(pathsInput) > 0 { return nil } diff --git a/pkg/component/kubernetes/executor_test.go b/pkg/component/kubernetes/executor_test.go index 22531fba412..f651b2b50b7 100644 --- a/pkg/component/kubernetes/executor_test.go +++ b/pkg/component/kubernetes/executor_test.go @@ -947,6 +947,33 @@ func TestValidateAndResolveComponentRequiresInputSource(t *testing.T) { require.ErrorIs(t, err, errUtils.ErrInvalidComponent) } +// A dry run never downloads source, so a cold source component has no directory yet and must not be +// rejected as missing input; a component without a source still is. +func TestValidateAndResolveComponentDryRunAcceptsColdSource(t *testing.T) { + original := provisionAndResolveComponentPath + t.Cleanup(func() { provisionAndResolveComponentPath = original }) + missingPath := filepath.Join(t.TempDir(), "missing") + provisionAndResolveComponentPath = func(context.Context, *schema.AtmosConfiguration, *schema.ConfigAndStacksInfo, string, string) (string, bool, error) { + return missingPath, false, nil + } + atmosConfig := &schema.AtmosConfiguration{BasePath: t.TempDir()} + atmosConfig.Components.Kubernetes.BasePath = filepath.Join("components", "kubernetes") + + newInfo := func(dryRun bool, section map[string]any) *schema.ConfigAndStacksInfo { + return &schema.ConfigAndStacksInfo{DryRun: dryRun, FinalComponent: "api", ComponentFromArg: "api", ComponentSection: section} + } + cold := map[string]any{"provider": ProviderKubectl, "source": map[string]any{"uri": "github.com/acme/manifests"}} + + _, err := validateAndResolveComponent(atmosConfig, newInfo(true, cold)) + require.NoError(t, err) + + _, err = validateAndResolveComponent(atmosConfig, newInfo(false, cold)) + require.ErrorIs(t, err, errUtils.ErrInvalidComponent, "a real run must still require the provisioned directory") + + _, err = validateAndResolveComponent(atmosConfig, newInfo(true, map[string]any{"provider": ProviderKubectl})) + require.ErrorIs(t, err, errUtils.ErrInvalidComponent, "a dry run must still reject a missing local component") +} + func TestMaybeAutoGenerateFilesGeneratesConfiguredFiles(t *testing.T) { atmosConfig := &schema.AtmosConfiguration{} atmosConfig.Components.Kubernetes.AutoGenerateFiles = true diff --git a/pkg/component/terraform/execute_command.go b/pkg/component/terraform/execute_command.go index e526464a463..036886350d1 100644 --- a/pkg/component/terraform/execute_command.go +++ b/pkg/component/terraform/execute_command.go @@ -22,7 +22,6 @@ import ( proexec "github.com/cloudposse/atmos/pkg/proexec" retry "github.com/cloudposse/atmos/pkg/retry" schema "github.com/cloudposse/atmos/pkg/schema" - autoinit "github.com/cloudposse/atmos/pkg/terraform/autoinit" ) // checkTTYRequirement returns an error when `terraform apply` is invoked without @@ -115,8 +114,9 @@ func (e *Executor) runMainTerraformCommand( // call after ExecuteShellCommandWithRetry) must invalidate any existing marker first: see // executeTerraformInitCommand's matching call for why a failed init must not leave a // stale-but-still-matching marker behind for a later, unrelated invocation to trust. - if info.SubCommand == subcommandInit { - autoinit.InvalidateFromInfo(newAutoInitInputs(atmosConfig, info, componentPath, ConstructTerraformComponentVarfileName(info))) + executionInfo, prepErr := prepareExplicitProviderInit(atmosConfig, info, componentPath) + if prepErr != nil { + return prepErr } // capturedMetrics receives this invocation's subprocess-tree resource @@ -135,7 +135,7 @@ func (e *Executor) runMainTerraformCommand( info, info.SubCommand, func(o ...component.ExecutionOption) error { - return e.executeStreamingOrShell(atmosConfig, info, &streamingExecRequest{ + return e.executeStreamingOrShell(atmosConfig, executionInfo, &streamingExecRequest{ componentPath: componentPath, args: allArgsAndFlags, gatePhase: info.SubCommand, @@ -152,7 +152,7 @@ func (e *Executor) runMainTerraformCommand( // implicit init so post-init provisioners can complete and persist provider // locks for workdir and vendored components, and so the smart-init marker // gets recorded (recordAutoInit) exactly as it would for an implicit init. - if err == nil && info.SubCommand == subcommandInit { + if err == nil && info.SubCommand == subcommandInit && !info.DryRun { e.dispatchAfterInitFn(atmosConfig, info, componentPath, opts...) recordAutoInit(newAutoInitInputs(atmosConfig, info, componentPath, ConstructTerraformComponentVarfileName(info)), allArgsAndFlags) } diff --git a/pkg/component/terraform/execute_environment.go b/pkg/component/terraform/execute_environment.go index 288f73630c1..8c2c6f5b739 100644 --- a/pkg/component/terraform/execute_environment.go +++ b/pkg/component/terraform/execute_environment.go @@ -124,6 +124,8 @@ func assembleComponentEnvVars(atmosConfig *schema.AtmosConfiguration, info *sche // and deferred at the ExecuteTerraform level so the file outlives every subprocess. func configureTerraformRC(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo) error { rcMap := map[string]any{} + var semanticMap map[string]any + var cacheIdentity string if rcCfg := atmosConfig.Components.Terraform.RC; rcCfg != nil && rcCfg.Enabled { for k, v := range rcCfg.Config { @@ -136,6 +138,10 @@ func configureTerraformRC(atmosConfig *schema.AtmosConfiguration, info *schema.C } if setup, ok := info.TerraformCache.(*tfcache.Setup); ok && setup != nil { + semanticMap = cloneRCValue(rcMap).(map[string]any) + contribution, identity := setup.FingerprintContribution() + mergeCacheContribution(semanticMap, contribution) + cacheIdentity = identity mergeCacheContribution(rcMap, setup.Contribute()) // Make the terraform/tofu subprocess trust the proxy's self-signed cert. @@ -150,7 +156,7 @@ func configureTerraformRC(atmosConfig *schema.AtmosConfiguration, info *schema.C return nil } - rcEnv, rcCleanup, err := rc.Generate(rcMap, atmosConfig, info) + rcEnv, rcCleanup, err := rc.GenerateManaged(rcMap, semanticMap, cacheIdentity, atmosConfig, info) if err != nil { return err } diff --git a/pkg/component/terraform/execute_helpers_test.go b/pkg/component/terraform/execute_helpers_test.go index 8f57a6265f1..67804993e19 100644 --- a/pkg/component/terraform/execute_helpers_test.go +++ b/pkg/component/terraform/execute_helpers_test.go @@ -559,6 +559,45 @@ func TestResolveAndProvisionComponentPath_MissingWithoutGenerationFails(t *testi require.ErrorIs(t, err, errUtils.ErrInvalidTerraformComponent) } +// TestResolveAndProvisionComponentPath_DryRunMissingPath verifies a dry run rejects a missing plain +// local component, and accepts a missing directory only when a skipped step would have created it. +func TestResolveAndProvisionComponentPath_DryRunMissingPath(t *testing.T) { + originalProvisioner := provisionAndResolveTerraformComponentPath + t.Cleanup(func() { provisionAndResolveTerraformComponentPath = originalProvisioner }) + + componentDir := filepath.Join(t.TempDir(), "missing") + provisionAndResolveTerraformComponentPath = func(_ context.Context, _ provisioner.OutputWriters, _ *schema.AtmosConfiguration, _ *schema.ConfigAndStacksInfo, _ string, _ string) (string, bool, error) { + return componentDir, false, nil + } + + tests := []struct { + name string + section map[string]any + generate bool + wantErr bool + }{ + {name: "plain local component", section: map[string]any{}, wantErr: true}, + {name: "JIT source", section: map[string]any{"source": "github.com/org/repo//modules/vpc"}}, + {name: "workdir", section: map[string]any{"provision": map[string]any{"workdir": map[string]any{"enabled": true}}}}, + {name: "generated files", section: map[string]any{"generate": map[string]any{"main.tf": "# generated"}}, generate: true}, + {name: "generate section without auto-generation", section: map[string]any{"generate": map[string]any{"main.tf": "# generated"}}, wantErr: true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + atmosConfig := schema.AtmosConfiguration{BasePath: t.TempDir()} + atmosConfig.Components.Terraform.AutoGenerateFiles = tt.generate + info := schema.ConfigAndStacksInfo{FinalComponent: "missing", DryRun: true, ComponentSection: tt.section} + + _, err := NewExecutor(Services{}).resolveAndProvisionComponentPath(t.Context(), provisioner.OutputWriters{}, &atmosConfig, &info) + if tt.wantErr { + require.ErrorIs(t, err, errUtils.ErrInvalidTerraformComponent) + return + } + require.NoError(t, err) + }) + } +} + // ────────────────────────────────────────────────────────────────────────────── // handleDeploySubcommand // ────────────────────────────────────────────────────────────────────────────── diff --git a/pkg/component/terraform/execute_helpers_workspace_test.go b/pkg/component/terraform/execute_helpers_workspace_test.go index 436057877e2..c6230f757e0 100644 --- a/pkg/component/terraform/execute_helpers_workspace_test.go +++ b/pkg/component/terraform/execute_helpers_workspace_test.go @@ -240,6 +240,9 @@ func TestExecuteMainTerraformCommand_Error_Propagates(t *testing.T) { } func TestExecuteMainTerraformCommand_ExplicitInitDispatchesAfterInit(t *testing.T) { + componentPath := t.TempDir() + executable, err := os.Executable() + require.NoError(t, err) originalDispatch := testExecutor(t).dispatchAfterInitFn t.Cleanup(func() { testExecutor(t).dispatchAfterInitFn = originalDispatch }) @@ -248,19 +251,19 @@ func TestExecuteMainTerraformCommand_ExplicitInitDispatchesAfterInit(t *testing. testExecutor(t).dispatchAfterInitFn = func(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo, componentPath string, opts ...ShellCommandOption) { dispatched = true dispatchOpts = append([]ShellCommandOption(nil), opts...) - assert.Equal(t, "/tmp/component", componentPath) + assert.DirExists(t, componentPath) assert.Equal(t, subcommandInit, info.SubCommand) } atmosConfig := schema.AtmosConfiguration{} - info := schema.ConfigAndStacksInfo{SubCommand: subcommandInit, DryRun: true} + info := schema.ConfigAndStacksInfo{SubCommand: subcommandInit, Command: executable, ComponentEnvList: []string{"_ATMOS_TEST_STDOUT=initialized"}} ctx := provWorkdir.WithOutputSuppressed(t.Context()) var stdout, stderr bytes.Buffer require.NoError(t, testExecutor(t).executeMainTerraformCommand( &atmosConfig, &info, []string{subcommandInit}, - "/tmp/component", + componentPath, false, WithProcessContext(ctx), WithProcessStreams(process.Streams{Stdout: &stdout, Stderr: &stderr}), diff --git a/pkg/component/terraform/execute_init.go b/pkg/component/terraform/execute_init.go index e7f5a19a668..a28ed351a2d 100644 --- a/pkg/component/terraform/execute_init.go +++ b/pkg/component/terraform/execute_init.go @@ -9,12 +9,14 @@ import ( filepath "path/filepath" slices "slices" strings "strings" + "sync" time "time" errUtils "github.com/cloudposse/atmos/errors" component "github.com/cloudposse/atmos/pkg/component" log "github.com/cloudposse/atmos/pkg/logger" perf "github.com/cloudposse/atmos/pkg/perf" + "github.com/cloudposse/atmos/pkg/process" provisioner "github.com/cloudposse/atmos/pkg/provisioner" provWorkdir "github.com/cloudposse/atmos/pkg/provisioner/workdir" schema "github.com/cloudposse/atmos/pkg/schema" @@ -145,13 +147,17 @@ func (e *Executor) executeTerraformInitForced(atmosConfig *schema.AtmosConfigura in := newAutoInitInputs(atmosConfig, info, componentPath, varFile) // Invalidate before attempting: see executeTerraformInitCommand's matching call for why a // forced init that fails must not leave a stale-but-still-matching marker behind. - autoinit.InvalidateFromInfo(in) + if !info.DryRun { + autoinit.InvalidateFromInfo(in) + } if _, err := e.runTerraformInitSubprocess(atmosConfig, info, componentPath, args, opts...); err != nil { return err } e.dispatchAfterInit(atmosConfig, info, componentPath, opts...) - recordAutoInit(in, args) + if !info.DryRun { + recordAutoInit(in, args) + } return nil } @@ -172,7 +178,7 @@ func (e *Executor) executeTerraformInitForced(atmosConfig *schema.AtmosConfigura // prompt on every apply. Skipping the cleanup for workdir components avoids this. func prepareInitExecution(ctx context.Context, writers provisioner.OutputWriters, atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo, componentPath string) (string, error) { _, isWorkdir := info.ComponentSection[provWorkdir.WorkdirPathKey].(string) - if !isWorkdir { + if !isWorkdir && !info.DryRun { cleanTerraformWorkspace(*atmosConfig, componentPath, info.ComponentEnvList) } @@ -189,6 +195,7 @@ func prepareInitExecution(ctx context.Context, writers provisioner.OutputWriters info.ComponentSection, info.AuthContext, writers, + &provisioner.TerraformExecContext{DryRun: info.DryRun}, ); err != nil { return componentPath, fmt.Errorf("provisioner execution failed: %w", err) } @@ -230,6 +237,12 @@ func (e *Executor) executeTerraformInitPhase(atmosConfig *schema.AtmosConfigurat // need that pkg/terraform/autoinit itself cannot own, since it talks to ExecuteShellCommandWithRetry // and executeStreamingOrShell, both internal/exec concerns. func (e *Executor) runTerraformInitSubprocess(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo, componentPath string, args []string, opts ...component.ExecutionOption) (string, error) { + preparedInfo, prepErr := providerRecoveryInfo(atmosConfig, info, componentPath) + if prepErr != nil { + return "", prepErr + } + info = preparedInfo + opts = prerequisiteOutputOptions(info, opts) var buf bytes.Buffer stdoutW, stderrW := composeRetryCaptureWriters(opts, &buf) captureOpts := append(slices.Clone(opts), component.WithStdoutCapture(stdoutW), component.WithStderrCapture(stderrW)) @@ -256,6 +269,47 @@ func (e *Executor) runTerraformInitSubprocess(atmosConfig *schema.AtmosConfigura return buf.String(), err } +// prerequisiteOutputOptions keeps initialization diagnostics out of a data command's stdout. +// Explicit init and ordinary plan/apply retain their existing terminal and capture behavior. +func prerequisiteOutputOptions(info *schema.ConfigAndStacksInfo, opts []component.ExecutionOption) []component.ExecutionOption { + if !isDataSubcommand(info) { + return opts + } + var options component.ExecutionOptions + for _, opt := range opts { + opt(&options) + } + streams := process.OSStreams() + if options.Streams != nil { + streams = *options.Streams + } + if streams.Stderr == nil { + streams.Stderr = process.OSStreams().Stderr + } + // Both subprocess pumps now share stderr. Serialize their display and capture + // writes together, including callers that use one buffer for both destinations. + writeMu := &sync.Mutex{} + streams.Stderr = &syncWriter{w: streams.Stderr, sharedMu: writeMu} + capture := options.StderrCapture + if capture != nil { + capture = &syncWriter{w: capture, sharedMu: writeMu} + } + return append(slices.Clone(opts), component.WithProcessStreams(streams), + component.WithStdoutOverride(streams.Stderr), component.WithStdoutCapture(capture), component.WithStderrCapture(capture)) +} + +// isDataSubcommand reports whether the main command writes data to stdout. The CLI parser stores +// `state pull` and `state list` as single compound subcommands; the split forms are accepted as well. +func isDataSubcommand(info *schema.ConfigAndStacksInfo) bool { + switch info.SubCommand { + case "output", "show", "state pull", "state list": + return true + case "state": + return info.SubCommand2 == "pull" || info.SubCommand2 == "list" + } + return false +} + // executeTerraformInitCommand is the "smart init" decision point: it fingerprints this // invocation's init inputs, compares them against the marker recorded by the last successful // init (autoinit.Decide), and either skips the subprocess entirely or runs it with exactly the @@ -282,7 +336,9 @@ func (e *Executor) executeTerraformInitCommand(atmosConfig *schema.AtmosConfigur // Invalidate before attempting: if this init fails, a stale-but-still-matching marker must // not survive it -- see autoinit.InvalidateFromInfo's doc comment. RecordFromInfo below // re-records a fresh marker once (and only once) this attempt or its recovery retry succeeds. - autoinit.InvalidateFromInfo(in) + if !info.DryRun { + autoinit.InvalidateFromInfo(in) + } output, err := e.runTerraformInitSubprocess(atmosConfig, info, componentPath, args, opts...) usedArgs := args @@ -307,7 +363,9 @@ func (e *Executor) executeTerraformInitCommand(atmosConfig *schema.AtmosConfigur } e.dispatchAfterInit(atmosConfig, info, componentPath, opts...) - autoinit.RecordFromInfo(in, usedArgs) + if !info.DryRun { + autoinit.RecordFromInfo(in, usedArgs) + } return nil } @@ -323,6 +381,7 @@ func (e *Executor) executeTerraformInitCommand(atmosConfig *schema.AtmosConfigur // "Selected … workspace" lines. Lock completion is best-effort: a failure is logged, not // propagated, so it never fails the user's plan/apply. func (e *Executor) dispatchAfterInit(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo, componentPath string, opts ...component.ExecutionOption) { + opts = prerequisiteOutputOptions(info, opts) ctx, cancel := context.WithTimeout(component.ContextFromOptions(opts...), 5*time.Minute) defer cancel() @@ -330,6 +389,7 @@ func (e *Executor) dispatchAfterInit(atmosConfig *schema.AtmosConfiguration, inf // cannot block plan/apply past the hook's timeout. runOpts := append(slices.Clone(opts), component.WithProcessContext(ctx)) execCtx := &provisioner.TerraformExecContext{ + DryRun: info.DryRun, WorkingDir: componentPath, Run: func(args []string) error { return e.executeStreamingOrShell(atmosConfig, info, &streamingExecRequest{ diff --git a/pkg/component/terraform/execute_pipeline.go b/pkg/component/terraform/execute_pipeline.go index 4e4750fdc85..cb80e252945 100644 --- a/pkg/component/terraform/execute_pipeline.go +++ b/pkg/component/terraform/execute_pipeline.go @@ -9,6 +9,7 @@ import ( "slices" "strings" + errUtils "github.com/cloudposse/atmos/errors" auth "github.com/cloudposse/atmos/pkg/auth" "github.com/cloudposse/atmos/pkg/ci" "github.com/cloudposse/atmos/pkg/component" @@ -17,6 +18,7 @@ import ( "github.com/cloudposse/atmos/pkg/policy/planfile" "github.com/cloudposse/atmos/pkg/provisioner" "github.com/cloudposse/atmos/pkg/schema" + "github.com/cloudposse/atmos/pkg/terraform/autoinit" "github.com/cloudposse/atmos/pkg/ui" ) @@ -173,7 +175,7 @@ func (e *Executor) executeCommandPipeline( return phaseErr }) if err != nil { - return err + return errUtils.AsPrerequisiteError(err) } } @@ -187,7 +189,7 @@ func (e *Executor) executeCommandPipeline( } if err = e.runWorkspaceSetupPhase(atmosConfig, info, componentPath, opts...); err != nil { - return err + return errUtils.AsPrerequisiteError(err) } if err = checkTTYRequirement(info, opts...); err != nil { @@ -322,8 +324,26 @@ func (e *Executor) runWorkspaceSetupPhase(atmosConfig *schema.AtmosConfiguration if shouldSkipWorkspaceSetup(info) { return nil } - return ci.Group(atmosConfig, ci.DimensionPhase, terraformPhaseLabel(info, subcommandWorkspace), func() error { - return e.runWorkspaceSetup(atmosConfig, info, componentPath, opts...) + var stdout, stderr bytes.Buffer + captureOpts := append(slices.Clone(opts), component.WithMetadataOutputCapture(&stdout, &stderr)) + err := ci.Group(atmosConfig, ci.DimensionPhase, terraformPhaseLabel(info, subcommandWorkspace), func() error { + return e.runWorkspaceSetup(atmosConfig, info, componentPath, captureOpts...) + }) + if err == nil { + return nil + } + // Workspace selection can load providers before plan ever runs. Apply the same narrow, + // bounded recovery and opt-out policy here, preserving the originally requested workspace. + tf := &atmosConfig.Components.Terraform + return autoinit.Recover(autoinit.RecoverParams{ + Err: err, Output: combineExecMetadataOutput(&stdout, &stderr) + "\n" + err.Error(), + Mode: tf.EffectiveInitMode(), Reconfigure: tf.EffectiveInitReconfigure(), Upgrade: tf.EffectiveInitUpgrade(), + OptedOut: autoinit.OptedOut(atmosConfig, info), + RunInit: func(rec autoinit.Recovery) error { + return e.executeTerraformInitForcedFn(atmosConfig, info, componentPath, + ConstructTerraformComponentVarfileName(info), rec.WithReconfigure, rec.WithUpgrade, opts...) + }, + Retry: func() error { return e.runWorkspaceSetup(atmosConfig, info, componentPath, opts...) }, }) } diff --git a/pkg/component/terraform/execute_prepare.go b/pkg/component/terraform/execute_prepare.go index 0277924831c..180da8123ae 100644 --- a/pkg/component/terraform/execute_prepare.go +++ b/pkg/component/terraform/execute_prepare.go @@ -70,7 +70,7 @@ func (e *Executor) resolveAndProvisionComponentPath(ctx context.Context, writers refreshTerraformModuleInfo(info, componentPath) } - if !componentPathExists { + if !componentPathExists && !dryRunCreatesComponentPath(atmosConfig, info) { basePath, _ := u.GetComponentBasePath(atmosConfig, cfg.TerraformComponentType) return "", fmt.Errorf( "%w: '%s' points to the Terraform component '%s', but it does not exist in '%s'", @@ -84,6 +84,19 @@ func (e *Executor) resolveAndProvisionComponentPath(ctx context.Context, writers return componentPath, nil } +// dryRunCreatesComponentPath reports whether a dry run skipped the step that would have created a +// missing component directory: JIT source download, workdir provisioning, or file generation. +// A plain local component with no such step must still exist during a dry run. +func dryRunCreatesComponentPath(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo) bool { + if !info.DryRun { + return false + } + if component.DryRunDefersMissingPath(info) || provWorkdir.IsWorkdirEnabled(info.ComponentSection) { + return true + } + return atmosConfig.Components.Terraform.AutoGenerateFiles && tfgenerate.GetGenerateSectionFromComponent(info.ComponentSection) != nil +} + // autoGenerateComponentFiles creates the component directory and generates source files // when AutoGenerateFiles is enabled and a generate section is present. func (e *Executor) autoGenerateComponentFiles(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo, componentPath string) error { diff --git a/pkg/component/terraform/managed_rc_fingerprint_test.go b/pkg/component/terraform/managed_rc_fingerprint_test.go new file mode 100644 index 00000000000..d98e634293f --- /dev/null +++ b/pkg/component/terraform/managed_rc_fingerprint_test.go @@ -0,0 +1,76 @@ +package terraform + +import ( + "context" + "os" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cloudposse/atmos/pkg/schema" + "github.com/cloudposse/atmos/pkg/terraform/autoinit" + tfcache "github.com/cloudposse/atmos/pkg/terraform/cache" + "github.com/cloudposse/atmos/pkg/terraform/rc" +) + +func TestManagedRegistryRCFingerprintStable(t *testing.T) { + clearUserCLIConfigEnv(t) + config := &schema.AtmosConfiguration{} + config.Components.Terraform.Cache = &schema.TerraformCacheConfig{Enabled: true, Location: t.TempDir()} + componentPath := t.TempDir() + var hashes, contents []string + for range 2 { + setup, err := tfcache.Start(t.Context(), config) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, setup.Close(context.Background())) }) + info := &schema.ConfigAndStacksInfo{TerraformCache: setup} + require.NoError(t, configureTerraformRC(config, info)) + require.NotNil(t, info.RCCleanup) + t.Cleanup(func() { require.NoError(t, info.RCCleanup()) }) + fp, err := autoinit.Compute(autoinit.InputsFromInfo(config, info, componentPath, "")) + require.NoError(t, err) + hashes = append(hashes, fp.Hash) + for _, entry := range info.ComponentEnvList { + if path, ok := strings.CutPrefix(entry, rc.EnvKeyTFCLIConfigFile+"="); ok { + b, e := os.ReadFile(path) + require.NoError(t, e) + contents = append(contents, string(b)) + } + } + } + require.Len(t, contents, 2) + assert.NotEqual(t, contents[0], contents[1], "live proxies must use distinct ports") + assert.Equal(t, hashes[0], hashes[1], "ephemeral Atmos-owned proxy ports must not invalidate init") +} + +func TestManagedRegistryRCFingerprintTracksSemanticChanges(t *testing.T) { + clearUserCLIConfigEnv(t) + config := &schema.AtmosConfiguration{} + config.Components.Terraform.Cache = &schema.TerraformCacheConfig{Enabled: true, Location: t.TempDir()} + config.Components.Terraform.RC = &schema.TerraformRCConfig{Enabled: true, Config: map[string]any{"host": map[string]any{"private.example.com": map[string]any{"services": map[string]any{"modules.v1": "https://127.0.0.1:1234/"}}}}} + componentPath := t.TempDir() + compute := func() string { + t.Helper() + setup, err := tfcache.Start(t.Context(), config) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, setup.Close(context.Background())) }) + info := &schema.ConfigAndStacksInfo{TerraformCache: setup} + require.NoError(t, configureTerraformRC(config, info)) + t.Cleanup(func() { require.NoError(t, info.RCCleanup()) }) + fp, err := autoinit.Compute(autoinit.InputsFromInfo(config, info, componentPath, "")) + require.NoError(t, err) + return fp.Hash + } + original := compute() + services := config.Components.Terraform.RC.Config["host"].(map[string]any)["private.example.com"].(map[string]any)["services"].(map[string]any) + services["modules.v1"] = "https://127.0.0.1:5678/" + changedUser := compute() + assert.NotEqual(t, original, changedUser, "user localhost ports must remain significant") + config.Components.Terraform.Cache.Location = t.TempDir() + changedRoot := compute() + assert.NotEqual(t, changedUser, changedRoot, "cache root/trust identity must remain significant") + config.Components.Terraform.Cache.MetadataTTL = "2h" + assert.NotEqual(t, changedRoot, compute(), "cache resolution policy must remain significant") +} diff --git a/pkg/component/terraform/plan_diff.go b/pkg/component/terraform/plan_diff.go index 45b5d180891..4adc555d022 100644 --- a/pkg/component/terraform/plan_diff.go +++ b/pkg/component/terraform/plan_diff.go @@ -209,12 +209,9 @@ func (s *Operations) ComparePlansAndGenerateDiff(atmosConfig *schema.AtmosConfig _ = data.Writeln("") _ = data.Writeln(diff) - // Print the error message - errUtils.CheckErrorAndPrint(errUtils.ErrPlanHasDiff, "", "") - - // Exit with code 2 to indicate that the plans are different - errUtils.OsExit(2) - return nil // This line will never be reached + // Return the detailed status so deferred cleanup of owned temporary plans + // runs before the command boundary exits. Caller-owned plans are retained. + return errUtils.WithExitCode(errUtils.ErrPlanHasDiff, 2) } _ = data.Writeln("The planfiles are identical") @@ -265,34 +262,49 @@ func ExtractJSONFromOutput(output string) (string, error) { func CopyPlanFileIfNeeded(planFile, componentPath string) (string, func(), error) { defer perf.Track(nil, "terraform.CopyPlanFileIfNeeded")() - rel, err := filepath.Rel(componentPath, planFile) - if err == nil && !filepath.IsAbs(rel) && rel != ".." && !strings.HasPrefix(rel, ".."+string(filepath.Separator)) { + planFile, err := filepath.Abs(planFile) + if err != nil { + return "", nil, fmt.Errorf("error resolving source plan file: %w", err) + } + componentPath, err = filepath.Abs(componentPath) + if err != nil { + return "", nil, fmt.Errorf("error resolving component directory: %w", err) + } + relative, err := filepath.Rel(componentPath, planFile) + + // A different volume (Rel returns an error on Windows) is also outside the + // component directory. Preserve support for caller plans on another drive. + if err == nil && relative != ".." && !strings.HasPrefix(relative, ".."+string(filepath.Separator)) { return planFile, nil, nil } + // Open source file. src, err := os.Open(planFile) if err != nil { return "", nil, fmt.Errorf("error opening source plan file: %w", err) } defer src.Close() - // A caller may compare an external plan whose basename matches a saved plan - // in this component. Never overwrite or later delete that existing file. + // Own a unique temporary file. Never truncate a caller's same-named plan. dst, err := os.CreateTemp(componentPath, ".atmos-plan-diff-*.planfile") if err != nil { return "", nil, fmt.Errorf("error creating destination plan file: %w", err) } - cleanup := func() { _ = os.Remove(dst.Name()) } - if _, err = io.Copy(dst, src); err != nil { - _ = dst.Close() + planFileInComponentDir := dst.Name() + cleanup := func() { _ = os.Remove(planFileInComponentDir) } + + // Copy the file contents without loading it all into memory. + _, err = io.Copy(dst, src) + closeErr := dst.Close() + if err != nil { cleanup() return "", nil, fmt.Errorf("error copying plan file to component directory: %w", err) } - if err = dst.Close(); err != nil { + if closeErr != nil { cleanup() - return "", nil, fmt.Errorf("error closing destination plan file: %w", err) + return "", nil, fmt.Errorf("error closing temporary plan file: %w", closeErr) } - return dst.Name(), cleanup, nil + return planFileInComponentDir, cleanup, nil } // runTerraformShow runs the terraform show command and captures its output. @@ -334,6 +346,11 @@ func (s *Operations) runTerraformInit(atmosConfig *schema.AtmosConfiguration, di // Create a copy of the info struct with init subcommand initInfo := *info initInfo.SubCommand = "init" + // Plan-diff borrows the caller's plans. Mark the canonical plan as supplied + // so the init lifecycle does not remove it as an unrelated generated artifact. + if initInfo.PlanFile == "" { + initInfo.PlanFile = filepath.Join(dir, ConstructTerraformComponentPlanfileName(info)) + } // No manual -reconfigure flag here: initInfo.SubCommand == "init" routes this call through // ExecuteTerraform's normal explicit-init path (buildInitSubcommandArgs), which now decides diff --git a/pkg/component/terraform/plan_diff_ownership_test.go b/pkg/component/terraform/plan_diff_ownership_test.go new file mode 100644 index 00000000000..98c7fc37851 --- /dev/null +++ b/pkg/component/terraform/plan_diff_ownership_test.go @@ -0,0 +1,160 @@ +package terraform + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/component" + "github.com/cloudposse/atmos/pkg/schema" +) + +func TestPlanDiffInitPreservesCallerPlan(t *testing.T) { + root := t.TempDir() + config := &schema.AtmosConfiguration{BasePath: root} + config.Components.Terraform.BasePath = "components" + dir := filepath.Join(root, "components", "probe") + require.NoError(t, os.MkdirAll(dir, 0o755)) + info := schema.ConfigAndStacksInfo{Component: "probe", FinalComponent: "probe", ContextPrefix: "dev", SubCommand: "plan-diff"} + plan := filepath.Join(dir, "dev-probe.planfile") + require.NoError(t, os.WriteFile(plan, []byte("reviewed plan"), 0o600)) + host := NewMockOperationServices(gomock.NewController(t)) + host.EXPECT().ExecuteTerraform(gomock.Any()).DoAndReturn(func(actual schema.ConfigAndStacksInfo, _ ...component.ExecutionOption) error { + require.Equal(t, "init", actual.SubCommand) + cleanupTerraformFiles(config, &actual) + return nil + }) + require.NoError(t, NewOperations(host).runTerraformInit(config, dir, &info)) + data, err := os.ReadFile(plan) + require.NoError(t, err) + require.Equal(t, "reviewed plan", string(data)) + require.Empty(t, info.PlanFile, "do not mutate caller command metadata") +} + +func TestPlanDiffTemporaryCopyDoesNotOwnCallerFiles(t *testing.T) { + for _, relative := range []bool{false, true} { + t.Run(map[bool]string{true: "relative", false: "absolute"}[relative], func(t *testing.T) { + root := t.TempDir() + dir, sibling := filepath.Join(root, "component"), filepath.Join(root, "component-sibling") + require.NoError(t, os.MkdirAll(dir, 0o755)) + require.NoError(t, os.MkdirAll(sibling, 0o755)) + original, collision := filepath.Join(sibling, "reviewed.plan"), filepath.Join(dir, "reviewed.plan") + require.NoError(t, os.WriteFile(original, []byte("source plan"), 0o600)) + require.NoError(t, os.WriteFile(collision, []byte("other reviewed plan"), 0o600)) + source, target := original, dir + if relative { + t.Chdir(root) + source, target = filepath.Join("component-sibling", "reviewed.plan"), "component" + } + copied, cleanup, err := CopyPlanFileIfNeeded(source, target) + require.NoError(t, err) + require.NotNil(t, cleanup) + require.NotEqual(t, original, copied) + require.NotEqual(t, collision, copied) + bytes, err := os.ReadFile(copied) + require.NoError(t, err) + require.Equal(t, "source plan", string(bytes)) + cleanup() + require.NoFileExists(t, copied) + for file, want := range map[string]string{original: "source plan", collision: "other reviewed plan"} { + bytes, err := os.ReadFile(file) + require.NoError(t, err) + require.Equal(t, want, string(bytes)) + } + same, cleanup, err := CopyPlanFileIfNeeded(collision, dir) + require.NoError(t, err) + require.Equal(t, collision, same) + require.Nil(t, cleanup) + }) + } +} + +func TestPlanDiffComparisonReturnsStatusAndCleansOwnedCopies(t *testing.T) { + for _, different := range []bool{false, true} { + t.Run(map[bool]string{true: "different", false: "identical"}[different], func(t *testing.T) { + directory, sources := t.TempDir(), t.TempDir() + original, fresh := filepath.Join(sources, "original.plan"), filepath.Join(sources, "fresh.plan") + oldJSON := `{"variables":{"revision":{"value":"one"}}}` + newJSON := oldJSON + if different { + newJSON = `{"variables":{"revision":{"value":"two"}}}` + } + require.NoError(t, os.WriteFile(original, []byte(oldJSON), 0o600)) + require.NoError(t, os.WriteFile(fresh, []byte(newJSON), 0o600)) + host := NewMockOperationServices(gomock.NewController(t)) + host.EXPECT().ExecuteTerraform(gomock.Any(), gomock.Any()).DoAndReturn(func(actual schema.ConfigAndStacksInfo, options ...component.ExecutionOption) error { + require.Equal(t, "show", actual.SubCommand) + require.Equal(t, "-json", actual.AdditionalArgsAndFlags[0]) + content, err := os.ReadFile(actual.AdditionalArgsAndFlags[1]) + require.NoError(t, err) + var execution component.ExecutionOptions + for _, option := range options { + option(&execution) + } + _, err = execution.StdoutOverride.Write(content) + return err + }).Times(2) + err := NewOperations(host).ComparePlansAndGenerateDiff(&schema.AtmosConfiguration{}, &schema.ConfigAndStacksInfo{SkipInit: true}, directory, original, fresh) + if different { + require.ErrorIs(t, err, errUtils.ErrPlanHasDiff) + require.Equal(t, 2, errUtils.GetExitCode(err)) + } else { + require.NoError(t, err) + } + for file, expected := range map[string]string{original: oldJSON, fresh: newJSON} { + actual, err := os.ReadFile(file) + require.NoError(t, err) + require.Equal(t, expected, string(actual)) + } + files, err := os.ReadDir(directory) + require.NoError(t, err) + require.Empty(t, files, "only owned temporary copies may be removed") + }) + } +} + +// Copy failures must not leave a partial plan available for a later deployment. +func TestPlanDiffCopyFailurePreservesCallerFiles(t *testing.T) { + for _, scenario := range []string{"missing source", "unreadable source contents", "unavailable destination"} { + t.Run(scenario, func(t *testing.T) { + root := t.TempDir() + directory := filepath.Join(root, "component") + require.NoError(t, os.Mkdir(directory, 0o755)) + callerPlan := filepath.Join(directory, "reviewed.plan") + require.NoError(t, os.WriteFile(callerPlan, []byte("approved caller plan"), 0o600)) + source := filepath.Join(root, "reviewed.plan") + destination := directory + switch scenario { + case "missing source": + // Leave the external plan absent. + case "unreadable source contents": + // A directory can open on Unix, but reading it as plan bytes fails. + require.NoError(t, os.Mkdir(source, 0o755)) + case "unavailable destination": + require.NoError(t, os.WriteFile(source, []byte("source plan"), 0o600)) + destination = filepath.Join(root, "missing-component") + } + + copied, cleanup, err := CopyPlanFileIfNeeded(source, destination) + require.Error(t, err) + require.Empty(t, copied) + require.Nil(t, cleanup, "failure must clean up internally") + content, err := os.ReadFile(callerPlan) + require.NoError(t, err) + require.Equal(t, "approved caller plan", string(content)) + files, err := os.ReadDir(directory) + require.NoError(t, err) + require.Len(t, files, 1, "no partial temporary plan may survive") + require.Equal(t, "reviewed.plan", files[0].Name()) + if scenario == "unavailable destination" { + content, err = os.ReadFile(source) + require.NoError(t, err) + require.Equal(t, "source plan", string(content)) + } + }) + } +} diff --git a/pkg/component/terraform/prerequisite_safety_test.go b/pkg/component/terraform/prerequisite_safety_test.go new file mode 100644 index 00000000000..2c46e02e024 --- /dev/null +++ b/pkg/component/terraform/prerequisite_safety_test.go @@ -0,0 +1,115 @@ +package terraform + +import ( + "bytes" + "context" + "io" + "os" + "path/filepath" + "sync" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cloudposse/atmos/pkg/component" + "github.com/cloudposse/atmos/pkg/process" + "github.com/cloudposse/atmos/pkg/provisioner" + "github.com/cloudposse/atmos/pkg/schema" + "github.com/cloudposse/atmos/pkg/terraform/autoinit" +) + +func TestDryRunInitPreservesWorkspaceAndMarker(t *testing.T) { + for _, explicit := range []bool{false, true} { + t.Run(map[bool]string{false: "implicit", true: "explicit"}[explicit], func(t *testing.T) { + root := t.TempDir() + environment := filepath.Join(root, ".terraform", "environment") + marker := autoinit.MarkerPath(filepath.Join(root, ".terraform")) + require.NoError(t, os.MkdirAll(filepath.Dir(marker), 0o755)) + require.NoError(t, os.WriteFile(environment, []byte("dev"), 0o600)) + require.NoError(t, os.WriteFile(marker, []byte("existing marker"), 0o600)) + info := &schema.ConfigAndStacksInfo{DryRun: true, Command: "must-not-launch", SubCommand: "plan", ComponentSection: map[string]any{}} + config := &schema.AtmosConfiguration{} + _, err := prepareInitExecution(context.Background(), provisioner.OutputWriters{}, config, info, root) + require.NoError(t, err) + if explicit { + info.SubCommand = "init" + err = testExecutor(t).runMainTerraformCommand(config, info, []string{"init"}, root) + } else { + err = testExecutor(t).executeTerraformInitCommand(config, info, root, "vars.json") + } + require.NoError(t, err) + for file, expected := range map[string]string{environment: "dev", marker: "existing marker"} { + content, readErr := os.ReadFile(file) + require.NoError(t, readErr) + assert.Equal(t, expected, string(content)) + } + }) + } +} + +func TestPrerequisiteInitRoutesDataCommandDiagnostics(t *testing.T) { + executable, err := os.Executable() + require.NoError(t, err) + // "state pull"/"state list" are the representations the CLI parser produces (compound subcommand, + // empty SubCommand2); the split forms are covered too. + for _, tc := range []struct{ command, command2 string }{ + {"output", ""}, + {"show", ""}, + {"state pull", ""}, + {"state", "pull"}, + {"state list", ""}, + {"state", "list"}, + {"plan", ""}, + {"init", ""}, + } { + command := tc.command + t.Run(command+" "+tc.command2, func(t *testing.T) { + var stdout, stderr, dataCapture, diagnostics bytes.Buffer + info := &schema.ConfigAndStacksInfo{ + Command: executable, SubCommand: command, SubCommand2: tc.command2, + ComponentEnvList: []string{"_ATMOS_TEST_STDOUT=initializing\n", "_ATMOS_TEST_STDERR=diagnostic\n"}, + } + captured, err := testExecutor(t).runTerraformInitSubprocess(&schema.AtmosConfiguration{}, info, t.TempDir(), []string{"init"}, + component.WithProcessStreams(process.Streams{Stdout: &stdout, Stderr: &stderr}), + component.WithStdoutCapture(&dataCapture), component.WithStderrCapture(&diagnostics)) + require.NoError(t, err) + assert.Contains(t, captured, "initializing") + if command == "plan" || command == "init" { + assert.Contains(t, stdout.String(), "initializing") + assert.Contains(t, dataCapture.String(), "initializing") + } else { + assert.Empty(t, stdout.String()) + assert.Empty(t, dataCapture.String()) + assert.Contains(t, stderr.String(), "initializing") + assert.Contains(t, diagnostics.String(), "initializing") + } + assert.Contains(t, stderr.String(), "diagnostic") + assert.Contains(t, diagnostics.String(), "diagnostic") + }) + } +} + +func TestPrerequisiteDiagnosticDestinationsSerializeConcurrentWrites(t *testing.T) { + var output, diagnostics bytes.Buffer + opts := prerequisiteOutputOptions(&schema.ConfigAndStacksInfo{SubCommand: "output"}, []component.ExecutionOption{ + component.WithProcessStreams(process.Streams{Stdout: &output, Stderr: &diagnostics}), + component.WithStdoutCapture(&output), component.WithStderrCapture(&diagnostics), + }) + var resolved component.ExecutionOptions + for _, opt := range opts { + opt(&resolved) + } + var writers sync.WaitGroup + for _, writer := range []io.Writer{resolved.StdoutOverride, resolved.Streams.Stderr, resolved.StdoutCapture, resolved.StderrCapture} { + writers.Go(func() { + for range 1000 { + _, err := writer.Write([]byte("diagnostic\n")) + assert.NoError(t, err) + } + }) + } + writers.Wait() + assert.Empty(t, output.String()) + assert.Equal(t, 4000*len("diagnostic\n"), diagnostics.Len()) +} diff --git a/pkg/component/terraform/provider_recovery.go b/pkg/component/terraform/provider_recovery.go new file mode 100644 index 00000000000..239777b17d8 --- /dev/null +++ b/pkg/component/terraform/provider_recovery.go @@ -0,0 +1,34 @@ +package terraform + +import ( + "slices" + + "github.com/cloudposse/atmos/pkg/schema" + "github.com/cloudposse/atmos/pkg/terraform/autoinit" +) + +// providerRecoveryInfo scopes an unusable shared-cache bypass to the init subprocess. The ordinary +// invocation configuration still identifies the marker: package selections and installation rules +// are unchanged, and the component-local recovery cache remains valid after this subprocess exits. +func providerRecoveryInfo(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo, componentPath string) (*schema.ConfigAndStacksInfo, error) { + cacheDir, err := autoinit.PrepareProviderInstallation(autoinit.InputsFromInfo(atmosConfig, info, componentPath, "")) + if err != nil { + return nil, err + } + if cacheDir == "" { + return info, nil + } + clone := *info + clone.ComponentEnvList = append(slices.Clone(info.ComponentEnvList), "TF_PLUGIN_CACHE_DIR="+cacheDir) + return &clone, nil +} + +// prepareExplicitProviderInit keeps explicit init's marker and provider preparation equivalent to +// implicit init without changing the command's ordinary execution or metadata capture context. +func prepareExplicitProviderInit(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo, componentPath string) (*schema.ConfigAndStacksInfo, error) { + if info.SubCommand != subcommandInit || info.DryRun { + return info, nil + } + autoinit.InvalidateFromInfo(newAutoInitInputs(atmosConfig, info, componentPath, ConstructTerraformComponentVarfileName(info))) + return providerRecoveryInfo(atmosConfig, info, componentPath) +} diff --git a/pkg/component/terraform/provider_recovery_test.go b/pkg/component/terraform/provider_recovery_test.go new file mode 100644 index 00000000000..6c481a464c3 --- /dev/null +++ b/pkg/component/terraform/provider_recovery_test.go @@ -0,0 +1,33 @@ +package terraform + +import ( + "os" + "path/filepath" + "runtime" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cloudposse/atmos/pkg/schema" +) + +func TestProviderRecoveryInfoScopedEnvironment(t *testing.T) { + root := t.TempDir() + cache := t.TempDir() + require.NoError(t, os.WriteFile(filepath.Join(root, ".terraform.lock.hcl"), []byte("provider \"registry.terraform.io/hashicorp/null\" {\n version = \"3.2.1\"\n}\n"), 0o600)) + require.NoError(t, os.MkdirAll(filepath.Join(cache, "registry.terraform.io", "hashicorp", "null", "3.2.1", runtime.GOOS+"_"+runtime.GOARCH), 0o755)) + cfg := &schema.AtmosConfiguration{} + info := &schema.ConfigAndStacksInfo{ComponentEnvList: []string{"TF_PLUGIN_CACHE_DIR=" + cache}} + copy, err := providerRecoveryInfo(cfg, info, root) + require.NoError(t, err) + assert.Equal(t, []string{"TF_PLUGIN_CACHE_DIR=" + cache, "TF_PLUGIN_CACHE_DIR=" + filepath.Join(root, ".terraform", "atmos-provider-recovery")}, copy.ComponentEnvList) + copy.ComponentEnvList[0] = "result-change" + assert.Equal(t, "TF_PLUGIN_CACHE_DIR="+cache, info.ComponentEnvList[0]) + info.ComponentEnvList[0] = "source-change" + assert.Equal(t, "result-change", copy.ComponentEnvList[0]) + info.DryRun = true + dry, err := providerRecoveryInfo(cfg, info, root) + require.NoError(t, err) + assert.Same(t, info, dry) +} diff --git a/pkg/component/terraform/repair_coverage_test.go b/pkg/component/terraform/repair_coverage_test.go new file mode 100644 index 00000000000..295c8891387 --- /dev/null +++ b/pkg/component/terraform/repair_coverage_test.go @@ -0,0 +1,111 @@ +package terraform + +import ( + "bytes" + "os" + "path/filepath" + "runtime" + "testing" + + "github.com/stretchr/testify/require" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/auth" + authdeferred "github.com/cloudposse/atmos/pkg/auth/deferred" + "github.com/cloudposse/atmos/pkg/component" + "github.com/cloudposse/atmos/pkg/config" + "github.com/cloudposse/atmos/pkg/process" + "github.com/cloudposse/atmos/pkg/schema" +) + +func TestProviderRecoveryFailurePreventsInitExecution(t *testing.T) { + for _, explicit := range []bool{false, true} { + t.Run(map[bool]string{false: "implicit", true: "explicit"}[explicit], func(t *testing.T) { + root, cache := t.TempDir(), t.TempDir() + require.NoError(t, os.WriteFile(filepath.Join(root, ".terraform.lock.hcl"), []byte("provider \"registry.terraform.io/hashicorp/null\" {\n version = \"3.2.1\"\n}\n"), 0o600)) + require.NoError(t, os.MkdirAll(filepath.Join(cache, "registry.terraform.io", "hashicorp", "null", "3.2.1", runtime.GOOS+"_"+runtime.GOARCH), 0o755)) + require.NoError(t, os.Mkdir(filepath.Join(root, ".terraform"), 0o755)) + blocked := filepath.Join(root, ".terraform", "atmos-provider-recovery") + require.NoError(t, os.WriteFile(blocked, []byte("caller-owned blocker"), 0o600)) + executable, err := os.Executable() + require.NoError(t, err) + argsFile := filepath.Join(root, "engine-invoked") + info := &schema.ConfigAndStacksInfo{Command: executable, SubCommand: "plan", ComponentEnvList: []string{"TF_PLUGIN_CACHE_DIR=" + cache, "_ATMOS_TEST_ARGS_FILE=" + argsFile}} + if explicit { + info.SubCommand = "init" + err = testExecutor(t).runMainTerraformCommand(&schema.AtmosConfiguration{}, info, []string{"init"}, root) + } else { + _, err = testExecutor(t).runTerraformInitSubprocess(&schema.AtmosConfiguration{}, info, root, []string{"init"}) + } + require.ErrorIs(t, err, errUtils.ErrTerraformInit) + require.ErrorContains(t, err, "creating provider recovery cache") + require.NoFileExists(t, argsFile, "engine must not run after recovery preparation fails") + content, err := os.ReadFile(blocked) + require.NoError(t, err) + require.Equal(t, "caller-owned blocker", string(content)) + }) + } +} + +func TestDryRunCleanupRetainsCanonicalCallerPlan(t *testing.T) { + root := t.TempDir() + cfg := &schema.AtmosConfiguration{BasePath: root} + cfg.Components.Terraform.BasePath = "components" + info := &schema.ConfigAndStacksInfo{DryRun: true, SubCommand: "apply", Component: "probe", FinalComponent: "probe", ContextPrefix: "dev"} + plan := ConstructTerraformComponentPlanfilePath(cfg, info) + require.NoError(t, os.MkdirAll(filepath.Dir(plan), 0o755)) + require.NoError(t, os.WriteFile(plan, []byte("reviewed saved plan"), 0o600)) + cleanupTerraformFiles(cfg, info) + content, err := os.ReadFile(plan) + require.NoError(t, err) + require.Equal(t, "reviewed saved plan", string(content)) +} + +func TestShellDryRunPreservesDisabledAuthAndFilesystem(t *testing.T) { + for _, unsafe := range []bool{false, true} { + t.Run(map[bool]string{false: "valid source", true: "unsafe source"}[unsafe], func(t *testing.T) { + root := t.TempDir() + cfg := &schema.AtmosConfiguration{BasePath: root} + cfg.Components.Terraform.BasePath = "components" + executor := testExecutor(t) + executor.services.CreateAndAuthenticateAuthManager = func(ac *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo) (auth.AuthManager, error) { + require.True(t, info.AuthDisabled) + require.Equal(t, config.IdentityFlagDisabledValue, info.Identity) + require.True(t, authdeferred.AuthDisabled(ac.AuthManager), "nested deferred references must inherit disabled authentication") + return nil, nil + } + executor.services.ProcessStacks = func(_ *schema.AtmosConfiguration, info schema.ConfigAndStacksInfo, _, _, _ bool, _ []string, _ auth.AuthManager) (schema.ConfigAndStacksInfo, error) { + name := "probe" + if unsafe { + name = "../outside" + } + info.FinalComponent = "probe" + info.ComponentSection = map[string]any{"component": name, "atmos_component": "probe", "atmos_stack": "dev", "source": map[string]any{"uri": "./missing-source"}, "provision": map[string]any{"workdir": map[string]any{"enabled": true}}} + return info, nil + } + err := executor.ExecuteTerraformShell(&ShellOptions{Component: "probe", Stack: "dev", Identity: "OFF", DryRun: true}, cfg) + if unsafe { + require.ErrorIs(t, err, errUtils.ErrSourceComponentNameInvalid) + } else { + require.NoError(t, err, "dry-run must not fetch the missing source or launch a shell") + } + entries, readErr := os.ReadDir(root) + require.NoError(t, readErr) + require.Empty(t, entries, "dry-run must not create source, backend, or workdir files") + }) + } +} + +func TestPrerequisiteInitAcceptsPartialStreamsWithoutPollutingData(t *testing.T) { + executable, err := os.Executable() + require.NoError(t, err) + var stdout, diagnostics bytes.Buffer + info := &schema.ConfigAndStacksInfo{Command: executable, SubCommand: "output", ComponentEnvList: []string{"_ATMOS_TEST_STDOUT=initializing\n", "_ATMOS_TEST_STDERR=diagnostic\n"}} + captured, err := testExecutor(t).runTerraformInitSubprocess(&schema.AtmosConfiguration{}, info, t.TempDir(), []string{"init"}, + component.WithProcessStreams(process.Streams{Stdout: &stdout}), component.WithStderrCapture(&diagnostics)) + require.NoError(t, err) + require.Empty(t, stdout.String(), "prerequisite diagnostics must not corrupt output data") + require.Contains(t, captured, "initializing") + require.Contains(t, diagnostics.String(), "initializing") + require.Contains(t, diagnostics.String(), "diagnostic") +} diff --git a/pkg/component/terraform/shell.go b/pkg/component/terraform/shell.go index 7e6440068f5..5253ef388e0 100644 --- a/pkg/component/terraform/shell.go +++ b/pkg/component/terraform/shell.go @@ -8,7 +8,9 @@ import ( errUtils "github.com/cloudposse/atmos/errors" auth "github.com/cloudposse/atmos/pkg/auth" + authdeferred "github.com/cloudposse/atmos/pkg/auth/deferred" "github.com/cloudposse/atmos/pkg/component" + "github.com/cloudposse/atmos/pkg/config" log "github.com/cloudposse/atmos/pkg/logger" "github.com/cloudposse/atmos/pkg/perf" "github.com/cloudposse/atmos/pkg/provisioner" @@ -24,21 +26,32 @@ type shellConfig struct { componentPath string workingDir string varFile string + // unverifiedPath marks a dry-run path for a JIT source that has not been downloaded yet, so the + // metadata.component subpath could not be resolved against the source tree. + unverifiedPath bool } +// unverifiedPathNote explains why a dry-run component path may not be the final module root. +const unverifiedPathNote = " (unverified: source not downloaded yet; metadata.component may select a subfolder)" + // printShellDryRunInfo prints the shell configuration in dry-run mode. func printShellDryRunInfo(info *schema.ConfigAndStacksInfo, cfg *shellConfig) { ui.Writeln("Dry run mode: shell would be started with the following configuration:") ui.Writeln(" Component: " + info.ComponentFromArg) ui.Writeln(" Stack: " + info.Stack) - ui.Writeln(" Working directory: " + cfg.workingDir) + note := "" + if cfg.unverifiedPath { + note = unverifiedPathNote + } + ui.Writeln(" Working directory: " + cfg.workingDir + note) ui.Writeln(" Terraform workspace: " + info.TerraformWorkspace) - ui.Writeln(" Component path: " + cfg.componentPath) + ui.Writeln(" Component path: " + cfg.componentPath + note) ui.Writeln(" Varfile: " + cfg.varFile) } // shellInfoFromOptions builds a ConfigAndStacksInfo from ShellOptions. func shellInfoFromOptions(opts *tf.ShellOptions) schema.ConfigAndStacksInfo { + identity := config.NormalizeIdentityValue(opts.Identity) return schema.ConfigAndStacksInfo{ ComponentFromArg: opts.Component, Stack: opts.Stack, @@ -46,7 +59,8 @@ func shellInfoFromOptions(opts *tf.ShellOptions) schema.ConfigAndStacksInfo { ComponentType: "terraform", SubCommand: "shell", DryRun: opts.DryRun, - Identity: opts.Identity, + Identity: identity, + AuthDisabled: identity == config.IdentityFlagDisabledValue, SkipInit: opts.SkipInit, } } @@ -99,6 +113,13 @@ func (e *Executor) ExecuteTerraformShell(opts *tf.ShellOptions, atmosConfig *sch ) info := shellInfoFromOptions(opts) + if info.AuthDisabled { + // Callers such as the interactive UI reuse one configuration across shells. Keep the + // disabled-auth manager on an invocation-local copy so a later authenticated shell is unaffected. + localConfig := *atmosConfig + atmosConfig = &localConfig + authdeferred.ConfigureAuth(atmosConfig, info.Identity) + } // Create and authenticate AuthManager by merging global + component auth config. // This enables YAML functions like !terraform.state to use authenticated credentials. @@ -132,8 +153,17 @@ func (e *Executor) ExecuteTerraformShell(opts *tf.ShellOptions, atmosConfig *sch // This handles the workdir provisioner which may copy component files to an isolated directory. ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() + unverifiedPath := false + if info.DryRun { + var exists bool + componentPath, exists, err = component.ProvisionAndResolveComponentPath(ctx, provisioner.OutputWriters{}, atmosConfig, &info, config.TerraformComponentType, componentPath) + if err != nil { + return err + } + unverifiedPath = !exists && component.DryRunDefersMissingPath(&info) + } - err = provisioner.ExecuteProvisioners(ctx, provisioner.HookEvent(beforeTerraformInitEvent), atmosConfig, info.ComponentSection, info.AuthContext, provisioner.OutputWriters{}) + err = provisioner.ExecuteProvisioners(ctx, provisioner.HookEvent(beforeTerraformInitEvent), atmosConfig, info.ComponentSection, info.AuthContext, provisioner.OutputWriters{}, &provisioner.TerraformExecContext{DryRun: info.DryRun}) if err != nil { return errUtils.Build(errUtils.ErrProvisionerFailed). WithCause(err). @@ -156,9 +186,10 @@ func (e *Executor) ExecuteTerraformShell(opts *tf.ShellOptions, atmosConfig *sch componentPath = resolveWorkdirPath(info.ComponentSection, componentPath) cfg := &shellConfig{ - componentPath: componentPath, - workingDir: ConstructTerraformComponentWorkingDir(atmosConfig, &info), - varFile: ConstructTerraformComponentVarfileName(&info), + componentPath: componentPath, + workingDir: ConstructTerraformComponentWorkingDir(atmosConfig, &info), + varFile: ConstructTerraformComponentVarfileName(&info), + unverifiedPath: unverifiedPath, } if info.DryRun { diff --git a/pkg/component/terraform/shell_test.go b/pkg/component/terraform/shell_test.go index 5b2a27c7813..ba32c0d5239 100644 --- a/pkg/component/terraform/shell_test.go +++ b/pkg/component/terraform/shell_test.go @@ -12,6 +12,8 @@ import ( "github.com/stretchr/testify/require" errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/auth" + "github.com/cloudposse/atmos/pkg/config" iolib "github.com/cloudposse/atmos/pkg/io" provWorkdir "github.com/cloudposse/atmos/pkg/provisioner/workdir" "github.com/cloudposse/atmos/pkg/schema" @@ -21,6 +23,16 @@ import ( // errTestInitFailed is a sentinel used to assert init-failure propagation in the shell lifecycle. var errTestInitFailed = errors.New("init failed") +func TestShellInfoFromOptions_DisabledIdentity(t *testing.T) { + for _, identity := range []string{"false", "FALSE", "0", "off", "no", config.IdentityFlagDisabledValue} { + t.Run(identity, func(t *testing.T) { + info := shellInfoFromOptions(&ShellOptions{Identity: identity}) + assert.Equal(t, config.IdentityFlagDisabledValue, info.Identity) + assert.True(t, info.AuthDisabled) + }) + } +} + func TestShellInfoFromOptions(t *testing.T) { tests := []struct { name string @@ -260,6 +272,20 @@ func TestPrintShellDryRunInfo(t *testing.T) { "Terraform workspace: ", }, }, + { + name: "Unverified cold source path", + info: &schema.ConfigAndStacksInfo{ComponentFromArg: "vpc", Stack: "dev"}, + cfg: &shellConfig{ + componentPath: "/.workdir/terraform/dev-vpc", + workingDir: "/.workdir/terraform/dev-vpc", + varFile: "dev-vpc.terraform.tfvars.json", + unverifiedPath: true, + }, + expectedOutput: []string{ + "Component path: /.workdir/terraform/dev-vpc" + unverifiedPathNote, + "Working directory: /.workdir/terraform/dev-vpc" + unverifiedPathNote, + }, + }, } for _, tt := range tests { @@ -768,3 +794,27 @@ func TestPrepareShellExecution_AuthErrorStopsSetup(t *testing.T) { require.ErrorIs(t, err, errUtils.ErrInvalidAuthConfig) assert.Empty(t, info.ComponentEnvList, "env must not be assembled after an auth failure") } + +// TestExecuteTerraformShell_DisabledAuthDoesNotMutateCallerConfig verifies that --identity=false configures +// the disabled-auth manager on an invocation-local copy, so a caller that reuses its configuration (the +// interactive UI) does not carry disabled auth into a later authenticated shell. +func TestExecuteTerraformShell_DisabledAuthDoesNotMutateCallerConfig(t *testing.T) { + stop := errors.New("stop after auth setup") + var seen *schema.AtmosConfiguration + executor := NewExecutor(Services{ + CreateAndAuthenticateAuthManager: func(atmosConfig *schema.AtmosConfiguration, _ *schema.ConfigAndStacksInfo) (auth.AuthManager, error) { + seen = atmosConfig + return nil, stop + }, + }) + shared := &schema.AtmosConfiguration{} + + err := executor.ExecuteTerraformShell(&ShellOptions{Component: "vpc", Stack: "dev", Identity: "false"}, shared) + require.ErrorIs(t, err, stop) + + require.NotNil(t, seen) + assert.NotSame(t, shared, seen, "disabled auth must be configured on a copy") + assert.NotNil(t, seen.AuthManager, "the invocation must see the disabled-auth manager") + assert.Nil(t, shared.AuthManager, "the caller's configuration must keep no auth manager") + assert.Nil(t, shared.DeferredEvaluation, "the caller's configuration must keep no deferred evaluation context") +} diff --git a/pkg/component/terraform/streaming_ui.go b/pkg/component/terraform/streaming_ui.go index 50cd5d05096..ffc74472201 100644 --- a/pkg/component/terraform/streaming_ui.go +++ b/pkg/component/terraform/streaming_ui.go @@ -30,14 +30,20 @@ import ( type syncWriter struct { mu sync.Mutex w io.Writer + // sharedMu optionally serializes multiple wrappers of the same destination. + sharedMu *sync.Mutex } // Write implements io.Writer, guarding the wrapped writer with a mutex. func (s *syncWriter) Write(p []byte) (int, error) { defer perf.Track(nil, "exec.syncWriter.Write")() - s.mu.Lock() - defer s.mu.Unlock() + mu := &s.mu + if s.sharedMu != nil { + mu = s.sharedMu + } + mu.Lock() + defer mu.Unlock() return s.w.Write(p) } diff --git a/pkg/component/terraform/workspace_init_recovery_test.go b/pkg/component/terraform/workspace_init_recovery_test.go new file mode 100644 index 00000000000..46a9e80341a --- /dev/null +++ b/pkg/component/terraform/workspace_init_recovery_test.go @@ -0,0 +1,62 @@ +package terraform + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cloudposse/atmos/pkg/component" + "github.com/cloudposse/atmos/pkg/schema" +) + +func TestWorkspaceSetupInitRecovery(t *testing.T) { + for _, tc := range []struct { + name, output string + skip, never, persistent bool + wantInit int + }{ + {name: "missing provider", output: "Required plugins are not installed", wantInit: 1}, + {name: "skip init", output: "Required plugins are not installed", skip: true}, + {name: "mode never", output: "Required plugins are not installed", never: true}, + {name: "unknown provider error", output: "Failed to load plugin schemas: permission denied"}, + {name: "auth error", output: "AccessDenied: expired credentials"}, + {name: "state lock", output: "Error acquiring the state lock"}, + {name: "bounded persistent failure", output: "Required plugins are not installed", persistent: true, wantInit: 1}, + } { + t.Run(tc.name, func(t *testing.T) { + exe, err := os.Executable() + require.NoError(t, err) + path := t.TempDir() + argsFile := filepath.Join(path, "args.txt") + cfg := &schema.AtmosConfiguration{} + if tc.never { + cfg.Components.Terraform.Init.Mode = schema.TerraformInitModeNever + } + info := &schema.ConfigAndStacksInfo{SubCommand: "plan", Command: exe, TerraformWorkspace: "dev", SkipInit: tc.skip, ComponentEnvList: []string{"_ATMOS_TEST_EXIT_ONE=1", "_ATMOS_TEST_STDOUT=" + tc.output}} + executor := testExecutor(t) + calls := 0 + executor.executeTerraformInitForcedFn = func(_ *schema.AtmosConfiguration, _ *schema.ConfigAndStacksInfo, _, _ string, reconfigure, upgrade bool, _ ...component.ExecutionOption) error { + calls++ + assert.False(t, reconfigure) + assert.False(t, upgrade) + if !tc.persistent { + info.ComponentEnvList = []string{"_ATMOS_TEST_ARGS_FILE=" + argsFile} + } + return nil + } + err = executor.runWorkspaceSetupPhase(cfg, info, path) + assert.Equal(t, tc.wantInit, calls) + if tc.wantInit == 1 && !tc.persistent { + require.NoError(t, err) + content, e := os.ReadFile(argsFile) + require.NoError(t, e) + assert.Equal(t, "workspace\nselect\n-or-create\ndev", string(content)) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/pkg/component/workdir_path.go b/pkg/component/workdir_path.go index e9e25043f91..81fd9905ef6 100644 --- a/pkg/component/workdir_path.go +++ b/pkg/component/workdir_path.go @@ -147,6 +147,13 @@ func BuildAndResolveWorkdirPath( if err != nil { return "", false, err } + if provSource.HasSource(info.ComponentSection) { + target, targetErr := provSource.ResolveTarget(atmosConfig, componentType, info.FinalComponent, info.ComponentSection) + if targetErr != nil { + return "", false, targetErr + } + workdirRoot = target.Dir + } resolved, err := ResolveWorkdirSubpath(info.BaseComponentPath, workdirRoot) if err != nil { return "", false, err @@ -214,6 +221,9 @@ func ProvisionAndResolveComponentPath( componentType, fallbackComponentPath string, ) (string, bool, error) { defer perf.Track(atmosConfig, "component.ProvisionAndResolveComponentPath")() + if info.DryRun { + return resolveDryRunComponentPath(atmosConfig, info, componentType, fallbackComponentPath) + } // Provision an isolated workdir for LOCAL Terraform components (no JIT source) up front — before // any backend.tf.json / varfile generation — so those generated files land in the per-run workdir @@ -286,6 +296,52 @@ func ProvisionAndResolveComponentPath( return fallbackComponentPath, exists, err } +// DryRunDefersMissingPath reports whether an absent component directory is expected for this run. +// A dry run never downloads JIT source, so a source component that has not been provisioned yet has +// no directory to find, and executors must not reject it as a missing component. Components without +// a source keep failing when their local directory is missing. +func DryRunDefersMissingPath(info *schema.ConfigAndStacksInfo) bool { + defer perf.Track(nil, "component.DryRunDefersMissingPath")() + + return info != nil && info.DryRun && provSource.HasSource(info.ComponentSection) +} + +// resolveDryRunComponentPath validates placement without downloading source or copying a workdir. +// The existence result describes the current filesystem, not a simulated successful provision. +func resolveDryRunComponentPath(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo, componentType, fallback string) (string, bool, error) { + var err error + isWorkdir := provWorkdir.IsWorkdirEnabled(info.ComponentSection) && + (componentType == cfg.TerraformComponentType || provSource.HasSource(info.ComponentSection)) + if provSource.HasSource(info.ComponentSection) { + fallback, err = dryRunSourceTarget(atmosConfig, info, componentType) + } else if componentType == cfg.TerraformComponentType && isWorkdir { + fallback, err = provWorkdir.BuildPath(atmosConfig.BasePath, componentType, info.FinalComponent, info.Stack, info.ComponentSection) + } + if err != nil { + return "", false, err + } + if isWorkdir { + info.ComponentSection[provWorkdir.WorkdirPathKey] = fallback + } + path, err := ApplyWorkdirSubpathToSection(info) + if err != nil { + return "", false, err + } + if path != "" { + fallback = path + } + exists, err := componentDirExists(fallback, "check dry-run component path", errUtils.ErrInvalidComponent) + return fallback, exists, err +} + +func dryRunSourceTarget(config *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo, componentType string) (string, error) { + target, err := provSource.ResolveTarget(config, componentType, info.FinalComponent, info.ComponentSection) + if err != nil { + return "", err + } + return target.Dir, nil +} + // wrapWorkdirProvisionError classifies a workdir provisioning failure as ErrWorkdirProvision without // repeating the sentinel text. The workdir service already returns builder errors that wrap the // sentinel together with an explanation, context and hints; joining a second copy of the sentinel diff --git a/pkg/component/workdir_path_test.go b/pkg/component/workdir_path_test.go index 139b340a12a..972f2f8e8de 100644 --- a/pkg/component/workdir_path_test.go +++ b/pkg/component/workdir_path_test.go @@ -579,6 +579,29 @@ func TestBuildAndResolveWorkdirPath_PathTraversalPropagates(t *testing.T) { // ProvisionAndResolveComponentPath ──────────────────────────────────────────. +func TestProvisionAndResolveComponentPathDryRunDoesNotCreateSourceOrWorkdir(t *testing.T) { + for _, source := range []bool{false, true} { + t.Run(map[bool]string{false: "local", true: "source"}[source], func(t *testing.T) { + base := t.TempDir() + section := map[string]any{ + "component": "vpc", "atmos_component": "vpc", "atmos_stack": "dev", + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + } + if source { + section["source"] = map[string]any{"uri": "./does-not-exist"} + } + info := &schema.ConfigAndStacksInfo{DryRun: true, FinalComponent: "vpc", Stack: "dev", ComponentSection: section} + path, exists, err := ProvisionAndResolveComponentPath(context.Background(), provisioner.OutputWriters{}, &schema.AtmosConfiguration{BasePath: base}, info, cfg.TerraformComponentType, filepath.Join(base, "components", "vpc")) + require.NoError(t, err) + assert.False(t, exists) + assert.NotEmpty(t, path) + entries, err := os.ReadDir(base) + require.NoError(t, err) + assert.Empty(t, entries, "dry-run must not download source or create an empty workdir") + }) + } +} + // TestProvisionAndResolveComponentPath_NoSourceReturnsFallback verifies the // short-circuit when no source is configured: the orchestrator must skip // AutoProvisionSource entirely and report whether the fallback exists. @@ -898,3 +921,22 @@ func TestWrapWorkdirProvisionError(t *testing.T) { }) } } + +func TestDryRunDefersMissingPath(t *testing.T) { + source := map[string]any{"source": map[string]any{"uri": "github.com/acme/mod"}} + tests := []struct { + name string + info *schema.ConfigAndStacksInfo + want bool + }{ + {"dry run with a source component", &schema.ConfigAndStacksInfo{DryRun: true, ComponentSection: source}, true}, + {"dry run without a source", &schema.ConfigAndStacksInfo{DryRun: true, ComponentSection: map[string]any{}}, false}, + {"real run with a source component", &schema.ConfigAndStacksInfo{ComponentSection: source}, false}, + {"nil info", nil, false}, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + assert.Equal(t, test.want, DryRunDefersMissingPath(test.info)) + }) + } +} diff --git a/pkg/component/workdir_repair_coverage_test.go b/pkg/component/workdir_repair_coverage_test.go new file mode 100644 index 00000000000..2c5fe5064b8 --- /dev/null +++ b/pkg/component/workdir_repair_coverage_test.go @@ -0,0 +1,68 @@ +package component + +import ( + "context" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/config" + "github.com/cloudposse/atmos/pkg/provisioner" + "github.com/cloudposse/atmos/pkg/provisioner/workdir" + "github.com/cloudposse/atmos/pkg/schema" +) + +func TestRebuiltSourceWorkdirUsesExplicitRootAndNestedModule(t *testing.T) { + root := t.TempDir() + explicit := filepath.Join(root, "explicit") + nested := filepath.Join(explicit, "nested") + require.NoError(t, os.MkdirAll(nested, 0o755)) + require.NoError(t, workdir.WriteMetadata(explicit, &workdir.WorkdirMetadata{Component: "alias", Stack: "dev"})) + require.NoError(t, os.WriteFile(filepath.Join(nested, "terraform.tfstate"), []byte("existing state"), 0o600)) + info := &schema.ConfigAndStacksInfo{FinalComponent: "alias", Stack: "dev", BaseComponentPath: "nested", ComponentSection: map[string]any{ + "component": "module", "atmos_component": "alias", "atmos_stack": "dev", + "source": map[string]any{"uri": "./not-fetched"}, "settings": map[string]any{"working_directory": explicit}, + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + }} + path, exists, err := BuildAndResolveWorkdirPath(&schema.AtmosConfiguration{BasePath: root}, info, config.TerraformComponentType) + require.NoError(t, err) + require.True(t, exists) + require.Equal(t, nested, path, "rebuilt metadata must find the same explicit source module") + content, err := os.ReadFile(filepath.Join(path, "terraform.tfstate")) + require.NoError(t, err) + require.Equal(t, "existing state", string(content)) + require.NoDirExists(t, filepath.Join(root, ".workdir")) +} + +func TestSourcePathValidationRemainsActiveDuringDryRunAndRebuild(t *testing.T) { + for _, operation := range []string{"dry-run source", "dry-run subpath", "rebuild source"} { + t.Run(operation, func(t *testing.T) { + root := t.TempDir() + section := map[string]any{"component": "module", "atmos_component": "alias", "atmos_stack": "dev", "source": map[string]any{"uri": "./missing"}, "provision": map[string]any{"workdir": map[string]any{"enabled": true}}} + info := &schema.ConfigAndStacksInfo{DryRun: true, FinalComponent: "alias", Stack: "dev", ComponentSection: section} + if operation == "dry-run subpath" { + info.BaseComponentPath = filepath.Join(root, "outside") + } else { + section["component"] = "../outside" + } + cfg := &schema.AtmosConfiguration{BasePath: root} + var err error + if operation == "rebuild source" { + _, _, err = BuildAndResolveWorkdirPath(cfg, info, config.TerraformComponentType) + } else { + _, _, err = ProvisionAndResolveComponentPath(context.Background(), provisioner.OutputWriters{}, cfg, info, config.TerraformComponentType, root) + } + if operation == "dry-run subpath" { + require.ErrorIs(t, err, errUtils.ErrWorkdirProvision) + } else { + require.ErrorIs(t, err, errUtils.ErrSourceComponentNameInvalid) + } + entries, err := os.ReadDir(root) + require.NoError(t, err) + require.Empty(t, entries, "invalid paths must fail before provisioning anything") + }) + } +} diff --git a/pkg/datafetcher/schema/atmos/manifest/1.0.json b/pkg/datafetcher/schema/atmos/manifest/1.0.json index 5c108b606f5..387afae680f 100644 --- a/pkg/datafetcher/schema/atmos/manifest/1.0.json +++ b/pkg/datafetcher/schema/atmos/manifest/1.0.json @@ -2690,6 +2690,10 @@ "type": "string", "description": "Terraform/OpenTofu/Helmfile component" }, + "working_directory": { + "type": "string", + "description": "Explicit source working directory. Relative paths are resolved from the Atmos base path when overriding an enabled workdir." + }, "description": { "type": "string", "description": "Human-readable component description" diff --git a/pkg/downloader/artifact.go b/pkg/downloader/artifact.go index 8a451ad93bd..b999d66bf89 100644 --- a/pkg/downloader/artifact.go +++ b/pkg/downloader/artifact.go @@ -62,7 +62,7 @@ func ResolveArtifact(ctx context.Context, config *schema.AtmosConfiguration, dec artifact.Kind = "local" } if stagedPath != "" { - if commit, err := gitCommit(stagedPath); err == nil { + if commit, err := gitCommit(stagedPath); artifact.Kind != "local" && err == nil { artifact.Kind = "git" artifact.Identity = commit return artifact, nil @@ -215,6 +215,12 @@ func redactFallback(source string) string { } func gitCommit(directory string) (string, error) { + // A materialized subdirectory may live inside the consuming repository. Only a + // staging root with its own Git metadata can attest to the downloaded commit. + if _, err := os.Lstat(filepath.Join(directory, ".git")); err != nil { + return "", err + } + output, err := osExec.Command("git", "-C", directory, "rev-parse", "HEAD").Output() // #nosec G204 -- fixed command and caller-owned staging directory. if err != nil { return "", err diff --git a/pkg/downloader/artifact_test.go b/pkg/downloader/artifact_test.go index 59b10d32a69..bc794f05fa6 100644 --- a/pkg/downloader/artifact_test.go +++ b/pkg/downloader/artifact_test.go @@ -273,3 +273,43 @@ func runGitOutput(t *testing.T, dir string, args ...string) string { require.NoError(t, err, "git %v failed: %s", args, string(output)) return string(output) } + +func TestResolveArtifactDoesNotBorrowEnclosingRepository(t *testing.T) { + repo, commit := initGitRepoWithCommit(t) + staged := filepath.Join(repo, "vendor", "module") + require.NoError(t, os.MkdirAll(staged, 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(staged, "main.tf"), []byte("terraform {}"), 0o644)) + for _, declared := range []string{staged, "https://example.com/source.tar.gz"} { + artifact, err := ResolveArtifact(t.Context(), nil, declared, staged) + require.NoError(t, err) + assert.NotEqual(t, commit, artifact.Identity) + assert.Regexp(t, `^sha256:[a-f0-9]{64}$`, artifact.Identity) + } +} + +func TestResolveArtifactUnusableGitMetadataUsesContentIdentity(t *testing.T) { + tests.RequireExecutable(t, "git", "artifact provenance checks Git metadata") + for _, metadata := range []string{"unborn", "invalid"} { + t.Run(metadata, func(t *testing.T) { + stage := t.TempDir() + if metadata == "unborn" { + output, err := exec.Command("git", "init", "--quiet", stage).CombinedOutput() + require.NoError(t, err, "%s", output) + } else { + require.NoError(t, os.Mkdir(filepath.Join(stage, ".git"), 0o755)) + } + file := filepath.Join(stage, "main.tf") + require.NoError(t, os.WriteFile(file, []byte("# staged source"), 0o600)) + want, err := TreeSHA256(stage) + require.NoError(t, err) + artifact, err := ResolveArtifact(t.Context(), nil, "https://example.invalid/module.git", stage) + require.NoError(t, err) + require.Equal(t, "archive", artifact.Kind, "unverifiable Git metadata must not attest to a commit") + require.Equal(t, want, artifact.Identity) + require.NoError(t, os.WriteFile(file, []byte("# changed source"), 0o600)) + changed, err := ResolveArtifact(t.Context(), nil, "https://example.invalid/module.git", stage) + require.NoError(t, err) + require.NotEqual(t, artifact.Identity, changed.Identity, "fallback identity must reflect actual staged bytes") + }) + } +} diff --git a/pkg/edition/journal.yaml b/pkg/edition/journal.yaml index 2231040ee32..2d9da39e750 100644 --- a/pkg/edition/journal.yaml +++ b/pkg/edition/journal.yaml @@ -2,6 +2,13 @@ # Append changes here; keep old/new in the configuration field's type. # Quote dates and string values such as "true" and "false". # The CLI embeds this file; the website generates its index from the same file. +- date: "2026-10-28" + key: components.source.working_directory_precedence + kind: behavior + old: source workdir provisioning ignores working_directory when workdir is enabled + new: explicit source working_directory takes precedence over the generated workdir path, with migration required for an existing old workdir + description: Source provisioning, shell execution, and reference lookups use the same explicit directory; earlier editions retain the generated workdir path. + ref: https://github.com/cloudposse/atmos/pull/3545 - date: "2026-10-26" key: templates.settings.sprig.enabled kind: value diff --git a/pkg/plugin/oci/bundleguard_test.go b/pkg/plugin/oci/bundleguard_test.go index 75dc0399ea8..b91f31d9894 100644 --- a/pkg/plugin/oci/bundleguard_test.go +++ b/pkg/plugin/oci/bundleguard_test.go @@ -18,7 +18,7 @@ import ( ) func TestCheckBundlePath(t *testing.T) { - allowed := []string{"bin/plugin", "bin/plugin.exe", "plugin.yaml", "schemas/provider.json", "schemas/nested/dir/broker.json"} + allowed := []string{"bin/plugin", "bin/plugin.exe", "bin/plugin..exe", "plugin.yaml", "schemas/provider.json", "schemas/nested/dir/broker.json"} for _, path := range allowed { t.Run("allowed/"+path, func(t *testing.T) { require.NoError(t, CheckBundlePath(path)) @@ -92,6 +92,11 @@ func TestScanBundleRejectsEveryUnsafeEntryClass(t *testing.T) { require.NoError(t, err) require.Equal(t, []BundleFile{{Path: "plugin.yaml", Size: 1, Mode: "0644"}, {Path: "bin/plugin", Size: 1, Mode: "0755"}}, files) }) + t.Run("double dots within a filename are local", func(t *testing.T) { + files, err := scanBundle(bytes.NewReader(tarOf(t, regular("bin/plugin..exe"))), &bundleRules{}) + require.NoError(t, err) + require.Equal(t, []BundleFile{{Path: "bin/plugin..exe", Size: 1, Mode: "0644"}}, files) + }) } func TestScanBundleHostLocalPaths(t *testing.T) { diff --git a/pkg/provisioner/registry.go b/pkg/provisioner/registry.go index 54c4ed598f4..294df4d4dca 100644 --- a/pkg/provisioner/registry.go +++ b/pkg/provisioner/registry.go @@ -23,6 +23,8 @@ type HookEvent string // whose provisioners use in-process SDKs). It lives here, with the runner closure built in // the exec layer, so pkg/provisioner does not need to import internal/exec (a cycle). type TerraformExecContext struct { + // DryRun suppresses all provisioners, including those that use SDKs instead of Run. + DryRun bool // Run executes a terraform/tofu subcommand (args after the binary, e.g. // {"providers","lock","-platform=linux_amd64"}) with the live env, RC, and workdir. Run func(args []string) error @@ -149,6 +151,9 @@ func ExecuteProvisioners( if len(execCtx) > 0 { ec = execCtx[0] } + if ec != nil && ec.DryRun { + return nil + } provisioners := GetProvisionersForEvent(event) if len(provisioners) == 0 { diff --git a/pkg/provisioner/registry_test.go b/pkg/provisioner/registry_test.go index d917a31b6db..ec2a7ce7111 100644 --- a/pkg/provisioner/registry_test.go +++ b/pkg/provisioner/registry_test.go @@ -20,6 +20,27 @@ func resetRegistry() { provisionersByEvent = make(map[HookEvent][]Provisioner) } +func TestExecuteProvisionersDryRunSkipsSDKMutations(t *testing.T) { + const event HookEvent = "test.dry-run.backend" + writes := 0 + require.NoError(t, RegisterProvisioner(Provisioner{ + Type: "backend", HookEvent: event, + Func: func(context.Context, *schema.AtmosConfiguration, map[string]any, *schema.AuthContext, OutputWriters, *TerraformExecContext) error { + writes++ + return nil + }, + })) + t.Cleanup(func() { + registryMu.Lock() + defer registryMu.Unlock() + delete(provisionersByEvent, event) + }) + require.NoError(t, ExecuteProvisioners(context.Background(), event, &schema.AtmosConfiguration{}, nil, nil, OutputWriters{}, &TerraformExecContext{DryRun: true})) + assert.Zero(t, writes) + require.NoError(t, ExecuteProvisioners(context.Background(), event, &schema.AtmosConfiguration{}, nil, nil, OutputWriters{})) + assert.Equal(t, 1, writes) +} + func TestRegisterProvisioner(t *testing.T) { // Reset registry before test. resetRegistry() diff --git a/pkg/provisioner/source/artifact_receipt.go b/pkg/provisioner/source/artifact_receipt.go new file mode 100644 index 00000000000..bd12c945ed6 --- /dev/null +++ b/pkg/provisioner/source/artifact_receipt.go @@ -0,0 +1,41 @@ +package source + +import ( + "context" + + "github.com/cloudposse/atmos/pkg/downloader" + "github.com/cloudposse/atmos/pkg/perf" + "github.com/cloudposse/atmos/pkg/schema" +) + +// WithRuntimePreservation keeps Terraform runtime artifacts while refreshing source-owned files. +// Callers supply the component configuration so custom backend paths take precedence over source ownership. +func WithRuntimePreservation(componentConfig map[string]any) VendorSourceOption { + defer perf.Track(nil, "source.WithRuntimePreservation")() + return func(opts *vendorSourceOptions) { opts.preserveRuntime = true; opts.componentConfig = componentConfig } +} + +// WithArtifactReceipt receives provenance captured from the fetched source before runtime files are merged. +func WithArtifactReceipt(receipt *downloader.ResolvedArtifact) VendorSourceOption { + defer perf.Track(nil, "source.WithArtifactReceipt")() + return func(opts *vendorSourceOptions) { opts.artifact = receipt } +} + +// captureArtifact uses downloader-owned fetch metadata; the destination is never treated as a Git checkout. +func (opts vendorSourceOptions) captureArtifact(ctx context.Context, config *schema.AtmosConfiguration, uri, staged string, metadata downloader.FetchMetadata) error { + receipt := opts.artifact + if receipt == nil { + return nil + } + if metadata.GitCommit != "" { + *receipt = downloader.ResolvedArtifact{Declared: downloader.RedactSource(uri), Resolved: downloader.RedactSource(uri), Kind: "git", Identity: metadata.GitCommit} + return nil + } + artifact, err := downloader.ResolveArtifact(ctx, config, uri, staged) + if err != nil { + return err + } + artifact.ETag, artifact.Modified = metadata.ETag, metadata.LastModified + *receipt = artifact + return nil +} diff --git a/pkg/provisioner/source/cmd/helpers.go b/pkg/provisioner/source/cmd/helpers.go index 801d1c18b42..27efd26a19a 100644 --- a/pkg/provisioner/source/cmd/helpers.go +++ b/pkg/provisioner/source/cmd/helpers.go @@ -64,10 +64,11 @@ func ParseCommonFlags(cmd *cobra.Command, parser *flags.StandardParser) (*Common return nil, err } + globalFlags := flags.ParseGlobalFlags(cmd, v) opts := &CommonOptions{ - Flags: flags.ParseGlobalFlags(cmd, v), + Flags: globalFlags, Stack: v.GetString("stack"), - Identity: v.GetString("identity"), + Identity: globalFlags.Identity.Value(), Force: v.GetBool("force"), } @@ -126,7 +127,7 @@ func initConfigAndAuth(componentType, component, stack, identity string, globalF } // Create AuthManager with merged config (auto-selects component's default identity if present). - authManager, err := createAuthFunc(identity, mergedAuthConfig, cfg.IdentityFlagSelectValue) + authManager, err := createAuthFunc(cfg.NormalizeIdentityValue(identity), mergedAuthConfig, cfg.IdentityFlagSelectValue) if err != nil { return nil, nil, fmt.Errorf("failed to create auth manager: %w", err) } diff --git a/pkg/provisioner/source/cmd/helpers_test.go b/pkg/provisioner/source/cmd/helpers_test.go index ba802fc34b4..086d2c0fb9a 100644 --- a/pkg/provisioner/source/cmd/helpers_test.go +++ b/pkg/provisioner/source/cmd/helpers_test.go @@ -13,11 +13,29 @@ import ( "go.uber.org/mock/gomock" errUtils "github.com/cloudposse/atmos/errors" + cfg "github.com/cloudposse/atmos/pkg/config" "github.com/cloudposse/atmos/pkg/flags" "github.com/cloudposse/atmos/pkg/flags/global" "github.com/cloudposse/atmos/pkg/schema" ) +func TestParseCommonFlags_DisabledIdentity(t *testing.T) { + for _, value := range []string{"false", "FALSE", "0", "no", "off", cfg.IdentityFlagDisabledValue} { + t.Run(value, func(t *testing.T) { + cmd := &cobra.Command{Use: "test"} + parser := flags.NewStandardParser( + flags.WithStringFlag("stack", "s", "", "Stack name"), + flags.WithStringFlag("identity", "", "", "Identity"), + ) + parser.RegisterFlags(cmd) + require.NoError(t, cmd.ParseFlags([]string{"--stack=dev", "--identity=" + value})) + opts, err := ParseCommonFlags(cmd, parser) + require.NoError(t, err) + assert.Equal(t, cfg.IdentityFlagDisabledValue, opts.Identity) + }) + } +} + // TestParseCommonFlags_MissingStack tests that ParseCommonFlags returns an error when --stack is not provided. func TestParseCommonFlags_MissingStack(t *testing.T) { cmd := &cobra.Command{Use: "test"} diff --git a/pkg/provisioner/source/invocation.go b/pkg/provisioner/source/invocation.go new file mode 100644 index 00000000000..f1e4fed9ca6 --- /dev/null +++ b/pkg/provisioner/source/invocation.go @@ -0,0 +1,81 @@ +package source + +import ( + "context" + "encoding/json" + "path/filepath" + "sync" + "sync/atomic" + + "github.com/cloudposse/atmos/pkg/auth/fingerprint" + "github.com/cloudposse/atmos/pkg/perf" + "github.com/cloudposse/atmos/pkg/schema" +) + +type invocationProvisioning struct { + entries sync.Map +} +type invocationEntry struct { + // The slot is a one-element semaphore rather than a mutex so a waiter can stop on cancellation. + slot chan struct{} + done bool + key string +} + +var currentInvocation atomic.Pointer[invocationProvisioning] + +// BeginInvocation scopes successful source reuse to one top-level CLI invocation. +// Direct library calls have no process-lifetime cache. The restore function supports +// nested CLI invocations and must be deferred by the owner. +func BeginInvocation() func() { + defer perf.Track(nil, "source.BeginInvocation")() + previous := currentInvocation.Swap(&invocationProvisioning{}) + return func() { currentInvocation.Store(previous) } +} + +func provisioningKey(target *Target, componentType string, config map[string]any, spec *schema.VendorComponentSource, auth *schema.AuthContext) string { + absolute, _ := filepath.Abs(target.Dir) + // Key credentials with a process-local secret rather than retaining plain digests. Different + // auth scopes, source selectors, filters and component instances never share a record. + encoded, _ := json.Marshal([]any{absolute, componentType, config["atmos_stack"], config["atmos_component"], spec, auth, config["auth"]}) + return fingerprint.Key(encoded) +} + +// beginProvision serializes duplicate callers within an explicitly established invocation. +// A failed attempt is never cached. Independent library calls still use publication locking. +func beginProvision(ctx context.Context, key, target string) (bool, func(bool), error) { + invocation := currentInvocation.Load() + if invocation == nil { + return false, func(bool) {}, nil + } + value, _ := invocation.entries.LoadOrStore(target, &invocationEntry{slot: make(chan struct{}, 1)}) + entry := value.(*invocationEntry) + select { + case entry.slot <- struct{}{}: + case <-ctx.Done(): + return false, nil, ctx.Err() + } + release := func() { <-entry.slot } + // The slot and cancellation can become ready together; a cancelled caller never reports reuse. + if err := ctx.Err(); err != nil { + release() + return false, nil, err + } + if entry.done && entry.key == key && isNonEmptyDir(target) { + release() + return true, func(bool) {}, nil + } + return false, func(success bool) { + entry.done = success + if success { + entry.key = key + } + release() + }, nil +} + +// provisionedMarker is valid only in the invocation that created it. +type provisionedMarker struct { + key string + invocation *invocationProvisioning +} diff --git a/pkg/provisioner/source/invocation_test.go b/pkg/provisioner/source/invocation_test.go new file mode 100644 index 00000000000..a667ea644fb --- /dev/null +++ b/pkg/provisioner/source/invocation_test.go @@ -0,0 +1,45 @@ +package source + +import ( + "context" + "os" + "path/filepath" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +// TestBeginProvisionPeerWaitHonorsCancellation verifies that a caller waiting for an in-process peer +// stops when its context is cancelled, and that a cancelled caller never reports a reused result. +func TestBeginProvisionPeerWaitHonorsCancellation(t *testing.T) { + t.Cleanup(BeginInvocation()) + target := filepath.Join(t.TempDir(), "target") + require.NoError(t, os.MkdirAll(target, 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(target, "main.tf"), []byte("# source"), 0o600)) + + reused, finishPeer, err := beginProvision(t.Context(), "key", target) + require.NoError(t, err) + require.False(t, reused) + + ctx, cancel := context.WithTimeout(t.Context(), 20*time.Millisecond) + defer cancel() + reused, finish, err := beginProvision(ctx, "key", target) + require.ErrorIs(t, err, context.DeadlineExceeded) + require.False(t, reused) + require.Nil(t, finish) + + finishPeer(true) + + // Once the peer finished successfully, a live caller reuses its result... + reused, _, err = beginProvision(t.Context(), "key", target) + require.NoError(t, err) + require.True(t, reused) + + // ...but an already-cancelled caller gets the cancellation, not success. + cancelled, cancelNow := context.WithCancel(t.Context()) + cancelNow() + reused, _, err = beginProvision(cancelled, "key", target) + require.ErrorIs(t, err, context.Canceled) + require.False(t, reused) +} diff --git a/pkg/provisioner/source/provenance.go b/pkg/provisioner/source/provenance.go index 72137f737d2..1088d12ead3 100644 --- a/pkg/provisioner/source/provenance.go +++ b/pkg/provisioner/source/provenance.go @@ -35,7 +35,9 @@ type Provenance struct { // Source is the credential-free form of the source URI. Source string `json:"source"` // Version is the source version, when one was declared separately. - Version string `json:"version,omitempty"` + Version string `json:"version,omitempty"` + SourceIdentity string `json:"source_identity,omitempty"` + SourceKind string `json:"source_kind,omitempty"` // ProvisionedAt is the provisioning time. ProvisionedAt time.Time `json:"provisioned_at"` } @@ -104,15 +106,64 @@ func HasProvenance(dir string) bool { // recordProvenance marks a freshly provisioned target. Workdir targets get the full workdir // metadata (which also drives re-provisioning decisions); shared directories get the minimal marker. -func recordProvenance(target *Target, stack string, spec *schema.VendorComponentSource) error { +func recordProvenance(target *Target, stack string, spec *schema.VendorComponentSource, receipts ...*downloader.ResolvedArtifact) error { if target.IsWorkdir { - return writeWorkdirMetadata(target.Dir, target.Component, stack, spec) + instance := target.Instance + if instance == "" { + instance = target.Component + } + return writeWorkdirMetadata(target.Dir, instance, stack, spec, receipts...) } - return WriteProvenance(target.Dir, &Provenance{ + p := &Provenance{ Component: target.Component, Stack: stack, Source: downloader.RedactSource(spec.Uri), Version: spec.Version, ProvisionedAt: time.Now().UTC(), - }) + } + if len(receipts) > 0 && receipts[0] != nil { + p.SourceIdentity, p.SourceKind = receipts[0].Identity, receipts[0].Kind + } + return WriteProvenance(target.Dir, p) +} + +// withProvenance prepares receipts in staging so source files and provenance share +// the same rollback journal. Existing creation time is carried forward explicitly. +func withProvenance(target *Target, stack string, spec *schema.VendorComponentSource, receipt *downloader.ResolvedArtifact) VendorSourceOption { + return func(opts *vendorSourceOptions) { + opts.metadata = func(stage string) error { + if err := validateTargetOwner(target, stack); err != nil { + return err + } + if target.IsWorkdir { + if previous, err := workdir.ReadMetadata(target.Dir); err == nil && previous != nil { + if err := workdir.WriteMetadata(stage, previous); err != nil { + return err + } + } + } + stagedTarget := *target + stagedTarget.Dir = stage + return recordProvenance(&stagedTarget, stack, spec, receipt) + } + } +} + +// validateTargetOwner also runs under the publication lock before a new receipt is +// staged, so two instances cannot race to claim one explicit working directory. +func validateTargetOwner(target *Target, stack string) error { + if !target.EnforceOwner { + return nil + } + metadata, err := workdir.ReadMetadata(target.Dir) + if err != nil || metadata == nil { + if !isNonEmptyDir(target.Dir) { + return nil + } + return errUtils.Build(errUtils.ErrWorkdirProvision).WithExplanation("Explicit source working directory has files but no verifiable instance owner").WithContext("path", target.Dir).Err() + } + if metadata.Component != target.Instance || metadata.Stack != stack { + return errUtils.Build(errUtils.ErrWorkdirProvision).WithExplanation("Explicit source working directory belongs to another component instance").WithContext("path", target.Dir).WithContext("owner_component", metadata.Component).WithContext("owner_stack", metadata.Stack).Err() + } + return nil } diff --git a/pkg/provisioner/source/provision_hook.go b/pkg/provisioner/source/provision_hook.go index ce0cc362118..8cc7ca04273 100644 --- a/pkg/provisioner/source/provision_hook.go +++ b/pkg/provisioner/source/provision_hook.go @@ -58,6 +58,11 @@ func autoProvisionSourceTerraform( return AutoProvisionSource(ctx, atmosConfig, cfg.TerraformComponentType, componentConfig, authContext, writers) } +// afterTargetOwnerCheck runs right after the initial ownership check in AutoProvisionSource. It is a +// seam that lets tests interleave a competing provisioner into the window between that check and the +// publication lock, deterministically. +var afterTargetOwnerCheck = func(string) {} + // AutoProvisionSource automatically vendors component source on first use. // This enables JIT (Just-in-Time) vendoring - sources are fetched automatically // when running terraform/helmfile/packer commands if the target directory doesn't exist. @@ -80,6 +85,9 @@ func AutoProvisionSource( ) (retErr error) { defer perf.Track(atmosConfig, "source.AutoProvisionSource")() out := ui.New(writers.Stderr) + if err := ctx.Err(); err != nil { + return err + } sourceSpec, component, err := extractSourceAndComponent(componentConfig) if err != nil { @@ -89,24 +97,6 @@ func AutoProvisionSource( return nil // No source configured - skip. } - // Guard against double-invocation within the same command lifecycle. - // AutoProvisionSource is called both directly (from resolveAndProvisionComponentPath) - // and indirectly via the before.terraform.init hook (from prepareInitExecution). - // Without this check a zero TTL would delete varfiles and backend configs that were - // written to the workdir between the two calls, causing the subprocess to fail with - // "file does not exist" errors. Once this function completes (provision or skip), - // no further provisioning should happen for this invocation. - if _, done := componentConfig[invocationDoneKey]; done { - return nil - } - // Mark as complete when this call returns successfully so any subsequent call - // (e.g., the before.terraform.init hook) is a no-op for this invocation. - defer func() { - if retErr == nil { - componentConfig[invocationDoneKey] = struct{}{} - } - }() - // Apply global TTL default if not set per-component. applyGlobalTTLDefault(sourceSpec, atmosConfig, componentType) @@ -117,18 +107,58 @@ func AutoProvisionSource( if err != nil { return wrapProvisionError(err, "Failed to determine target directory", component) } + if err := validateTargetOwner(target, stack); err != nil { + return err + } + afterTargetOwnerCheck(target.Dir) targetDir, isWorkdir := target.Dir, target.IsWorkdir + key := provisioningKey(target, componentType, componentConfig, sourceSpec, authContext) + marker := provisionedMarker{key: key, invocation: currentInvocation.Load()} + if done, ok := componentConfig[invocationDoneKey].(provisionedMarker); ok && marker.invocation == nil && done == marker && isNonEmptyDir(targetDir) && markerTargetMatches(target, stack, sourceSpec) { + if isWorkdir { + setProvisionedWorkdir(componentConfig, targetDir) + } + return nil + } + reused, finish, err := beginProvision(ctx, key, targetDir) + if err != nil { + return err + } + if reused { + // beginProvision may have waited for an in-process peer; another process can claim an + // explicit target in that window, so confirm ownership before reusing the directory. + if err := validateTargetOwner(target, stack); err != nil { + return err + } + if isWorkdir { + setProvisionedWorkdir(componentConfig, targetDir) + } + componentConfig[invocationDoneKey] = marker + return nil + } + defer func() { + finish(retErr == nil) + if retErr == nil { + componentConfig[invocationDoneKey] = marker + } + }() + // Check if provisioning is needed (version change, URI change, or fresh workdir). needs, reason := needsProvisioning(targetDir, sourceSpec, isWorkdir) if !needs { + // Another instance may have claimed an explicit target after the first owner check, so + // confirm ownership again before reporting the target as ready. + if err := validateTargetOwner(target, stack); err != nil { + return err + } // No provisioning needed - touch LastAccessed and return. if isWorkdir { if err := workdir.UpdateLastAccessed(targetDir); err != nil { // Non-critical error - log and continue. out.Warningf("Failed to update workdir last accessed time: %s", err) } - componentConfig[workdir.WorkdirPathKey] = targetDir + setProvisionedWorkdir(componentConfig, targetDir) } return nil } @@ -146,28 +176,59 @@ func AutoProvisionSource( ctx = downloader.WithAWSAuthContext(ctx, authContext.AWS) } + hadSource := isNonEmptyDir(targetDir) // Vendor the source to target directory. - if err := vendorToTarget(ctx, atmosConfig, sourceSpec, vendorTarget{path: targetDir, component: component, writers: writers}); err != nil { + var receipt downloader.ResolvedArtifact + options := []VendorSourceOption{WithArtifactReceipt(&receipt)} + if componentType == cfg.TerraformComponentType { + options = append(options, WithRuntimePreservation(componentConfig), withProvenance(target, stack, sourceSpec, &receipt)) + } + if err := vendorToTarget(ctx, atmosConfig, sourceSpec, &vendorTarget{path: targetDir, component: component, writers: writers, options: options, preserveRuntime: componentType == cfg.TerraformComponentType}); err != nil { return err } // Record provenance: workdir metadata for workdir targets, the `.atmos/source.json` marker for // shared component directories. Non-critical: a failure only limits `source delete`. - if err := recordProvenance(target, stack, sourceSpec); err != nil { - out.Warningf("Failed to record source provenance: %s", err) + if componentType != cfg.TerraformComponentType { + if err := recordProvenance(target, stack, sourceSpec, &receipt); err != nil { + out.Warningf("Failed to record source provenance: %s", err) + } } if isWorkdir { - componentConfig[workdir.WorkdirPathKey] = targetDir - // Signal that the workdir was wiped and re-provisioned this invocation. - // buildInitArgs checks this to decide whether -reconfigure is needed: - // a re-provisioned workdir has no .terraform/ cache so -reconfigure is safe; - // a preserved workdir (TTL not expired) has a valid cache and -reconfigure - // causes a spurious "migrate all workspaces?" prompt from tofu. - componentConfig[workdir.WorkdirReprovisionedKey] = struct{}{} + setProvisionedWorkdir(componentConfig, targetDir) + // Only first materialization has no backend cache. Refresh preserves .terraform; + // normal init fingerprinting decides whether its actual inputs changed. + if !hadSource { + componentConfig[workdir.WorkdirReprovisionedKey] = struct{}{} + } } return nil } +// markerTargetMatches reports whether a workdir target still holds what this selector provisioned. +// Another selector may have re-vendored a shared target since the marker was recorded; its metadata +// then names a different instance, stack, or source, and the marker must not be reused. The TTL is +// deliberately ignored so a zero-TTL source is not downloaded twice within one command. Shared +// component directories carry no per-selector workdir metadata and keep the marker as recorded. +func markerTargetMatches(target *Target, stack string, sourceSpec *schema.VendorComponentSource) bool { + if !target.IsWorkdir { + return true + } + metadata, err := workdir.ReadMetadata(target.Dir) + if err != nil || metadata == nil { + return false + } + instance := target.Instance + if instance == "" { + instance = target.Component + } + if metadata.Component != instance || metadata.Stack != stack { + return false + } + changed, _ := checkMetadataChanges(metadata, sourceSpec) + return !changed +} + // applyGlobalTTLDefault sets the source TTL from the global config if not already set per-component. func applyGlobalTTLDefault(sourceSpec *schema.VendorComponentSource, atmosConfig *schema.AtmosConfiguration, componentType string) { if sourceSpec.TTL != "" { @@ -217,36 +278,28 @@ func extractSourceAndComponent(componentConfig map[string]any) (*schema.VendorCo // vendorTarget identifies the provisioning destination and progress output streams. type vendorTarget struct { - path string - component string - writers provisioner.OutputWriters + path string + component string + writers provisioner.OutputWriters + options []VendorSourceOption + preserveRuntime bool } // vendorToTarget provisions with progress reporting and removes a newly created target when downloading fails. -func vendorToTarget(ctx context.Context, atmosConfig *schema.AtmosConfiguration, sourceSpec *schema.VendorComponentSource, target vendorTarget) error { +func vendorToTarget(ctx context.Context, atmosConfig *schema.AtmosConfiguration, sourceSpec *schema.VendorComponentSource, target *vendorTarget) error { progressMsg := fmt.Sprintf("Auto-provisioning source for %q", target.component) completedMsg := fmt.Sprintf("Auto-provisioned source to %s", target.path) out := ui.New(target.writers.Stderr) operation := func() error { - // Track whether this attempt creates the target directory so a failed - // provisioning can remove it again. A leftover directory is worse than - // none: an empty one misleads path resolution (the component "exists" - // but has no code), and a partially populated one is treated as fully - // provisioned by needsProvisioning on the next run, silently skipping - // re-provisioning. - _, statErr := os.Stat(target.path) - createdTarget := os.IsNotExist(statErr) - - if err := os.MkdirAll(target.path, DirPermissions); err != nil { - return errUtils.Build(errUtils.ErrSourceProvision). - WithCause(err). - WithExplanation("Failed to create target directory"). - WithContext("path", target.path). - Err() + // Transactional Terraform refresh owns creation/publication under its target lock. + // An outer "created target" cleanup can otherwise delete a concurrent winner. + createdTarget, err := prepareAutoVendorTarget(target.path, target.preserveRuntime) + if err != nil { + return err } - if err := VendorSource(ctx, atmosConfig, sourceSpec, target.path); err != nil { + if err := VendorSource(ctx, atmosConfig, sourceSpec, target.path, target.options...); err != nil { if createdTarget { if rmErr := os.RemoveAll(target.path); rmErr != nil { out.Warningf("Failed to clean up target directory after failed provisioning: %s", rmErr) @@ -310,7 +363,8 @@ func determineSourceTargetDirectory( if err != nil { return "", false, err } - return workdirPath, true, nil + workdirPath, err = sourceWorkdirOverride(atmosConfig, componentConfig, workdirPath) + return workdirPath, true, err } // No workdir - use standard component path. @@ -522,7 +576,7 @@ func isLocalSource(uri string) bool { } // writeWorkdirMetadata writes workdir metadata based on source type (local or remote). -func writeWorkdirMetadata(workdirPath, component, stack string, sourceSpec *schema.VendorComponentSource) error { +func writeWorkdirMetadata(workdirPath, component, stack string, sourceSpec *schema.VendorComponentSource, receipts ...*downloader.ResolvedArtifact) error { now := time.Now() // Read existing metadata to preserve CreatedAt if it exists. @@ -546,14 +600,15 @@ func writeWorkdirMetadata(workdirPath, component, stack string, sourceSpec *sche LastAccessed: now, ContentHash: "", // Content hash is computed separately for local sources. } - // The common artifact resolver records a local, credential-free receipt for - // JIT workdirs. Failure is deliberately non-fatal: the provisioning result - // remains usable, while SBOM coverage can report the missing evidence. - if artifact, err := downloader.ResolveArtifact(context.Background(), nil, sourceSpec.Uri, workdirPath); err == nil { - metadata.SourceURI = artifact.Declared - metadata.SourceResolved = artifact.Resolved - metadata.SourceIdentity = artifact.Identity + // Use the fetch receipt captured before Git metadata is stripped. Compatibility + // callers without one get an honest content digest, never the enclosing repo HEAD. + artifact := downloader.ResolvedArtifact{Declared: downloader.RedactSource(sourceSpec.Uri), Resolved: downloader.RedactSource(sourceSpec.Uri)} + if len(receipts) > 0 && receipts[0] != nil { + artifact = *receipts[0] + } else if digest, err := downloader.TreeSHA256(workdirPath); err == nil { + artifact.Identity = digest } + metadata.SourceURI, metadata.SourceResolved, metadata.SourceIdentity = artifact.Declared, artifact.Resolved, artifact.Identity // Preserve original CreatedAt and ContentHash if metadata already existed. if existingMetadata != nil { @@ -591,3 +646,25 @@ func extractComponentName(componentConfig map[string]any) string { return "" } + +// setProvisionedWorkdir does not undo the runtime's already-resolved module subdirectory +// when a later hook reuses the same source provisioning result. +func setProvisionedWorkdir(config map[string]any, target string) { + if existing, ok := config[workdir.WorkdirPathKey].(string); ok && existing != "" && isWithinBase(existing, target) { + if info, err := os.Stat(existing); err == nil && info.IsDir() { + return + } + } + config[workdir.WorkdirPathKey] = target +} + +func prepareAutoVendorTarget(path string, preserveRuntime bool) (bool, error) { + if preserveRuntime { + return false, nil + } + _, statErr := os.Stat(path) + if err := os.MkdirAll(path, DirPermissions); err != nil { + return false, errUtils.Build(errUtils.ErrSourceProvision).WithCause(err).WithExplanation("Failed to create target directory").WithContext("path", path).Err() + } + return os.IsNotExist(statErr), nil +} diff --git a/pkg/provisioner/source/provision_hook_test.go b/pkg/provisioner/source/provision_hook_test.go index 011712ba737..81ba59e68d1 100644 --- a/pkg/provisioner/source/provision_hook_test.go +++ b/pkg/provisioner/source/provision_hook_test.go @@ -1478,42 +1478,47 @@ func TestWriteWorkdirMetadata_PreservesContentHash(t *testing.T) { // before.terraform.init hook), wiping out varfiles and backend configs written between // the two calls and causing the subprocess to fail with "file does not exist" errors. func TestAutoProvisionSource_InvocationGuard_PreventsDoubleProvisioning(t *testing.T) { - // The guard is checked before any provisioning when invocationDoneKey is set. - // A component config with a valid source but the done-key present should return nil - // immediately without touching the filesystem. - componentConfig := map[string]any{ - "component": "null-label", - "atmos_stack": "demo", - "source": map[string]any{ - "uri": "github.com/cloudposse/terraform-null-label.git//", - "version": "0.25.0", - "ttl": "0s", - }, - "provision": map[string]any{ - "workdir": map[string]any{ - "enabled": true, - }, - }, - // Simulate that this invocation already ran AutoProvisionSource once. - invocationDoneKey: struct{}{}, - } + sourceDir := t.TempDir() + require.NoError(t, os.WriteFile(filepath.Join(sourceDir, "main.tf"), []byte("# v1"), 0o644)) + component := map[string]any{"component": "example", "atmos_stack": "dev", "source": map[string]any{"uri": sourceDir, "ttl": "0s"}, "provision": map[string]any{"workdir": map[string]any{"enabled": true}}} + config := &schema.AtmosConfiguration{BasePath: t.TempDir()} + require.NoError(t, AutoProvisionSource(t.Context(), config, "terraform", component, nil, provisioner.OutputWriters{})) + target, err := ResolveTarget(config, "terraform", "example", component) + require.NoError(t, err) + require.NoError(t, os.WriteFile(filepath.Join(sourceDir, "main.tf"), []byte("# v2"), 0o644)) + require.NoError(t, AutoProvisionSource(t.Context(), config, "terraform", component, nil, provisioner.OutputWriters{})) + contents, err := os.ReadFile(filepath.Join(target.Dir, "main.tf")) + require.NoError(t, err) + assert.Equal(t, "# v1", string(contents)) +} - // Use a real atmosConfig with base path pointing to a temp dir. - // The function should return nil without ever trying to resolve a target dir - // or call VendorSource (which would require network access). - tmpDir := t.TempDir() - atmosConfig := &schema.AtmosConfiguration{ - BasePath: tmpDir, - Components: schema.Components{ - Terraform: schema.Terraform{ - BasePath: "components/terraform", - }, - }, - } +// TestAutoProvisionSource_InvocationGuard_RechecksTargetOwner verifies the marker is reused only while +// the workdir still holds this selector's provisioning. When another selector has since re-vendored the +// target, the marker no longer applies and the source is provisioned again. +func TestAutoProvisionSource_InvocationGuard_RechecksTargetOwner(t *testing.T) { + sourceDir := t.TempDir() + require.NoError(t, os.WriteFile(filepath.Join(sourceDir, "main.tf"), []byte("# v1"), 0o644)) + component := map[string]any{"component": "example", "atmos_stack": "dev", "source": map[string]any{"uri": sourceDir, "ttl": "0s"}, "provision": map[string]any{"workdir": map[string]any{"enabled": true}}} + config := &schema.AtmosConfiguration{BasePath: t.TempDir()} + require.NoError(t, AutoProvisionSource(t.Context(), config, "terraform", component, nil, provisioner.OutputWriters{})) + target, err := ResolveTarget(config, "terraform", "example", component) + require.NoError(t, err) - ctx := t.Context() - err := AutoProvisionSource(ctx, atmosConfig, "terraform", componentConfig, nil, provisioner.OutputWriters{}) - require.NoError(t, err, "second AutoProvisionSource call with invocationDoneKey set should be a no-op") + // Another selector re-vendors the same target. + metadata, err := workdir.ReadMetadata(target.Dir) + require.NoError(t, err) + metadata.Stack = "prod" + require.NoError(t, workdir.WriteMetadata(target.Dir, metadata)) + require.False(t, markerTargetMatches(target, "dev", &schema.VendorComponentSource{Uri: sourceDir})) + + require.NoError(t, os.WriteFile(filepath.Join(sourceDir, "main.tf"), []byte("# v2"), 0o644)) + require.NoError(t, AutoProvisionSource(t.Context(), config, "terraform", component, nil, provisioner.OutputWriters{})) + contents, err := os.ReadFile(filepath.Join(target.Dir, "main.tf")) + require.NoError(t, err) + assert.Equal(t, "# v2", string(contents)) + metadata, err = workdir.ReadMetadata(target.Dir) + require.NoError(t, err) + assert.Equal(t, "dev", metadata.Stack) } // TestAutoProvisionSource_InvocationGuard_SetAfterProvisioning verifies that the diff --git a/pkg/provisioner/source/refresh.go b/pkg/provisioner/source/refresh.go new file mode 100644 index 00000000000..8f7ae458fa7 --- /dev/null +++ b/pkg/provisioner/source/refresh.go @@ -0,0 +1,525 @@ +package source + +import ( + "archive/zip" + "context" + "encoding/json" + "errors" + "fmt" + "io/fs" + "os" + "path/filepath" + "sort" + "strings" + "time" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/filelock" + log "github.com/cloudposse/atmos/pkg/logger" + "github.com/cloudposse/atmos/pkg/provisioner" + "github.com/cloudposse/atmos/pkg/provisioner/workdir" + "github.com/cloudposse/atmos/pkg/schema" + "github.com/cloudposse/atmos/pkg/ui" +) + +const sourceFilesManifest = ".atmos/source-files.json" + +// sourceRefreshLockWarnAfter is how long a refresh waits for another process's publication before +// it tells the user why it is blocked. The wait itself is bounded only by the caller's context. +var sourceRefreshLockWarnAfter = 2 * time.Second + +// warnSourceRefreshLockWait reports a refresh blocked by another publisher. It is a seam for tests. +var warnSourceRefreshLockWait = func(ctx context.Context, target string) { + if workdir.OutputSuppressed(ctx) { + log.Debug("Waiting for another Atmos process to finish refreshing the component source", "target", target) + return + } + ui.Warningf("Waiting for another Atmos process to finish refreshing the component source in %s", target) +} + +// sourceFiles records only downloaded files, never files created by Terraform or hooks. +// An absent manifest is a legacy checkout: unrecognized files remain caller-owned. +type sourceFiles struct { + Files []string `json:"files"` +} + +func vendorSourcePreserving(ctx context.Context, config *schema.AtmosConfiguration, spec *schema.VendorComponentSource, target string, opts vendorSourceOptions) error { + if err := validateVendorTargetDir(target); err != nil { + return err + } + if err := ctx.Err(); err != nil { + return err + } + if err := os.MkdirAll(filepath.Dir(target), TargetDirPermissions); err != nil { + return err + } + // The lock lives outside the mutable source and coordinates publishers for this exact checkout. + absolute, err := filepath.Abs(target) + if err != nil { + return err + } + canonical, err := resolveExistingSymlinks(absolute) + if err != nil { + return err + } + // Publication protects caller state and ownership, so it requires a real lock + // on every platform; the best-effort cache lock is intentionally a no-op on Windows. + // Concurrent publishers of one checkout run one after another: a waiter later finds the target + // up to date or republishes the same files. The wait is bounded by the caller's context. + lock := filelock.New(provisioner.LockCoordPath(canonical+".source-refresh") + ".lock") + warning := time.AfterFunc(sourceRefreshLockWarnAfter, func() { warnSourceRefreshLockWait(ctx, target) }) + defer warning.Stop() + err = lock.WithExclusive(ctx, func() error { + warning.Stop() + return stageSourceRefresh(ctx, config, spec, target, opts) + }) + if errors.Is(err, filelock.ErrAcquire) { + return errors.Join(errUtils.ErrCacheLocked, err) + } + return err +} + +func stageSourceRefresh(ctx context.Context, config *schema.AtmosConfiguration, spec *schema.VendorComponentSource, target string, opts vendorSourceOptions) error { + if info, err := os.Lstat(target); err == nil && info.Mode()&os.ModeSymlink != 0 { + return fmt.Errorf("%w: source target is a symlink: %s", errUtils.ErrSourceCopyFailed, target) + } + if !opts.replaceTarget { + if _, err := os.Stat(target); err == nil { + return fmt.Errorf("%w: target directory already exists", errUtils.ErrSourceCopyFailed) + } + } + stage, err := os.MkdirTemp(filepath.Dir(target), ".atmos-source-stage-") + if err != nil { + return fmt.Errorf("%w: create source stage: %w", errUtils.ErrSourceCopyFailed, err) + } + defer os.RemoveAll(stage) + stagedOpts := opts + stagedOpts.preserveRuntime, stagedOpts.replaceTarget = false, true + if err := vendorSource(ctx, config, spec, stage, stagedOpts); err != nil { + return err + } + if err := rejectGeneratedBackendCollision(config, stage, target, opts.componentConfig); err != nil { + return err + } + if opts.metadata != nil { + if err := opts.metadata(stage); err != nil { + return err + } + } + return publishSource(ctx, stage, target, opts.componentConfig, os.Rename) +} + +// generatedBackendFile is the backend configuration Atmos writes into the module root. +const generatedBackendFile = "backend.tf.json" + +// rejectGeneratedBackendCollision fails a refresh whose source ships the backend file Atmos generates. +// Installing it would replace the generated backend, and the next generation would overwrite the +// source's copy, so neither owner's version could be trusted. +func rejectGeneratedBackendCollision(config *schema.AtmosConfiguration, stage, target string, componentConfig map[string]any) error { + if config == nil || !config.Components.Terraform.AutoGenerateBackendFile { + return nil + } + for _, root := range moduleRoots(target, componentConfig) { + rel, err := filepath.Rel(target, root) + if err != nil { + continue + } + if _, err := os.Lstat(filepath.Join(stage, rel, generatedBackendFile)); err == nil { + return fmt.Errorf("%w: source ships %s, which Atmos generates because components.terraform.auto_generate_backend_file is enabled; exclude it with source.excluded_paths or disable backend generation", + errUtils.ErrSourceCopyFailed, filepath.ToSlash(filepath.Join(rel, generatedBackendFile))) + } + } + return nil +} + +type sourceRename func(string, string) error + +// publishSource updates source files in place. The component directory and runtime files +// never move. Every touched source file is journaled until publication succeeds. +func publishSource(ctx context.Context, stage, target string, config map[string]any, rename sourceRename) error { + next, err := sourceInventory(stage) + if err != nil { + return err + } + previous, err := readSourceInventory(target) + if err != nil { + return err + } + if err := rejectActiveStateLock(target); err != nil { + return err + } + changes, incoming, err := sourceChanges(stage, target, next, previous, runtimePaths(target, config)) + if err != nil { + return err + } + changes, err = prepareSourceReceipts(stage, target, next, changes, incoming) + if err != nil { + return err + } + if err := os.MkdirAll(target, TargetDirPermissions); err != nil { + return fmt.Errorf("%w: create source target: %w", errUtils.ErrSourceCopyFailed, err) + } + backup, err := os.MkdirTemp(filepath.Dir(target), ".atmos-source-rollback-") + if err != nil { + return fmt.Errorf("%w: create source rollback directory: %w", errUtils.ErrSourceCopyFailed, err) + } + publication := sourcePublication{stage: stage, target: target, backup: backup, rename: rename} + return publication.publish(ctx, changes, incoming) +} + +func readSourceInventory(target string) (sourceFiles, error) { + previous := sourceFiles{} + data, err := os.ReadFile(filepath.Join(target, sourceFilesManifest)) + if os.IsNotExist(err) { + return previous, nil + } + if err != nil { + return previous, fmt.Errorf("%w: read source ownership: %w", errUtils.ErrSourceCopyFailed, err) + } + if err := json.Unmarshal(data, &previous); err != nil { + return previous, fmt.Errorf("%w: read source ownership: %w", errUtils.ErrSourceCopyFailed, err) + } + for _, name := range previous.Files { + if !safeSourceRelative(name) { + return previous, fmt.Errorf("%w: invalid source ownership path %q", errUtils.ErrSourceCopyFailed, name) + } + } + return previous, nil +} + +func sourceChanges(stage, target string, next, previous sourceFiles, protected map[string]bool) ([]string, map[string]bool, error) { + owned := make(map[string]bool, len(previous.Files)) + incoming := make(map[string]bool, len(previous.Files)+len(next.Files)) + for _, name := range previous.Files { + owned[name], incoming[name] = true, false + } + for _, name := range next.Files { + incoming[name] = true + } + var changes []string + for name, install := range incoming { + change, err := sourceChange(stage, target, name, sourceChangeFlags{install: install, owned: owned[name]}, protected) + if err != nil { + return nil, nil, err + } + if change { + changes = append(changes, name) + } + } + sort.Slice(changes, func(i, j int) bool { + if incoming[changes[i]] != incoming[changes[j]] { + return !incoming[changes[i]] + } + return changes[i] < changes[j] + }) + return changes, incoming, nil +} + +// Legacy directories lack ownership receipts. Terraform configuration is source; +// other existing files must match the incoming bytes before adopting them. +func validateUnownedIncoming(stage, target, name string) error { + path := filepath.Join(target, name) + info, err := os.Lstat(path) + if os.IsNotExist(err) { + return nil + } + if err != nil { + return err + } + if !info.Mode().IsRegular() { + return fmt.Errorf("%w: source path conflicts with existing non-file %s", errUtils.ErrSourceCopyFailed, name) + } + if strings.HasSuffix(name, ".tf") || strings.HasSuffix(name, ".tf.json") { + return nil + } + old, oldErr := os.ReadFile(path) + fresh, freshErr := os.ReadFile(filepath.Join(stage, name)) + if oldErr != nil || freshErr != nil || string(old) != string(fresh) { + return fmt.Errorf("%w: cannot establish ownership of existing file %s", errUtils.ErrSourceCopyFailed, name) + } + return nil +} + +func prepareSourceReceipts(stage, target string, next sourceFiles, changes []string, incoming map[string]bool) ([]string, error) { + encoded, err := json.Marshal(next) + if err != nil { + return nil, err + } + if err := os.MkdirAll(filepath.Join(stage, ".atmos"), TargetDirPermissions); err != nil { + return nil, err + } + // #nosec G306 -- ownership receipt contains source-relative filenames, not credentials. + if err := os.WriteFile(filepath.Join(stage, sourceFilesManifest), encoded, provenanceFilePermissions); err != nil { + return nil, err + } + // Include receipts in the source journal, never metadata-lock sidecars. + for _, name := range []string{sourceFilesManifest, ".atmos/metadata.json", ".atmos/source.json"} { + if _, err := os.Stat(filepath.Join(stage, name)); os.IsNotExist(err) { + continue + } else if err != nil { + return nil, err + } + if err := rejectSourceSymlinkAncestors(target, name); err != nil { + return nil, err + } + incoming[name] = true + changes = append(changes, name) + } + return changes, nil +} + +func sourceInventory(root string) (sourceFiles, error) { + inventory := sourceFiles{} + err := filepath.WalkDir(root, func(path string, entry fs.DirEntry, err error) error { + if err != nil { + return err + } + if entry.IsDir() { + return nil + } + rel, err := filepath.Rel(root, path) + if err != nil { + return err + } + rel = filepath.ToSlash(rel) + if rel == ".atmos/metadata.json" || rel == ".atmos/metadata.json.lock" || rel == ".atmos/source.json" { + return nil + } + if rel == sourceFilesManifest { + return fmt.Errorf("%w: source contains reserved ownership manifest %s", errUtils.ErrSourceCopyFailed, rel) + } + inventory.Files = append(inventory.Files, rel) + return nil + }) + return inventory, err +} + +// The safeSourceRelative check accepts only canonical, slash-separated paths that stay inside the target. +// Requiring filepath.IsLocal also rejects volume-qualified names such as "C:state" and reserved device names +// on Windows, where joining them to the target would address an alternate data stream or device. +func safeSourceRelative(name string) bool { + return name != "" && name != "." && !filepath.IsAbs(name) && filepath.IsLocal(name) && filepath.ToSlash(filepath.Clean(name)) == name && name != ".." && !strings.HasPrefix(name, "../") +} + +func rejectSourceSymlinkAncestors(target, relative string) error { + for path := filepath.Join(target, filepath.Dir(relative)); ; path = filepath.Dir(path) { + if info, err := os.Lstat(path); err == nil && info.Mode()&os.ModeSymlink != 0 { + return fmt.Errorf("%w: source destination traverses symlink %s", errUtils.ErrSourceCopyFailed, path) + } + if path == filepath.Clean(target) { + return nil + } + if filepath.Dir(path) == path { + return fmt.Errorf("%w: source destination escaped target", errUtils.ErrSourceCopyFailed) + } + } +} + +func rejectActiveStateLock(target string) error { + err := filepath.WalkDir(target, func(path string, entry fs.DirEntry, err error) error { + if err != nil { + return err + } + if strings.HasSuffix(entry.Name(), ".lock.info") { + return fmt.Errorf("%w: active Terraform state lock %s", errUtils.ErrSourceCopyFailed, path) + } + return nil + }) + if os.IsNotExist(err) { + return nil + } + return err +} + +// runtimePaths accounts for nested module roots and custom local backend locations. +func runtimePaths(target string, config map[string]any) map[string]bool { + protected := map[string]bool{} + for _, root := range moduleRoots(target, config) { + for _, name := range []string{".terraform", "terraform.tfstate", "terraform.tfstate.backup", "terraform.tfstate.d"} { + protected[filepath.Join(root, name)] = true + } + protectLocalBackendPaths(protected, root, config) + } + return protected +} + +// moduleRoots lists every directory Terraform may run in under target: the target itself, the +// component name and the metadata.component subpath joined onto it, and an already-resolved +// workdir path. The subpath candidates are included before they exist, because refresh runs +// before the module root is resolved against the downloaded tree. +func moduleRoots(target string, config map[string]any) []string { + roots := []string{target} + candidates := []string{extractComponentName(config)} + if metadata, ok := config["metadata"].(map[string]any); ok { + subpath, _ := metadata["component"].(string) + candidates = append(candidates, subpath) + } + for _, candidate := range candidates { + if candidate != "" && filepath.IsLocal(candidate) { + roots = append(roots, filepath.Join(target, candidate)) + } + } + if resolved, ok := config[workdir.WorkdirPathKey].(string); ok && resolved != "" && isWithinBase(resolved, target) { + roots = append(roots, filepath.Clean(resolved)) + } + return roots +} + +// protectLocalBackendPaths marks custom local backend locations as runtime-owned. The state reader +// accepts both the flat form (backend.path) and the nested form (backend.local.path), so both are +// protected here. +func protectLocalBackendPaths(protected map[string]bool, root string, config map[string]any) { + backend, _ := config["backend"].(map[string]any) + local, _ := backend["local"].(map[string]any) + for _, section := range []map[string]any{backend, local} { + for _, key := range []string{"path", "workspace_dir"} { + value, ok := section[key].(string) + if !ok || value == "" { + continue + } + path := value + if !filepath.IsAbs(path) { + path = filepath.Join(root, path) + } + protected[filepath.Clean(path)] = true + if key == "path" { + protected[filepath.Clean(path)+".backup"] = true + } + } + } +} + +func runtimeOwned(path, relative string, protected map[string]bool) (bool, error) { + info, err := os.Lstat(path) + if os.IsNotExist(err) { + // An absent destination under a protected runtime root (local state, .terraform, a configured + // backend path) is still runtime-owned: installing a source file there would plant initial state. + // An absent provider lock file is not under such a root, so it still reaches installation. + return underProtectedRoot(path, protected), nil + } else if err != nil { + return false, err + } + if protectedRuntimePath(path, relative, protected) { + return true, nil + } + state, err := isTerraformState(path) + if info.Mode()&os.ModeSymlink != 0 && os.IsNotExist(err) { + return false, nil + } + if err != nil || state { + return state, err + } + return isTerraformPlan(path), nil +} + +func protectedRuntimePath(path, relative string, protected map[string]bool) bool { + if underProtectedRoot(path, protected) { + return true + } + return strings.HasSuffix(strings.ToLower(filepath.Base(path)), ".terraform.lock.hcl") || + strings.EqualFold(relative, ".atmos/metadata.json") || strings.EqualFold(relative, ".atmos/source.json") +} + +// underProtectedRoot reports whether path is a protected runtime root or lies beneath one. +func underProtectedRoot(path string, protected map[string]bool) bool { + path = strings.ToLower(path) + for root := range protected { + root = strings.ToLower(root) + if path == root || strings.HasPrefix(path, root+string(filepath.Separator)) { + return true + } + } + return false +} + +// checkSourceDestination rejects a destination that traverses a symlink and, for an incoming file, +// one whose type differs from the source path. +func checkSourceDestination(target, name string, install bool) error { + if err := rejectSourceSymlinkAncestors(target, name); err != nil { + return err + } + if !install { + return nil + } + return rejectSourceTypeChange(target, name) +} + +// rejectSourceTypeChange fails before publication when an incoming file would replace a nonempty +// directory, or would need a directory where a file exists. Refresh replaces files in place and cannot +// change a path's type transactionally, so the error names the path and how to recover. An empty +// directory is still replaced by publication, as before. +func rejectSourceTypeChange(target, name string) error { + const recovery = "; refresh cannot change a path between a file and a directory in place. Move only that path out of the component directory (keep anything it holds that you still need), then refresh again; do not delete the whole directory, which would also remove local state, `.terraform` and saved plans" + local := filepath.FromSlash(name) + if entries, err := os.ReadDir(filepath.Join(target, local)); err == nil && len(entries) > 0 { + return fmt.Errorf("%w: source file %s conflicts with a nonempty directory in the target%s", + errUtils.ErrSourceCopyFailed, name, recovery) + } + for dir := filepath.Dir(local); dir != "." && dir != string(filepath.Separator); dir = filepath.Dir(dir) { + if info, err := os.Lstat(filepath.Join(target, dir)); err == nil && info.Mode().IsRegular() { + return fmt.Errorf("%w: source path %s needs a directory where the target has the file %s%s", + errUtils.ErrSourceCopyFailed, name, filepath.ToSlash(dir), recovery) + } + } + return nil +} + +func isTerraformPlan(path string) bool { + archive, err := zip.OpenReader(path) + if err != nil { + return false + } + defer archive.Close() + for _, file := range archive.File { + if file.Name == "tfplan" { + return true + } + } + return false +} + +// sourceChange distinguishes files owned by the source from runtime artifacts. +type sourceChangeFlags struct{ install, owned bool } + +func sourceChange(stage, target, name string, flags sourceChangeFlags, protected map[string]bool) (bool, error) { + install, owned := flags.install, flags.owned + if err := checkSourceDestination(target, name, install); err != nil { + return false, err + } + path := filepath.Join(target, filepath.FromSlash(name)) + runtime, err := runtimeOwned(path, name, protected) + if err != nil { + return false, fmt.Errorf("%w: inspect runtime artifact %s: %w", errUtils.ErrSourceCopyFailed, name, err) + } + if runtime { + return false, validateRuntimeSource(stage, path, name, flags, protected) + } + if !install { + _, err := os.Lstat(path) + return !os.IsNotExist(err), nil + } + if !owned { + if err := validateUnownedIncoming(stage, target, name); err != nil { + return false, err + } + } + return true, nil +} + +// identicalSourceFile permits unchanged source fixtures without replacing runtime-modified contents. +func identicalSourceFile(stage, path, name string) bool { + old, oldErr := os.ReadFile(path) + fresh, freshErr := os.ReadFile(filepath.Join(stage, filepath.FromSlash(name))) + return oldErr == nil && freshErr == nil && string(old) == string(fresh) +} + +// validateRuntimeSource allows only preserved locks and unchanged source-owned fixtures. +func validateRuntimeSource(stage, path, name string, flags sourceChangeFlags, protected map[string]bool) error { + if !flags.install || strings.HasSuffix(strings.ToLower(filepath.Base(name)), ".terraform.lock.hcl") { + return nil + } + if flags.owned && !protectedRuntimePath(path, name, protected) && identicalSourceFile(stage, path, name) { + return nil + } + return fmt.Errorf("%w: downloaded source collides with runtime artifact %s", errUtils.ErrSourceCopyFailed, name) +} diff --git a/pkg/provisioner/source/refresh_alias_test.go b/pkg/provisioner/source/refresh_alias_test.go new file mode 100644 index 00000000000..508080970e7 --- /dev/null +++ b/pkg/provisioner/source/refresh_alias_test.go @@ -0,0 +1,115 @@ +package source + +import ( + "context" + "os" + "path/filepath" + "sync" + "testing" + "time" + + "github.com/stretchr/testify/require" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/filelock" + "github.com/cloudposse/atmos/pkg/provisioner" + "github.com/cloudposse/atmos/pkg/provisioner/workdir" + "github.com/cloudposse/atmos/pkg/schema" +) + +func TestSourceRefreshCancellationWhileWaitingForPublication(t *testing.T) { + src, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, src, "main.tf", "# source") + canonical, err := resolveExistingSymlinks(target) + require.NoError(t, err) + lock := filelock.New(provisioner.LockCoordPath(canonical+".source-refresh") + ".lock") + require.NoError(t, lock.WithExclusive(t.Context(), func() error { + ctx, cancel := context.WithTimeout(t.Context(), 50*time.Millisecond) + defer cancel() + err := VendorSource(ctx, nil, &schema.VendorComponentSource{Uri: src}, target, WithRuntimePreservation(nil)) + require.ErrorIs(t, err, errUtils.ErrCacheLocked) + require.ErrorIs(t, err, context.DeadlineExceeded) + require.NoDirExists(t, target) + return nil + })) + // Cancellation releases only the waiter's claim; a later publisher can recover. + require.NoError(t, VendorSource(t.Context(), nil, &schema.VendorComponentSource{Uri: src}, target, WithRuntimePreservation(nil))) + content, err := os.ReadFile(filepath.Join(target, "main.tf")) + require.NoError(t, err) + require.Equal(t, "# source", string(content)) +} + +func TestSourceRefreshSerializesAncestorAliasOwners(t *testing.T) { + parent := t.TempDir() + realParent, aliasParent := filepath.Join(parent, "real"), filepath.Join(parent, "alias") + require.NoError(t, os.Mkdir(realParent, 0o755)) + if err := os.Symlink(realParent, aliasParent); err != nil { + t.Skipf("symlinks unavailable: %v", err) + } + firstSource, secondSource := t.TempDir(), t.TempDir() + refreshWrite(t, firstSource, "main.tf", "# winning source") + refreshWrite(t, secondSource, "main.tf", "# losing source") + firstSpec := &schema.VendorComponentSource{Uri: firstSource} + secondSpec := &schema.VendorComponentSource{Uri: secondSource} + firstTarget := &Target{Dir: filepath.Join(realParent, "work"), IsWorkdir: true, EnforceOwner: true, Component: "module", Instance: "first"} + secondTarget := &Target{Dir: filepath.Join(aliasParent, "work"), IsWorkdir: true, EnforceOwner: true, Component: "module", Instance: "second"} + + staged, release := make(chan struct{}), make(chan struct{}) + var releaseOnce sync.Once + unblock := func() { releaseOnce.Do(func() { close(release) }) } + t.Cleanup(unblock) + pauseBeforePublication := func(opts *vendorSourceOptions) { + metadata := opts.metadata + opts.metadata = func(stage string) error { + if err := metadata(stage); err != nil { + return err + } + close(staged) + <-release + return nil + } + } + firstResult := make(chan error, 1) + go func() { + firstResult <- VendorSource(t.Context(), nil, firstSpec, firstTarget.Dir, WithRuntimePreservation(nil), withProvenance(firstTarget, "dev", firstSpec, nil), pauseBeforePublication) + }() + select { + case <-staged: + case err := <-firstResult: + t.Fatalf("first source failed before staging: %v", err) + } + // The winner still owns the publication lock. The aliased contender must wait + // for that same lock (and say so), rather than publish into the same tree. + waiting := make(chan string, 1) + restoreWarn, restoreDelay := warnSourceRefreshLockWait, sourceRefreshLockWarnAfter + t.Cleanup(func() { warnSourceRefreshLockWait, sourceRefreshLockWarnAfter = restoreWarn, restoreDelay }) + sourceRefreshLockWarnAfter = time.Millisecond + warnSourceRefreshLockWait = func(_ context.Context, target string) { waiting <- target } + secondResult := make(chan error, 1) + go func() { + secondResult <- VendorSource(t.Context(), nil, secondSpec, secondTarget.Dir, WithRuntimePreservation(nil), withProvenance(secondTarget, "dev", secondSpec, nil)) + }() + select { + case blocked := <-waiting: + require.Equal(t, secondTarget.Dir, blocked) + case err := <-secondResult: + t.Fatalf("aliased contender did not wait for the publication lock: %v", err) + } + unblock() + require.NoError(t, <-firstResult) + // Once the winner publishes, the contender sees a target owned by another instance. + require.ErrorIs(t, <-secondResult, errUtils.ErrWorkdirProvision) + metadata, err := workdir.ReadMetadata(firstTarget.Dir) + require.NoError(t, err) + require.Equal(t, "first", metadata.Component) + content, err := os.ReadFile(filepath.Join(firstTarget.Dir, "main.tf")) + require.NoError(t, err) + require.Equal(t, "# winning source", string(content)) + refreshWrite(t, firstTarget.Dir, "terraform.tfstate", `{"version":4,"lineage":"winner","serial":1}`) + before := refreshFileDigest(t, filepath.Join(firstTarget.Dir, "terraform.tfstate")) + require.ErrorIs(t, VendorSource(t.Context(), nil, secondSpec, secondTarget.Dir, WithRuntimePreservation(nil), withProvenance(secondTarget, "dev", secondSpec, nil)), errUtils.ErrWorkdirProvision) + require.Equal(t, before, refreshFileDigest(t, filepath.Join(firstTarget.Dir, "terraform.tfstate"))) + content, err = os.ReadFile(filepath.Join(firstTarget.Dir, "main.tf")) + require.NoError(t, err) + require.Equal(t, "# winning source", string(content)) +} diff --git a/pkg/provisioner/source/refresh_publish.go b/pkg/provisioner/source/refresh_publish.go new file mode 100644 index 00000000000..a560d18bea5 --- /dev/null +++ b/pkg/provisioner/source/refresh_publish.go @@ -0,0 +1,112 @@ +package source + +import ( + "context" + "errors" + "fmt" + "os" + "path/filepath" + + errUtils "github.com/cloudposse/atmos/errors" +) + +type sourceJournalEntry struct { + name string + existed, installed bool +} + +type sourcePublication struct { + stage, target, backup string + rename sourceRename + journal []sourceJournalEntry +} + +func (p *sourcePublication) publish(ctx context.Context, changes []string, incoming map[string]bool) (retErr error) { + defer func() { + if retErr != nil { + if err := p.rollback(); err != nil { + // Preserve the last usable backup if restoration itself fails. + retErr = errors.Join(retErr, fmt.Errorf("source rollback journal retained at %s: %w", p.backup, err)) + return + } + } + _ = os.RemoveAll(p.backup) + }() + for _, name := range changes { + if err := ctx.Err(); err != nil { + return err + } + if err := p.install(name, incoming[name]); err != nil { + return err + } + } + return ctx.Err() +} + +func (p *sourcePublication) install(name string, incoming bool) error { + dest := filepath.Join(p.target, name) + if err := os.MkdirAll(filepath.Dir(dest), TargetDirPermissions); err != nil { + return err + } + item, err := p.backupFile(name) + if err != nil { + return err + } + p.journal = append(p.journal, item) + if incoming { + if err := p.rename(filepath.Join(p.stage, name), dest); err != nil { + return err + } + p.journal[len(p.journal)-1].installed = true + } + return nil +} + +func (p *sourcePublication) rollback() error { + var result error + for i := len(p.journal) - 1; i >= 0; i-- { + item := p.journal[i] + dest := filepath.Join(p.target, item.name) + if item.installed { + if err := os.Remove(dest); err != nil && !os.IsNotExist(err) { + result = errors.Join(result, err) + } + } + if item.existed { + if err := os.Rename(filepath.Join(p.backup, item.name), dest); err != nil { + result = errors.Join(result, fmt.Errorf("restore source %s: %w", item.name, err)) + } + } + } + return result +} + +func (p *sourcePublication) backupFile(name string) (sourceJournalEntry, error) { + dest := filepath.Join(p.target, name) + item := sourceJournalEntry{name: name} + info, err := os.Lstat(dest) + if os.IsNotExist(err) { + return item, nil + } + if err != nil { + return item, err + } + if info.IsDir() { + entries, err := os.ReadDir(dest) + if err != nil { + return item, err + } + if len(entries) != 0 { + return item, fmt.Errorf("%w: source file conflicts with nonempty directory %s", errUtils.ErrSourceCopyFailed, name) + } + } + saved := filepath.Join(p.backup, name) + if err := os.MkdirAll(filepath.Dir(saved), TargetDirPermissions); err != nil { + return item, err + } + if err := p.rename(dest, saved); err != nil { + return item, err + } + item.existed = true + return item, nil +} diff --git a/pkg/provisioner/source/refresh_roots_test.go b/pkg/provisioner/source/refresh_roots_test.go new file mode 100644 index 00000000000..6326f27c2d1 --- /dev/null +++ b/pkg/provisioner/source/refresh_roots_test.go @@ -0,0 +1,203 @@ +package source + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/provisioner/workdir" + "github.com/cloudposse/atmos/pkg/schema" +) + +// TestRuntimePathsProtectResolvedModuleRoot verifies that local backend state is protected under the +// module root Terraform actually runs in, not only under target and target/. +func TestRuntimePathsProtectResolvedModuleRoot(t *testing.T) { + target := filepath.Join(t.TempDir(), "work") + backend := map[string]any{"path": filepath.Join("state", "custom.tfstate")} + + t.Run("metadata.component subpath before the workdir key is resolved", func(t *testing.T) { + protected := runtimePaths(target, map[string]any{ + "component": "vpc", + "metadata": map[string]any{"component": "modules/vpc"}, + "backend": backend, + }) + root := filepath.Join(target, "modules", "vpc") + assert.True(t, protected[filepath.Join(root, "state", "custom.tfstate")]) + assert.True(t, protected[filepath.Join(root, "state", "custom.tfstate.backup")]) + assert.True(t, protected[filepath.Join(root, "terraform.tfstate.d")]) + // The existing roots stay protected. + assert.True(t, protected[filepath.Join(target, "state", "custom.tfstate")]) + assert.True(t, protected[filepath.Join(target, "vpc", "terraform.tfstate")]) + }) + + t.Run("resolved workdir path", func(t *testing.T) { + resolved := filepath.Join(target, "nested", "root") + protected := runtimePaths(target, map[string]any{"component": "vpc", workdir.WorkdirPathKey: resolved, "backend": backend}) + assert.True(t, protected[filepath.Join(resolved, "state", "custom.tfstate")]) + assert.True(t, protected[filepath.Join(resolved, ".terraform")]) + }) + + t.Run("workdir path outside the target is ignored", func(t *testing.T) { + outside := filepath.Join(t.TempDir(), "elsewhere") + protected := runtimePaths(target, map[string]any{workdir.WorkdirPathKey: outside}) + assert.False(t, protected[filepath.Join(outside, "terraform.tfstate")]) + }) +} + +// TestSourceRefreshRejectsGeneratedBackendCollision verifies a source that ships backend.tf.json is +// rejected when Atmos generates that file, and installed normally when backend generation is off. +func TestSourceRefreshRejectsGeneratedBackendCollision(t *testing.T) { + src := t.TempDir() + refreshWrite(t, src, "main.tf", "# source") + refreshWrite(t, src, "backend.tf.json", `{"terraform":{"backend":{"local":{}}}}`) + spec := &schema.VendorComponentSource{Uri: src} + + generating := &schema.AtmosConfiguration{} + generating.Components.Terraform.AutoGenerateBackendFile = true + target := filepath.Join(t.TempDir(), "target") + err := VendorSource(t.Context(), generating, spec, target, WithRuntimePreservation(nil)) + require.ErrorIs(t, err, errUtils.ErrSourceCopyFailed) + assert.Contains(t, err.Error(), "backend.tf.json") + assert.NoFileExists(t, filepath.Join(target, "main.tf"), "a rejected refresh must not publish any source file") + + target = filepath.Join(t.TempDir(), "target") + require.NoError(t, VendorSource(t.Context(), &schema.AtmosConfiguration{}, spec, target, WithRuntimePreservation(nil))) + assert.FileExists(t, filepath.Join(target, "backend.tf.json")) +} + +// TestSourceRefreshRejectsFileDirectoryTypeChange verifies a source update that turns a file into a +// directory, or a directory into a file, fails before publication with an actionable error. +func TestSourceRefreshRejectsFileDirectoryTypeChange(t *testing.T) { + for _, tc := range []struct{ name, before, after, conflict string }{ + {name: "file becomes directory", before: "modules", after: filepath.Join("modules", "main.tf"), conflict: "modules"}, + {name: "directory becomes file", before: filepath.Join("modules", "main.tf"), after: "modules", conflict: "modules"}, + } { + t.Run(tc.name, func(t *testing.T) { + first, second := t.TempDir(), t.TempDir() + refreshWrite(t, first, "main.tf", "# first") + refreshWrite(t, first, tc.before, "# before") + refreshWrite(t, second, "main.tf", "# second") + refreshWrite(t, second, tc.after, "# after") + target := filepath.Join(t.TempDir(), "target") + require.NoError(t, VendorSource(t.Context(), nil, &schema.VendorComponentSource{Uri: first}, target, WithRuntimePreservation(nil))) + + err := VendorSource(t.Context(), nil, &schema.VendorComponentSource{Uri: second}, target, WithRuntimePreservation(nil)) + require.ErrorIs(t, err, errUtils.ErrSourceCopyFailed) + assert.Contains(t, err.Error(), "between a file and a directory") + assert.Contains(t, err.Error(), tc.conflict) + // Nothing was published: the previous source is intact. + content, readErr := os.ReadFile(filepath.Join(target, "main.tf")) + require.NoError(t, readErr) + assert.Equal(t, "# first", string(content)) + assert.NotContains(t, err.Error(), "source delete") + + // The documented recovery moves only the conflicting path aside; refresh then succeeds. + require.NoError(t, os.Rename(filepath.Join(target, tc.conflict), filepath.Join(t.TempDir(), "aside"))) + require.NoError(t, VendorSource(t.Context(), nil, &schema.VendorComponentSource{Uri: second}, target, WithRuntimePreservation(nil))) + content, readErr = os.ReadFile(filepath.Join(target, tc.after)) + require.NoError(t, readErr) + assert.Equal(t, "# after", string(content)) + }) + } +} + +// TestSourceRefreshRejectsRuntimePathsOnFreshCheckout verifies that a source cannot plant initial +// local state or Terraform runtime files when the destination does not exist yet, while ordinary +// source files and an absent provider lock file still install. +func TestSourceRefreshRejectsRuntimePathsOnFreshCheckout(t *testing.T) { + cases := []struct { + name string + file string + config map[string]any + wantErr bool + }{ + {name: "case-variant-state", file: "Terraform.tfstate", wantErr: true}, + {name: "mixed-case-backend", file: "STATE/Custom.tfstate", config: map[string]any{"backend": map[string]any{"path": "state/custom.tfstate"}}, wantErr: true}, + {name: "default-state", file: "terraform.tfstate", wantErr: true}, + {name: "state-backup", file: "terraform.tfstate.backup", wantErr: true}, + {name: "workspace-state", file: "terraform.tfstate.d/dev/terraform.tfstate", wantErr: true}, + {name: "terraform-dir", file: ".terraform/terraform.tfstate", wantErr: true}, + { + name: "configured-backend-path", + file: "state/custom.tfstate", + config: map[string]any{"backend": map[string]any{"local": map[string]any{"path": "state/custom.tfstate"}}}, + wantErr: true, + }, + {name: "provider-lock", file: ".terraform.lock.hcl"}, + {name: "ordinary-file", file: "data/custom.tfstate"}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + src, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, src, "main.tf", "# source") + refreshWrite(t, src, tc.file, `{"version":4,"lineage":"shipped-by-source","serial":1}`) + spec := &schema.VendorComponentSource{Uri: src} + err := VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(tc.config)) + _, statErr := os.Lstat(filepath.Join(target, filepath.FromSlash(tc.file))) + if tc.wantErr { + require.ErrorIs(t, err, errUtils.ErrSourceCopyFailed) + require.ErrorContains(t, err, "collides with runtime artifact "+tc.file) + require.True(t, os.IsNotExist(statErr), "the source file must not be published at a runtime path") + return + } + require.NoError(t, err) + require.NoError(t, statErr, "a non-runtime source file must still be installed") + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(tc.config))) + if tc.name == "ordinary-file" { + refreshWrite(t, target, tc.file, `{"version":4,"lineage":"runtime","serial":2}`) + require.ErrorIs(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(tc.config)), errUtils.ErrSourceCopyFailed) + } + }) + } +} + +// TestRuntimeOwnedAbsentDestination verifies the missing-destination branch directly: absent paths under a +// protected root are runtime-owned, and absent paths elsewhere, including the provider lock file, are not. +func TestRuntimeOwnedAbsentDestination(t *testing.T) { + target := t.TempDir() + protected := runtimePaths(target, nil) + for relative, want := range map[string]bool{ + "terraform.tfstate": true, + ".terraform/modules/x/main.tf": true, + ".terraform.lock.hcl": false, + "modules/terraform.tfstate": false, + "terraform.tfstate.d.notes": false, + } { + owned, err := runtimeOwned(filepath.Join(target, filepath.FromSlash(relative)), relative, protected) + require.NoError(t, err) + assert.Equal(t, want, owned, relative) + } +} + +// TestReadSourceInventoryWrapsFailures verifies that unreadable and unparseable ownership manifests +// carry ErrSourceCopyFailed and keep their cause. +func TestReadSourceInventoryWrapsFailures(t *testing.T) { + t.Run("unparseable", func(t *testing.T) { + target := t.TempDir() + refreshWrite(t, target, sourceFilesManifest, "not json") + _, err := readSourceInventory(target) + require.ErrorIs(t, err, errUtils.ErrSourceCopyFailed) + require.ErrorContains(t, err, "read source ownership") + }) + t.Run("unreadable", func(t *testing.T) { + target := t.TempDir() + // A directory at the manifest path makes the read fail with an error other than not-exist. + require.NoError(t, os.MkdirAll(filepath.Join(target, filepath.FromSlash(sourceFilesManifest)), 0o755)) + _, err := readSourceInventory(target) + require.ErrorIs(t, err, errUtils.ErrSourceCopyFailed) + require.ErrorContains(t, err, "read source ownership") + }) +} + +func TestProtectedRuntimePathCaseAndBoundary(t *testing.T) { + root := t.TempDir() + protected := map[string]bool{filepath.Join(root, "State"): true} + for _, name := range []string{"STATE", "state/child", ".ATMOS/Metadata.JSON", ".ATMOS/Source.JSON", ".Terraform.Lock.hcl"} { + assert.True(t, protectedRuntimePath(filepath.Join(root, filepath.FromSlash(name)), name, protected), name) + } + assert.False(t, protectedRuntimePath(filepath.Join(root, "StateOther"), "StateOther", protected)) +} diff --git a/pkg/provisioner/source/refresh_safety_test.go b/pkg/provisioner/source/refresh_safety_test.go new file mode 100644 index 00000000000..35413b45288 --- /dev/null +++ b/pkg/provisioner/source/refresh_safety_test.go @@ -0,0 +1,224 @@ +package source + +import ( + "archive/zip" + "errors" + "os" + "path/filepath" + "testing" + + cockroacherrors "github.com/cockroachdb/errors" + "github.com/stretchr/testify/require" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/downloader" + "github.com/cloudposse/atmos/pkg/provisioner" + "github.com/cloudposse/atmos/pkg/provisioner/workdir" + "github.com/cloudposse/atmos/pkg/schema" +) + +func TestSourceRefreshOwnedFileBecomesDirectory(t *testing.T) { + for _, nonempty := range []bool{false, true} { + t.Run(map[bool]string{false: "empty-directory-replaced", true: "runtime-directory-preserved"}[nonempty], func(t *testing.T) { + src, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, src, "a.tf", "# old") + refreshWrite(t, src, "z.data", "original source file") + spec := &schema.VendorComponentSource{Uri: src} + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil))) + require.NoError(t, os.Remove(filepath.Join(target, "z.data"))) + require.NoError(t, os.Mkdir(filepath.Join(target, "z.data"), 0o755)) + if nonempty { + refreshWrite(t, target, "z.data/runtime", "caller-owned artifact") + } + before, err := downloader.TreeSHA256(target) + require.NoError(t, err) + refreshWrite(t, src, "a.tf", "# new") + refreshWrite(t, src, "z.data", "new source file") + err = VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil)) + if nonempty { + require.ErrorIs(t, err, errUtils.ErrSourceCopyFailed) + require.ErrorContains(t, err, "nonempty directory") + after, err := downloader.TreeSHA256(target) + require.NoError(t, err) + require.Equal(t, before, after, "an earlier source update and all receipts must roll back") + return + } + require.NoError(t, err) + contents, err := os.ReadFile(filepath.Join(target, "z.data")) + require.NoError(t, err) + require.Equal(t, "new source file", string(contents)) + }) + } +} + +func TestSourceRefreshBackupFailureRestoresEarlierFiles(t *testing.T) { + stage, target := t.TempDir(), t.TempDir() + for _, name := range []string{"a.tf", "b.tf"} { + refreshWrite(t, stage, name, "# new") + refreshWrite(t, target, name, "# previous") + } + refreshWrite(t, target, "terraform.tfstate", `{"version":4,"lineage":"preserved","serial":3}`) + before, err := downloader.TreeSHA256(target) + require.NoError(t, err) + failure := errors.New("cannot back up source file") + rename := func(from, to string) error { + if from == filepath.Join(target, "b.tf") { + return failure + } + return os.Rename(from, to) + } + require.ErrorIs(t, publishSource(t.Context(), stage, target, nil, rename), failure) + after, err := downloader.TreeSHA256(target) + require.NoError(t, err) + require.Equal(t, before, after) +} + +func TestSourceRefreshRemovesDanglingOwnedArtifact(t *testing.T) { + src, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, src, "custom.data", "source") + spec := &schema.VendorComponentSource{Uri: src} + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil))) + path := filepath.Join(target, "custom.data") + require.NoError(t, os.Remove(path)) + if err := os.Symlink(filepath.Join(t.TempDir(), "missing-state"), path); err != nil { + t.Skipf("symlinks unavailable: %v", err) + } + require.NoError(t, os.Remove(filepath.Join(src, "custom.data"))) + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil))) + _, err := os.Lstat(path) + require.True(t, os.IsNotExist(err)) +} + +func TestRuntimeOwnedSymlinkStateAndInspectionError(t *testing.T) { + dir := t.TempDir() + refreshWrite(t, dir, "state", `{"version":4,"lineage":"preserved","serial":3}`) + link := filepath.Join(dir, "custom.data") + if err := os.Symlink(filepath.Join(dir, "state"), link); err != nil { + t.Skipf("symlinks unavailable: %v", err) + } + owned, err := runtimeOwned(link, "custom.data", nil) + require.NoError(t, err) + require.True(t, owned, "a symlink to state must remain protected") + + require.NoError(t, os.Remove(link)) + require.NoError(t, os.Symlink(link, link)) + _, err = runtimeOwned(link, "custom.data", nil) + require.Error(t, err, "symlink inspection errors other than a missing target must propagate") +} + +func TestSourceExplicitWorkdirRefusesUnverifiableOwner(t *testing.T) { + for _, receipt := range []string{"missing", "corrupt"} { + t.Run(receipt, func(t *testing.T) { + base, src := t.TempDir(), t.TempDir() + refreshWrite(t, src, "main.tf", "# incoming") + target := filepath.Join(base, "custom") + refreshWrite(t, target, "terraform.tfstate", `{"version":4,"lineage":"existing","serial":8}`) + if receipt == "corrupt" { + refreshWrite(t, target, ".atmos/metadata.json", "invalid receipt") + } + section := map[string]any{ + "component": "module", "atmos_component": "instance", "atmos_stack": "dev", "source": src, + "settings": map[string]any{"working_directory": target}, + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + } + stateBefore, err := os.ReadFile(filepath.Join(target, "terraform.tfstate")) + require.NoError(t, err) + err = AutoProvisionSource(t.Context(), &schema.AtmosConfiguration{BasePath: base}, "terraform", section, nil, provisioner.OutputWriters{}) + require.ErrorIs(t, err, errUtils.ErrWorkdirProvision) + require.Contains(t, cockroacherrors.GetAllDetails(err), "Explicit source working directory has files but no verifiable instance owner") + require.NoFileExists(t, filepath.Join(target, "main.tf")) + stateAfter, err := os.ReadFile(filepath.Join(target, "terraform.tfstate")) + require.NoError(t, err) + require.Equal(t, stateBefore, stateAfter) + }) + } +} + +func TestSourceReceiptDirectoryConflictPreservesWorkdir(t *testing.T) { + src, target := t.TempDir(), t.TempDir() + refreshWrite(t, src, "main.tf", "# incoming") + refreshWrite(t, src, ".atmos", "source cannot replace the receipt directory") + refreshWrite(t, target, "main.tf", "# current") + require.NoError(t, workdir.WriteMetadata(target, &workdir.WorkdirMetadata{Component: "instance", Stack: "dev"})) + before, err := downloader.TreeSHA256(target) + require.NoError(t, err) + spec := &schema.VendorComponentSource{Uri: src} + receipt := &downloader.ResolvedArtifact{} + err = VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil), withProvenance(&Target{Dir: target, IsWorkdir: true, Instance: "instance"}, "dev", spec, receipt)) + var pathErr *os.PathError + require.ErrorAs(t, err, &pathErr, "receipt staging must fail on the source file occupying .atmos") + require.Equal(t, ".atmos", filepath.Base(pathErr.Path)) + after, err := downloader.TreeSHA256(target) + require.NoError(t, err) + require.Equal(t, before, after, "failed receipt staging must not publish source") +} + +func TestSourceRefreshRefusesReceiptPathConflicts(t *testing.T) { + for _, scenario := range []string{"inventory-is-directory", "stage-metadata-is-file", "metadata-symlink"} { + t.Run(scenario, func(t *testing.T) { + src, target := t.TempDir(), t.TempDir() + refreshWrite(t, src, "main.tf", "# incoming") + refreshWrite(t, target, "main.tf", "# current") + refreshWrite(t, target, "terraform.tfstate", `{"version":4,"lineage":"preserved","serial":5}`) + var external string + switch scenario { + case "inventory-is-directory": + require.NoError(t, os.MkdirAll(filepath.Join(target, sourceFilesManifest), 0o755)) + case "stage-metadata-is-file": + refreshWrite(t, src, ".atmos", "invalid receipt directory") + case "metadata-symlink": + external = t.TempDir() + refreshWrite(t, external, "preserved", "external metadata") + if err := os.Symlink(external, filepath.Join(target, ".atmos")); err != nil { + t.Skipf("symlinks unavailable: %v", err) + } + } + before, err := downloader.TreeSHA256(target) + require.NoError(t, err) + err = VendorSource(t.Context(), nil, &schema.VendorComponentSource{Uri: src}, target, WithRuntimePreservation(nil)) + if scenario == "metadata-symlink" { + require.ErrorIs(t, err, errUtils.ErrSourceCopyFailed) + } else { + var pathErr *os.PathError + require.ErrorAs(t, err, &pathErr) + if scenario == "inventory-is-directory" { + require.Equal(t, filepath.Join(target, sourceFilesManifest), pathErr.Path) + } else { + require.Equal(t, ".atmos", filepath.Base(pathErr.Path)) + } + } + after, err := downloader.TreeSHA256(target) + require.NoError(t, err) + require.Equal(t, before, after, "receipt path failure must preserve source and state") + if external != "" { + entries, err := os.ReadDir(external) + require.NoError(t, err) + require.Len(t, entries, 1, "no receipt may be written outside target") + contents, err := os.ReadFile(filepath.Join(external, "preserved")) + require.NoError(t, err) + require.Equal(t, "external metadata", string(contents)) + } + }) + } +} + +func TestSourceRefreshUpdatesOrdinaryZipSource(t *testing.T) { + src, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + for _, contents := range []string{"initial configuration", "updated configuration"} { + file, err := os.Create(filepath.Join(src, "config.zip")) + require.NoError(t, err) + archive := zip.NewWriter(file) + entry, err := archive.Create("configuration.json") + require.NoError(t, err) + _, err = entry.Write([]byte(contents)) + require.NoError(t, err) + require.NoError(t, archive.Close()) + require.NoError(t, file.Close()) + require.NoError(t, VendorSource(t.Context(), nil, &schema.VendorComponentSource{Uri: src}, target, WithRuntimePreservation(nil)), "a ZIP without tfplan is source content, not a saved Terraform plan") + want, err := os.ReadFile(filepath.Join(src, "config.zip")) + require.NoError(t, err) + got, err := os.ReadFile(filepath.Join(target, "config.zip")) + require.NoError(t, err) + require.Equal(t, want, got) + } +} diff --git a/pkg/provisioner/source/refresh_test.go b/pkg/provisioner/source/refresh_test.go new file mode 100644 index 00000000000..a7084c628d7 --- /dev/null +++ b/pkg/provisioner/source/refresh_test.go @@ -0,0 +1,608 @@ +package source + +import ( + "archive/zip" + "context" + "errors" + "io" + "net/http" + "net/http/httptest" + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" + "sync" + "sync/atomic" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/downloader" + "github.com/cloudposse/atmos/pkg/provisioner" + "github.com/cloudposse/atmos/pkg/provisioner/workdir" + "github.com/cloudposse/atmos/pkg/schema" +) + +func refreshWrite(t *testing.T, root, name, contents string) { + t.Helper() + path := filepath.Join(root, name) + require.NoError(t, os.MkdirAll(filepath.Dir(path), 0o755)) + require.NoError(t, os.WriteFile(path, []byte(contents), 0o644)) +} + +func TestSourceRefreshPreservesRuntimeAndRemovesOwnedSource(t *testing.T) { + src, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, src, "exports/main.tf", "# first") + refreshWrite(t, src, "examples/terraform.tfstate", "source fixture, not runtime") + refreshWrite(t, src, "exports/old.tf", "# obsolete") + config := map[string]any{"component": "exports", "backend": map[string]any{"local": map[string]any{"path": "custom/state.data", "workspace_dir": "custom/workspaces"}}} + spec := &schema.VendorComponentSource{Uri: src} + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(config))) + runtime := map[string]string{ + "exports/custom/state.data": "custom state bytes", "exports/custom/state.data.backup": "backup", "exports/custom/workspaces/blue/terraform.tfstate": "workspace", + "exports/.terraform/providers/provider": "installed provider", "exports/.terraform/modules/modules.json": "module manifest", "exports/.terraform.lock.hcl": "provider lock", "exports/.dev-a.terraform.lock.hcl": "instance lock", + "exports/reviewed-any-name": "reviewed saved plan", "exports/generated.txt": "generated content", "exports/backend.tf.json": "generated backend", + } + for name, contents := range runtime { + refreshWrite(t, target, name, contents) + } + stateBefore, err := os.Stat(filepath.Join(target, "exports", "custom", "state.data")) + require.NoError(t, err) + require.NoError(t, os.Remove(filepath.Join(src, "examples", "terraform.tfstate"))) + require.NoError(t, os.Remove(filepath.Join(src, "exports", "old.tf"))) + refreshWrite(t, src, "exports/main.tf", "# second") + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(config))) + for name, contents := range runtime { + got, err := os.ReadFile(filepath.Join(target, name)) + require.NoError(t, err, name) + assert.Equal(t, contents, string(got), name) + } + stateAfter, err := os.Stat(filepath.Join(target, "exports", "custom", "state.data")) + require.NoError(t, err) + assert.True(t, os.SameFile(stateBefore, stateAfter), "runtime inode must not move") + assert.NoFileExists(t, filepath.Join(target, "examples", "terraform.tfstate")) + assert.NoFileExists(t, filepath.Join(target, "exports", "old.tf")) + got, err := os.ReadFile(filepath.Join(target, "exports", "main.tf")) + require.NoError(t, err) + assert.Equal(t, "# second", string(got)) +} + +func TestSourceRefreshRollbackAndCancellation(t *testing.T) { + for _, mode := range []string{"copy-failure", "publish-failure", "cancel", "active-lock"} { + t.Run(mode, func(t *testing.T) { + src, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, src, "a.tf", "v1-a") + refreshWrite(t, src, "b.tf", "v1-b") + opts := WithRuntimePreservation(nil) + spec := &schema.VendorComponentSource{Uri: src} + require.NoError(t, VendorSource(t.Context(), nil, spec, target, opts)) + refreshWrite(t, target, "terraform.tfstate", `{"version":4,"lineage":"original","serial":2}`) + before, err := downloader.TreeSHA256(target) + require.NoError(t, err) + refreshWrite(t, src, "a.tf", "v2-a") + refreshWrite(t, src, "b.tf", "v2-b") + switch mode { + case "copy-failure": + spec.IncludedPaths = []string{"["} + err = VendorSource(t.Context(), nil, spec, target, opts) + case "publish-failure", "cancel": + ctx, cancel := context.WithCancel(t.Context()) + defer cancel() + count := 0 + rename := func(from, to string) error { + count++ + if count == 3 { + if mode == "cancel" { + cancel() + } else { + return errors.New("injected publish failure") + } + } + return os.Rename(from, to) + } + err = publishSource(ctx, src, target, nil, rename) + case "active-lock": + refreshWrite(t, target, ".terraform.tfstate.lock.info", "active operation") + err = VendorSource(t.Context(), nil, spec, target, opts) + require.NoError(t, os.Remove(filepath.Join(target, ".terraform.tfstate.lock.info"))) + } + require.Error(t, err) + after, e := downloader.TreeSHA256(target) + require.NoError(t, e) + assert.Equal(t, before, after, "failure must preserve source, state and ownership receipt") + }) + } +} + +func TestSourceRefreshRefusesRuntimeCollisionAndSymlinkTraversal(t *testing.T) { + for _, kind := range []string{"configured-state", "state-content", "saved-plan", "symlink"} { + t.Run(kind, func(t *testing.T) { + src, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, src, "nested/owned.data", "source") + config := map[string]any{} + spec := &schema.VendorComponentSource{Uri: src} + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(config))) + switch kind { + case "configured-state": + config["backend"] = map[string]any{"local": map[string]any{"path": "nested/owned.data"}} + refreshWrite(t, target, "nested/owned.data", "custom state") + case "state-content": + refreshWrite(t, target, "nested/owned.data", `{"version":4,"lineage":"existing-state","serial":7}`) + case "saved-plan": + file, e := os.Create(filepath.Join(target, "nested", "owned.data")) + require.NoError(t, e) + writer := zip.NewWriter(file) + entry, e := writer.Create("tfplan") + require.NoError(t, e) + _, e = entry.Write([]byte("reviewed plan")) + require.NoError(t, e) + require.NoError(t, writer.Close()) + require.NoError(t, file.Close()) + case "symlink": + outside := t.TempDir() + refreshWrite(t, outside, "owned.data", "outside") + require.NoError(t, os.RemoveAll(filepath.Join(target, "nested"))) + if e := os.Symlink(outside, filepath.Join(target, "nested")); e != nil { + t.Skipf("symlinks unavailable: %v", e) + } + } + before, e := downloader.TreeSHA256(target) + require.NoError(t, e) + require.Error(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(config))) + after, e := downloader.TreeSHA256(target) + require.NoError(t, e) + assert.Equal(t, before, after) + }) + } +} + +func TestSourceInvocationReuseFreshMapsAndChangedSources(t *testing.T) { + src := t.TempDir() + refreshWrite(t, src, "main.tf", "# v1") + conf := &schema.AtmosConfiguration{BasePath: t.TempDir()} + component := func() map[string]any { + return map[string]any{"component": "example", "atmos_component": "alias", "atmos_stack": "dev", "source": map[string]any{"uri": src, "ttl": "0s"}, "provision": map[string]any{"workdir": map[string]any{"enabled": true}}} + } + first := component() + restore := BeginInvocation() + t.Cleanup(restore) + ctx := workdir.WithOutputSuppressed(t.Context()) + require.NoError(t, AutoProvisionSource(ctx, conf, "terraform", first, nil, provisioner.OutputWriters{})) + target, e := ResolveTarget(conf, "terraform", "example", first) + require.NoError(t, e) + refreshWrite(t, src, "main.tf", "# v2") + second := component() + require.NoError(t, AutoProvisionSource(ctx, conf, "terraform", second, nil, provisioner.OutputWriters{})) + got, e := os.ReadFile(filepath.Join(target.Dir, "main.tf")) + require.NoError(t, e) + assert.Equal(t, "# v1", string(got)) + assert.Equal(t, target.Dir, second[workdir.WorkdirPathKey]) + // A hook on the same config must not undo a resolved nested module directory. + require.NoError(t, os.MkdirAll(filepath.Join(target.Dir, "exports"), 0o755)) + second[workdir.WorkdirPathKey] = filepath.Join(target.Dir, "exports") + require.NoError(t, AutoProvisionSource(ctx, conf, "terraform", second, nil, provisioner.OutputWriters{})) + assert.Equal(t, filepath.Join(target.Dir, "exports"), second[workdir.WorkdirPathKey]) + // A changed selector within the same invocation must fetch; a failed attempt must retry. + other := t.TempDir() + refreshWrite(t, other, "main.tf", "# other") + changed := component() + changed["source"].(map[string]any)["uri"] = other + require.NoError(t, AutoProvisionSource(ctx, conf, "terraform", changed, nil, provisioner.OutputWriters{})) + got, e = os.ReadFile(filepath.Join(target.Dir, "main.tf")) + require.NoError(t, e) + assert.Equal(t, "# other", string(got)) + // Returning to a prior selector after another source occupied the target must + // refresh rather than reuse an earlier success for that selector. + require.NoError(t, AutoProvisionSource(ctx, conf, "terraform", first, nil, provisioner.OutputWriters{})) + got, e = os.ReadFile(filepath.Join(target.Dir, "main.tf")) + require.NoError(t, e) + assert.Equal(t, "# v2", string(got)) + require.NoError(t, os.RemoveAll(target.Dir)) + require.NoError(t, AutoProvisionSource(ctx, conf, "terraform", component(), nil, provisioner.OutputWriters{})) + refreshWrite(t, src, "main.tf", "# next invocation") + restore() + restore = BeginInvocation() + defer restore() + // Even reusing the same component map cannot leak success across CLI invocations. + require.NoError(t, AutoProvisionSource(ctx, conf, "terraform", first, nil, provisioner.OutputWriters{})) + got, e = os.ReadFile(filepath.Join(target.Dir, "main.tf")) + require.NoError(t, e) + assert.Equal(t, "# next invocation", string(got)) +} + +func TestSourceGitReceiptUsesFetchedCommit(t *testing.T) { + if _, err := exec.LookPath("git"); err != nil { + t.Skip("git required") + } + git := func(dir string, args ...string) string { + t.Helper() + cmd := exec.Command("git", append([]string{"-c", "commit.gpgsign=false", "-c", "user.name=Fixture", "-c", "user.email=fixture@example.invalid"}, args...)...) + cmd.Dir = dir + out, e := cmd.CombinedOutput() + require.NoError(t, e, string(out)) + return strings.TrimSpace(string(out)) + } + repo, consumer := t.TempDir(), t.TempDir() + git(repo, "init", "-q") + refreshWrite(t, repo, "exports/main.tf", "# source") + git(repo, "add", ".") + git(repo, "commit", "-qm", "source") + sourceCommit := git(repo, "rev-parse", "HEAD") + git(consumer, "init", "-q") + refreshWrite(t, consumer, "README.md", "consumer") + git(consumer, "add", ".") + git(consumer, "commit", "-qm", "consumer") + var receipt downloader.ResolvedArtifact + target := filepath.Join(consumer, "vendored") + spec := &schema.VendorComponentSource{Uri: "git::file://" + filepath.ToSlash(repo) + "//exports", Version: sourceCommit} + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil), WithArtifactReceipt(&receipt))) + assert.Equal(t, "git", receipt.Kind) + assert.Equal(t, sourceCommit, receipt.Identity) + assert.NotEqual(t, git(consumer, "rev-parse", "HEAD"), receipt.Identity) + require.NoError(t, writeWorkdirMetadata(target, "example", "dev", spec, &receipt)) + md, e := workdir.ReadMetadata(target) + require.NoError(t, e) + assert.Equal(t, sourceCommit, md.SourceIdentity) +} + +func TestSourceInvocationConcurrentFreshMapsAndRetry(t *testing.T) { + var requests atomic.Int64 + var fail atomic.Bool + fail.Store(true) + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method == http.MethodGet { + requests.Add(1) + } + if fail.Load() { + w.WriteHeader(http.StatusInternalServerError) + return + } + _, _ = io.WriteString(w, "# fetched source") + })) + defer server.Close() + restore := BeginInvocation() + defer restore() + conf := &schema.AtmosConfiguration{BasePath: t.TempDir()} + makeComponent := func() map[string]any { + return map[string]any{"component": "example", "atmos_component": "alias", "atmos_stack": "dev", "source": map[string]any{"uri": server.URL + "/main.tf", "ttl": "0s"}, "provision": map[string]any{"workdir": map[string]any{"enabled": true}}} + } + ctx := workdir.WithOutputSuppressed(t.Context()) + require.Error(t, AutoProvisionSource(ctx, conf, "terraform", makeComponent(), nil, provisioner.OutputWriters{})) + failedRequests := requests.Load() + fail.Store(false) + var wg sync.WaitGroup + failures := make(chan error, 8) + for range 8 { + wg.Add(1) + go func() { + defer wg.Done() + failures <- AutoProvisionSource(ctx, conf, "terraform", makeComponent(), nil, provisioner.OutputWriters{}) + }() + } + wg.Wait() + close(failures) + for err := range failures { + require.NoError(t, err) + } + assert.Equal(t, failedRequests+1, requests.Load(), "one successful fetch across independently resolved maps; failed attempt was not cached") + // Auth and checkout scopes remain independent, even with identical stack/component names. + scopedAuth := &schema.AuthContext{AWS: &schema.AWSAuthContext{Region: "us-east-2"}} + require.NoError(t, AutoProvisionSource(ctx, conf, "terraform", makeComponent(), scopedAuth, provisioner.OutputWriters{})) + assert.Equal(t, failedRequests+2, requests.Load()) + other := &schema.AtmosConfiguration{BasePath: t.TempDir()} + require.NoError(t, AutoProvisionSource(ctx, other, "terraform", makeComponent(), nil, provisioner.OutputWriters{})) + assert.Equal(t, failedRequests+3, requests.Load()) + for _, credential := range []string{"initial-scope", "initial-scope", "rotated-scope"} { + component := makeComponent() + component["auth"] = map[string]any{"password": credential} + require.NoError(t, AutoProvisionSource(ctx, conf, "terraform", component, nil, provisioner.OutputWriters{})) + } + assert.Equal(t, failedRequests+5, requests.Load(), "unchanged credentials reuse the source; changed credentials fetch again") +} + +func TestSourceRefreshMetadataFailureLeavesPriorReceipt(t *testing.T) { + src, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, src, "main.tf", "# old source") + spec := &schema.VendorComponentSource{Uri: src} + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil))) + refreshWrite(t, target, ".atmos/metadata.json", `{"source_identity":"previous"}`) + before, err := downloader.TreeSHA256(target) + require.NoError(t, err) + refreshWrite(t, src, "main.tf", "# new source") + failMetadata := func(opts *vendorSourceOptions) { + opts.metadata = func(string) error { return errors.New("injected receipt write failure") } + } + require.ErrorContains(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil), failMetadata), "injected receipt") + after, err := downloader.TreeSHA256(target) + require.NoError(t, err) + assert.Equal(t, before, after) +} + +// The state reader accepts the flat backend.path form as well as backend.local.path, so a refresh +// must treat a custom state file (and its backup) as runtime-owned either way: a source that ships a +// file at that location, even one it owned before, is rejected and the runtime bytes survive. +func TestSourceRefreshProtectsFlatBackendPathState(t *testing.T) { + for name, backend := range map[string]map[string]any{ + "flat": {"path": "custom/state.data"}, + "nested": {"local": map[string]any{"path": "custom/state.data"}}, + } { + for _, collision := range []string{"exports/custom/state.data", "exports/custom/state.data.backup"} { + t.Run(name+" "+filepath.Base(collision), func(t *testing.T) { + src, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, src, "exports/main.tf", "# first") + refreshWrite(t, src, collision, "source fixture") + spec := &schema.VendorComponentSource{Uri: src} + // The source owns the file before the backend path is configured; a fresh checkout with the + // backend already configured refuses to install it at all. + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(map[string]any{"component": "exports"}))) + config := map[string]any{"component": "exports", "backend": backend} + refreshWrite(t, target, collision, "opaque runtime bytes") + refreshWrite(t, src, collision, "changed source fixture") + err := VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(config)) + require.ErrorIs(t, err, errUtils.ErrSourceCopyFailed) + got, readErr := os.ReadFile(filepath.Join(target, collision)) + require.NoError(t, readErr) + assert.Equal(t, "opaque runtime bytes", string(got)) + }) + } + } +} + +func TestSourceExplicitTargetOwnership(t *testing.T) { + src := t.TempDir() + refreshWrite(t, src, "main.tf", "# module") + config := &schema.AtmosConfiguration{BasePath: t.TempDir()} + target := filepath.Join(config.BasePath, "explicit") + component := func(name string) map[string]any { + return map[string]any{ + "component": "module", "atmos_component": name, "atmos_stack": "dev", + "source": map[string]any{"uri": src}, + "settings": map[string]any{"working_directory": target}, + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + } + } + ctx := workdir.WithOutputSuppressed(t.Context()) + // The publication lock must enforce ownership even when both initial checks saw an empty target. + var wait sync.WaitGroup + outcomes := make(chan error, 2) + for _, name := range []string{"first", "second"} { + wait.Add(1) + go func() { + defer wait.Done() + outcomes <- AutoProvisionSource(ctx, config, "terraform", component(name), nil, provisioner.OutputWriters{}) + }() + } + wait.Wait() + close(outcomes) + successes := 0 + for err := range outcomes { + if err == nil { + successes++ + } else { + assert.ErrorIs(t, err, errUtils.ErrWorkdirProvision) + } + } + require.Equal(t, 1, successes) + metadata, err := workdir.ReadMetadata(target) + require.NoError(t, err) + require.NotNil(t, metadata) + require.Contains(t, []string{"first", "second"}, metadata.Component) + loser := "first" + if metadata.Component == loser { + loser = "second" + } + before, err := downloader.TreeSHA256(target) + require.NoError(t, err) + require.ErrorIs(t, AutoProvisionSource(ctx, config, "terraform", component(loser), nil, provisioner.OutputWriters{}), errUtils.ErrWorkdirProvision) + require.ErrorIs(t, Provision(ctx, &ProvisionParams{AtmosConfig: config, ComponentType: "terraform", Component: loser, Stack: "dev", ComponentConfig: component(loser), Force: true}), errUtils.ErrWorkdirProvision) + after, err := downloader.TreeSHA256(target) + require.NoError(t, err) + assert.Equal(t, before, after) +} + +// TestSourceExplicitTargetOwnershipHoldsWhenAnotherInstancePublishesFirst makes the race deterministic: +// the second instance passes its owner check on an empty target, then the first instance publishes +// before the second reaches its up-to-date early exit. The second must still be rejected. +func TestSourceExplicitTargetOwnershipHoldsWhenAnotherInstancePublishesFirst(t *testing.T) { + src := t.TempDir() + refreshWrite(t, src, "main.tf", "# module") + config := &schema.AtmosConfiguration{BasePath: t.TempDir()} + target := filepath.Join(config.BasePath, "explicit") + component := func(name string) map[string]any { + return map[string]any{ + "component": "module", "atmos_component": name, "atmos_stack": "dev", + "source": map[string]any{"uri": src}, + "settings": map[string]any{"working_directory": target}, + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + } + } + ctx := workdir.WithOutputSuppressed(t.Context()) + + var interleaved bool + afterTargetOwnerCheck = func(string) { + if interleaved { + return + } + interleaved = true + require.NoError(t, AutoProvisionSource(ctx, config, "terraform", component("first"), nil, provisioner.OutputWriters{})) + } + t.Cleanup(func() { afterTargetOwnerCheck = func(string) {} }) + + // The second instance sees an empty target at its owner check; "first" then publishes inside the hook. + err := AutoProvisionSource(ctx, config, "terraform", component("second"), nil, provisioner.OutputWriters{}) + require.ErrorIs(t, err, errUtils.ErrWorkdirProvision) + require.True(t, interleaved, "the interleaving hook must have run") + metadata, readErr := workdir.ReadMetadata(target) + require.NoError(t, readErr) + require.NotNil(t, metadata) + assert.Equal(t, "first", metadata.Component) +} + +// TestSourceExplicitTargetOwnershipRecheckedOnInvocationReuse covers the in-invocation reuse path: +// after a successful provision, another instance claims the explicit target once the initial owner +// check has passed. The reuse must be rejected instead of reporting the claimed directory as ready. +func TestSourceExplicitTargetOwnershipRecheckedOnInvocationReuse(t *testing.T) { + src := t.TempDir() + refreshWrite(t, src, "main.tf", "# module") + config := &schema.AtmosConfiguration{BasePath: t.TempDir()} + target := filepath.Join(config.BasePath, "explicit") + component := func() map[string]any { + return map[string]any{ + "component": "module", "atmos_component": "first", "atmos_stack": "dev", + "source": map[string]any{"uri": src}, + "settings": map[string]any{"working_directory": target}, + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + } + } + ctx := workdir.WithOutputSuppressed(t.Context()) + restore := BeginInvocation() + t.Cleanup(restore) + require.NoError(t, AutoProvisionSource(ctx, config, "terraform", component(), nil, provisioner.OutputWriters{})) + + // Prerequisite: without interference the same instance reuses the provisioned target. + require.NoError(t, AutoProvisionSource(ctx, config, "terraform", component(), nil, provisioner.OutputWriters{})) + + var claimed bool + afterTargetOwnerCheck = func(dir string) { + metadata, err := workdir.ReadMetadata(dir) + require.NoError(t, err) + require.NotNil(t, metadata) + metadata.Component = "second" + require.NoError(t, workdir.WriteMetadata(dir, metadata)) + claimed = true + } + t.Cleanup(func() { afterTargetOwnerCheck = func(string) {} }) + + err := AutoProvisionSource(ctx, config, "terraform", component(), nil, provisioner.OutputWriters{}) + require.True(t, claimed, "the interleaving hook must have run") + require.ErrorIs(t, err, errUtils.ErrWorkdirProvision) +} + +func TestSourceReceiptPublicationFailureRollsBackCode(t *testing.T) { + source, target := t.TempDir(), t.TempDir() + refreshWrite(t, source, "main.tf", "# next") + refreshWrite(t, source, ".atmos/metadata.json", `{"source_identity":"next"}`) + refreshWrite(t, target, "main.tf", "# previous") + refreshWrite(t, target, ".atmos/metadata.json", `{"source_identity":"previous"}`) + before, err := downloader.TreeSHA256(target) + require.NoError(t, err) + rename := func(from, to string) error { + if from == filepath.Join(source, ".atmos", "metadata.json") { + return errors.New("receipt publication failed") + } + return os.Rename(from, to) + } + require.ErrorContains(t, publishSource(t.Context(), source, target, nil, rename), "receipt publication failed") + after, err := downloader.TreeSHA256(target) + require.NoError(t, err) + assert.Equal(t, before, after) +} + +func TestSourceRefreshRejectsUnsafeOwnershipAndLegacyConflicts(t *testing.T) { + for _, scenario := range []string{"invalid-json", "escaping-path", "reserved-manifest", "legacy-conflict", "legacy-identical", "target-symlink", "replacement-disabled", "cancelled", "blocked-parent", "nonempty-directory"} { + t.Run(scenario, func(t *testing.T) { + src := t.TempDir() + parent := t.TempDir() + target := filepath.Join(parent, "target") + refreshWrite(t, src, "config.yaml", "new configuration") + refreshWrite(t, target, "preserved.state", "caller-owned") + spec := &schema.VendorComponentSource{Uri: src} + options := []VendorSourceOption{WithRuntimePreservation(nil)} + ctx := t.Context() + wantSuccess := false + switch scenario { + case "invalid-json": + refreshWrite(t, target, sourceFilesManifest, "not json") + case "escaping-path": + refreshWrite(t, target, sourceFilesManifest, `{"files":["../escape"]}`) + case "reserved-manifest": + refreshWrite(t, src, sourceFilesManifest, `{"files":[]}`) + case "legacy-conflict": + refreshWrite(t, target, "config.yaml", "unidentified existing file") + case "legacy-identical": + refreshWrite(t, target, "config.yaml", "new configuration") + wantSuccess = true + case "target-symlink": + outside := t.TempDir() + require.NoError(t, os.RemoveAll(target)) + if err := os.Symlink(outside, target); err != nil { + t.Skipf("symlinks unavailable: %v", err) + } + case "replacement-disabled": + options = append(options, WithReplaceTarget(false)) + case "cancelled": + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + cancel() + case "blocked-parent": + refreshWrite(t, parent, "blocker", "file") + target = filepath.Join(parent, "blocker", "target") + case "nonempty-directory": + refreshWrite(t, target, "config.yaml/runtime", "owned runtime") + } + err := VendorSource(ctx, nil, spec, target, options...) + if wantSuccess { + require.NoError(t, err) + } else { + require.Error(t, err) + } + if scenario != "target-symlink" && scenario != "blocked-parent" { + contents, e := os.ReadFile(filepath.Join(target, "preserved.state")) + require.NoError(t, e) + assert.Equal(t, "caller-owned", string(contents)) + } + }) + } +} + +func TestSourceRefreshKeepsManagedProviderLock(t *testing.T) { + src, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, src, "main.tf", "# v1") + refreshWrite(t, src, ".terraform.lock.hcl", "source lock") + spec := &schema.VendorComponentSource{Uri: src} + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil))) + refreshWrite(t, target, ".terraform.lock.hcl", "instance-managed lock") + refreshWrite(t, src, "main.tf", "# v2") + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil))) + actual, err := os.ReadFile(filepath.Join(target, ".terraform.lock.hcl")) + require.NoError(t, err) + assert.Equal(t, "instance-managed lock", string(actual)) +} + +func TestSourceRefreshRetainsBackupWhenRollbackFails(t *testing.T) { + stage, parent := t.TempDir(), t.TempDir() + target := filepath.Join(parent, "target") + refreshWrite(t, stage, "main.tf", "# new") + refreshWrite(t, target, "main.tf", "# previous") + rename := func(from, to string) error { + if from == filepath.Join(stage, sourceFilesManifest) { + require.NoError(t, os.Remove(filepath.Join(target, "main.tf"))) + refreshWrite(t, target, "main.tf/blocker", "simulated concurrent filesystem failure") + return errors.New("publication failed after source install") + } + return os.Rename(from, to) + } + err := publishSource(t.Context(), stage, target, nil, rename) + require.ErrorContains(t, err, "rollback journal retained") + backups, err := filepath.Glob(filepath.Join(parent, ".atmos-source-rollback-*")) + require.NoError(t, err) + require.Len(t, backups, 1) + previous, err := os.ReadFile(filepath.Join(backups[0], "main.tf")) + require.NoError(t, err) + assert.Equal(t, "# previous", string(previous)) +} + +// TestSafeSourceRelativeRejectsVolumeQualifiedNames covers manifest entries joined to the target. +// On Windows "C:state" addresses the "state" stream of file "C", so it must be rejected there; +// on Unix a colon is an ordinary filename character and stays accepted. +func TestSafeSourceRelativeRejectsVolumeQualifiedNames(t *testing.T) { + assert.True(t, safeSourceRelative("modules/main.tf")) + assert.True(t, safeSourceRelative("plugin..exe")) + assert.False(t, safeSourceRelative("../escape")) + assert.False(t, safeSourceRelative("/abs")) + assert.Equal(t, runtime.GOOS != "windows", safeSourceRelative("C:state")) + assert.Equal(t, runtime.GOOS != "windows", safeSourceRelative("dir/NUL")) +} diff --git a/pkg/provisioner/source/source.go b/pkg/provisioner/source/source.go index 59d2ec11f0e..32ae52175e5 100644 --- a/pkg/provisioner/source/source.go +++ b/pkg/provisioner/source/source.go @@ -76,6 +76,9 @@ func Provision(ctx context.Context, params *ProvisionParams) error { WithContext("stack", params.Stack). Err() } + if err := validateTargetOwner(target, params.Stack); err != nil { + return err + } targetDir := target.Dir // Check if vendoring is needed. @@ -94,12 +97,20 @@ func Provision(ctx context.Context, params *ProvisionParams) error { // Vendor the source with spinner feedback. progressMsg := fmt.Sprintf("Vendoring `%s` from `%s`", componentID, sourceSpec.Uri) completedMsg := fmt.Sprintf("Vendored `%s` to `%s`", componentID, targetDir) + var receipt downloader.ResolvedArtifact + options := []VendorSourceOption{WithArtifactReceipt(&receipt)} + if params.ComponentType == "terraform" { + options = append(options, WithRuntimePreservation(params.ComponentConfig), withProvenance(target, params.Stack, sourceSpec, &receipt)) + } err = spinner.ExecWithSpinner(progressMsg, completedMsg, func() error { - if err := VendorSource(ctx, params.AtmosConfig, sourceSpec, targetDir); err != nil { + if err := VendorSource(ctx, params.AtmosConfig, sourceSpec, targetDir, options...); err != nil { return err } // Record provenance so `source delete` can prove it owns this directory. - return recordProvenance(target, params.Stack, sourceSpec) + if params.ComponentType == "terraform" { + return nil + } + return recordProvenance(target, params.Stack, sourceSpec, &receipt) }) if err != nil { return provisionFailure(err, "Failed to vendor component source", map[string]string{ diff --git a/pkg/provisioner/source/state_probe.go b/pkg/provisioner/source/state_probe.go new file mode 100644 index 00000000000..157022028dc --- /dev/null +++ b/pkg/provisioner/source/state_probe.go @@ -0,0 +1,107 @@ +package source + +import ( + "encoding/json" + "errors" + "io" + "os" +) + +// isTerraformState recognizes custom runtime paths without imposing a size limit. +// Inspection I/O errors must stop publication rather than transfer ownership to source. +func isTerraformState(path string) (bool, error) { + info, err := os.Stat(path) + if err != nil { + return false, err + } + if !info.Mode().IsRegular() { + return false, nil + } + file, err := os.Open(path) + if err != nil { + return false, err + } + defer file.Close() + state, err := inspectStateMetadata(file) + var syntax *json.SyntaxError + if errors.As(err, &syntax) || errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) { + return false, nil // Ordinary source need not contain valid JSON. + } + return state, err +} + +// inspectStateMetadata reads only top-level identity fields. Nested resources are +// skipped token by token, and a recognized state header ends inspection immediately. +func inspectStateMetadata(reader io.Reader) (bool, error) { + decoder := json.NewDecoder(reader) + decoder.UseNumber() + first, err := decoder.Token() + if err != nil || first != json.Delim('{') { + return false, err + } + var header stateHeader + for decoder.More() { + key, err := decoder.Token() + if err != nil { + return false, err + } + value, err := decoder.Token() + if err != nil { + return false, err + } + if header.observe(key, value) { + return true, nil + } + if err := skipStateValue(decoder, value); err != nil { + return false, err + } + } + _, err = decoder.Token() + return false, err +} + +type stateHeader struct { + version, lineage, serial bool +} + +func (header *stateHeader) observe(key, value json.Token) bool { + switch key { + case "version": + number, valid := stateInteger(value) + header.version = valid && number > 0 + case "lineage": + text, ok := value.(string) + header.lineage = ok && text != "" + case "serial": + _, header.serial = stateInteger(value) + } + return header.version && header.lineage && header.serial +} + +func stateInteger(token json.Token) (int64, bool) { + number, ok := token.(json.Number) + if !ok { + return 0, false + } + value, err := number.Int64() + return value, err == nil +} + +func skipStateValue(decoder *json.Decoder, first json.Token) error { + if first != json.Delim('{') && first != json.Delim('[') { + return nil + } + for depth := 1; depth > 0; { + token, err := decoder.Token() + if err != nil { + return err + } + switch token { + case json.Delim('{'), json.Delim('['): + depth++ + case json.Delim('}'), json.Delim(']'): + depth-- + } + } + return nil +} diff --git a/pkg/provisioner/source/state_probe_test.go b/pkg/provisioner/source/state_probe_test.go new file mode 100644 index 00000000000..00fa1884054 --- /dev/null +++ b/pkg/provisioner/source/state_probe_test.go @@ -0,0 +1,149 @@ +package source + +import ( + "crypto/sha256" + "errors" + "io" + "os" + "path/filepath" + "strings" + "testing" + "testing/iotest" + + "github.com/stretchr/testify/require" + + "github.com/cloudposse/atmos/pkg/schema" +) + +func TestStateProbeStreamsTopLevelMetadata(t *testing.T) { + for _, tc := range []struct { + name, contents string + want bool + }{ + {"header first", `{"version":4,"lineage":"state","serial":0,"resources":[]}`, true}, + {"header last", `{"resources":[{"values":{"nested":[1,true,null,{"version":9}]}}],"serial":2,"lineage":"state","version":4}`, true}, + {"nested impostor", `{"resources":[{"version":4,"lineage":"nested","serial":2}]}`, false}, + {"invalid serial", `{"version":4,"lineage":"state","serial":"2"}`, false}, + {"ordinary source", `{"configuration":{"items":[{},[]]}}`, false}, + } { + t.Run(tc.name, func(t *testing.T) { + state, err := inspectStateMetadata(strings.NewReader(tc.contents)) + require.NoError(t, err) + require.Equal(t, tc.want, state) + }) + } + readFailure := errors.New("state reader unavailable") + state, err := inspectStateMetadata(io.MultiReader(strings.NewReader(`{"version":4,"lineage":"state","serial":2,`), iotest.ErrReader(readFailure))) + require.NoError(t, err, "recognized header must stop before reading resources") + require.True(t, state) + _, err = inspectStateMetadata(io.MultiReader(strings.NewReader(`{"resources":[`), iotest.ErrReader(readFailure))) + require.ErrorIs(t, err, readFailure) +} + +func writeLargeRefreshFile(t *testing.T, path string, state bool) { + t.Helper() + file, err := os.Create(path) + require.NoError(t, err) + if state { + _, err = io.WriteString(file, `{"version":4,"lineage":"large-runtime","serial":9,"resources":[`) + require.NoError(t, err) + } + // Whitespace makes the state valid while exceeding the former 64 MiB limit. + block := strings.Repeat(" ", 1024*1024) + for range 65 { + _, err = io.WriteString(file, block) + require.NoError(t, err) + } + if state { + _, err = io.WriteString(file, `]}`) + require.NoError(t, err) + } + require.NoError(t, file.Close()) +} + +func refreshFileDigest(t *testing.T, path string) []byte { + t.Helper() + file, err := os.Open(path) + require.NoError(t, err) + defer file.Close() + hash := sha256.New() + _, err = io.Copy(hash, file) + require.NoError(t, err) + return hash.Sum(nil) +} + +func TestSourceRefreshProtectsLargeCustomState(t *testing.T) { + for _, replace := range []bool{false, true} { + t.Run(map[bool]string{false: "delete", true: "replace"}[replace], func(t *testing.T) { + source, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, source, "custom.data", "source fixture") + refreshWrite(t, source, "main.tf", "# initial") + spec := &schema.VendorComponentSource{Uri: source} + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil))) + state := filepath.Join(target, "custom.data") + writeLargeRefreshFile(t, state, true) + before := refreshFileDigest(t, state) + inode, err := os.Stat(state) + require.NoError(t, err) + require.Greater(t, inode.Size(), int64(64*1024*1024)) + if !replace { + require.NoError(t, os.Remove(filepath.Join(source, "custom.data"))) + } + err = VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil)) + if replace { + require.ErrorContains(t, err, "collides with runtime artifact") + } else { + require.NoError(t, err) + } + after, err := os.Stat(state) + require.NoError(t, err) + require.True(t, os.SameFile(inode, after)) + require.Equal(t, before, refreshFileDigest(t, state)) + }) + } +} + +func TestSourceRefreshReplacesLargeNonStateSource(t *testing.T) { + source, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, source, "custom.data", "source fixture") + spec := &schema.VendorComponentSource{Uri: source} + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil))) + writeLargeRefreshFile(t, filepath.Join(target, "custom.data"), false) + refreshWrite(t, source, "custom.data", "updated source") + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil))) + content, err := os.ReadFile(filepath.Join(target, "custom.data")) + require.NoError(t, err) + require.Equal(t, "updated source", string(content)) +} + +func TestSourceRefreshRefusesUnreadableOwnedArtifact(t *testing.T) { + source, target := t.TempDir(), filepath.Join(t.TempDir(), "target") + refreshWrite(t, source, "custom.data", "source fixture") + spec := &schema.VendorComponentSource{Uri: source} + require.NoError(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil))) + path := filepath.Join(target, "custom.data") + refreshWrite(t, target, "custom.data", `{"version":4,"lineage":"state","serial":1}`) + before := refreshFileDigest(t, path) + require.NoError(t, os.Chmod(path, 0)) + t.Cleanup(func() { _ = os.Chmod(path, 0o600) }) + if file, err := os.Open(path); err == nil { + _ = file.Close() + t.Skip("host permissions allow reading mode-000 files") + } + require.NoError(t, os.Remove(filepath.Join(source, "custom.data"))) + require.ErrorContains(t, VendorSource(t.Context(), nil, spec, target, WithRuntimePreservation(nil)), "inspect runtime artifact") + require.NoError(t, os.Chmod(path, 0o600)) + require.Equal(t, before, refreshFileDigest(t, path)) +} + +func TestStateProbePropagatesHeaderReadErrors(t *testing.T) { + failure := errors.New("state file became unreadable") + for _, prefix := range []string{`{"vers`, `{"version":`} { + t.Run(prefix, func(t *testing.T) { + reader := io.MultiReader(strings.NewReader(prefix), iotest.ErrReader(failure)) + state, err := inspectStateMetadata(reader) + require.False(t, state) + require.ErrorIs(t, err, failure, "an I/O failure must not classify an owned artifact as ordinary source") + }) + } +} diff --git a/pkg/provisioner/source/target.go b/pkg/provisioner/source/target.go index ce1d1c88036..790fe7724ae 100644 --- a/pkg/provisioner/source/target.go +++ b/pkg/provisioner/source/target.go @@ -17,6 +17,10 @@ import ( // used by render/deploy/plan) and by the `source pull` / `source delete` commands, so the commands // always act on exactly the directory the runtime reads from. type Target struct { + // Instance is the stack component identity owning a source workdir. + Instance string + // EnforceOwner rejects reuse of an explicit workdir owned by another instance. + EnforceOwner bool // Dir is the absolute or base-path-relative destination directory. Dir string // IsWorkdir reports that Dir is an isolated per-instance workdir rather than a shared @@ -60,7 +64,23 @@ func ResolveTarget( if err != nil { return nil, err } - return &Target{Dir: dir, IsWorkdir: isWorkdir, Component: component}, nil + instance, _ := componentConfig["atmos_component"].(string) + if instance == "" { + instance = fallbackComponent + } + if instance == "" { + instance = component + } + enforceOwner, err := enforceSourceWorkdirOwner(atmosConfig, componentConfig, isWorkdir) + if err != nil { + return nil, err + } + target := &Target{Dir: dir, IsWorkdir: isWorkdir, Component: component, Instance: instance, EnforceOwner: enforceOwner} + stack, _ := componentConfig["atmos_stack"].(string) + if err := validateTargetOwner(target, stack); err != nil { + return nil, err + } + return target, nil } // validateComponentName rejects component names that cannot safely name a directory under the diff --git a/pkg/provisioner/source/target_test.go b/pkg/provisioner/source/target_test.go index 66f8cb8ac17..f0ccd6bf3c7 100644 --- a/pkg/provisioner/source/target_test.go +++ b/pkg/provisioner/source/target_test.go @@ -248,3 +248,26 @@ func TestProvision_FailureReportsSentinelOnce(t *testing.T) { }) } } + +func TestResolveTargetValidatesExplicitWorkdirOwner(t *testing.T) { + for _, owner := range []struct{ component, stack string }{{"instance", "dev"}, {"other", "dev"}, {"instance", "prod"}} { + t.Run(owner.component+"-"+owner.stack, func(t *testing.T) { + root := t.TempDir() + targetDir := filepath.Join(root, "custom") + require.NoError(t, workdir.WriteMetadata(targetDir, &workdir.WorkdirMetadata{Component: owner.component, Stack: owner.stack})) + section := map[string]any{ + "atmos_component": "instance", "atmos_stack": "dev", "component": "module", + "metadata": map[string]any{"working_directory": "custom"}, + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + } + target, err := ResolveTarget(&schema.AtmosConfiguration{BasePath: root}, "terraform", "instance", section) + if owner.component != "instance" || owner.stack != "dev" { + require.ErrorIs(t, err, errUtils.ErrWorkdirProvision) + require.Nil(t, target) + return + } + require.NoError(t, err) + require.Equal(t, targetDir, target.Dir) + }) + } +} diff --git a/pkg/provisioner/source/vendor.go b/pkg/provisioner/source/vendor.go index 5c26976d98b..d85a1a943d6 100644 --- a/pkg/provisioner/source/vendor.go +++ b/pkg/provisioner/source/vendor.go @@ -27,8 +27,12 @@ const ( type VendorSourceOption func(*vendorSourceOptions) type vendorSourceOptions struct { - replaceTarget bool - baseDir string + replaceTarget bool + baseDir string + preserveRuntime bool + componentConfig map[string]any + artifact *downloader.ResolvedArtifact + metadata func(string) error } // WithReplaceTarget controls whether VendorSource may replace an existing target directory. @@ -67,6 +71,13 @@ func VendorSource( option(&vendorOpts) } + if vendorOpts.preserveRuntime { + return vendorSourcePreserving(ctx, atmosConfig, sourceSpec, targetDir, vendorOpts) + } + return vendorSource(ctx, atmosConfig, sourceSpec, targetDir, vendorOpts) +} + +func vendorSource(ctx context.Context, atmosConfig *schema.AtmosConfiguration, sourceSpec *schema.VendorComponentSource, targetDir string, vendorOpts vendorSourceOptions) error { if sourceSpec == nil { return errUtils.Build(errUtils.ErrNilParam). WithExplanation("source specification cannot be nil"). @@ -102,147 +113,31 @@ func VendorSource( if localDir, ok, err := localDirectorySource(uri); err != nil { return err } else if ok { - return copySourceToTarget(localDir, targetDir, sourceSpec, vendorOpts) - } - - if !vendorOpts.replaceTarget { - if _, err := os.Stat(targetDir); err == nil { - return errUtils.Build(errUtils.ErrSourceCopyFailed). - WithExplanation("Target directory already exists"). - WithContext("target", targetDir). - WithHint("Remove the target directory or enable replacement before provisioning"). - Err() - } else if err != nil && !os.IsNotExist(err) { - return errUtils.Build(errUtils.ErrSourceCopyFailed). - WithCause(err). - WithExplanation("Failed to inspect target directory"). - WithContext("target", targetDir). - Err() - } else if targetPathBlockedByFile(targetDir) { - // os.Stat(targetDir) alone isn't enough: when an ancestor of targetDir is a - // regular file (not a directory), Unix reports ENOTDIR (distinct from - // ErrNotExist, caught above), but Windows reports the equivalent stat error - // as ErrNotExist, so it would otherwise fall through to a doomed download. - return errUtils.Build(errUtils.ErrSourceCopyFailed). - WithExplanation("Failed to inspect target directory"). - WithContext("target", targetDir). - WithHint("An ancestor of the target directory is a file, not a directory"). - Err() - } - } - - // Generate a unique temp path for the download staging area. - // - // We use os.MkdirTemp to reserve a unique name, then immediately remove the - // directory before passing the path to go-getter. This is necessary for - // file:// URIs: go-getter's FileGetter.Get creates a symlink at dst (rather - // than copying files), which requires dst to not already exist. If dst is - // a pre-created real directory, FileGetter returns "destination exists and is - // not a symlink". Removing the empty directory before the fetch lets FileGetter - // create the symlink; the subsequent vendor.CopyToTarget then copies through it. - // For remote sources, go-getter creates the directory itself when needed. - tempDir, err := os.MkdirTemp("", "atmos-source-*") - if err != nil { - return errUtils.Build(errUtils.ErrCreateTempDir). - WithCause(err). - WithExplanation("Failed to create temporary directory for download"). - Err() - } - // Remove the empty directory so go-getter can create it as a symlink (for - // file:// URIs) or recreate it as a real directory (for remote URIs). - if removeErr := os.Remove(tempDir); removeErr != nil && !os.IsNotExist(removeErr) { - return errUtils.Build(errUtils.ErrCreateTempDir). - WithCause(removeErr). - WithExplanation("Failed to prepare temporary directory for download"). - Err() - } - defer os.RemoveAll(tempDir) - - // Download the source into tempDir. OCI registries aren't a go-getter scheme - // (there is no getter.Getter implementation for them, and go-getter's model - // doesn't fit pulling registry layers), so oci:// sources go through pkg/oci - // directly; everything else still goes through go-getter. - if err := downloadSource(ctx, atmosConfig, sourceSpec, uri, tempDir); err != nil { - return err - } - - // Single-file downloads keep the component target as a directory. Handle - // them explicitly because go-getter stages local files as external symlinks, - // which the shared directory copier correctly refuses to follow. - if !vendor.IsOCIURI(uri) && !vendor.IsGitURI(uri) && !vendor.IsArchiveURI(uri) { - if singleFile, ok, err := singleFileInDir(tempDir); err != nil { + if err := copySourceToTarget(localDir, targetDir, sourceSpec, vendorOpts); err != nil { return err - } else if ok { - return copySingleFileToDirectory(singleFile, targetDir, sourceSpec, vendorOpts) - } - } - - // Ensure target parent directory exists. - if err := os.MkdirAll(filepath.Dir(targetDir), TargetDirPermissions); err != nil { - return errUtils.Build(errUtils.ErrSourceCopyFailed). - WithCause(err). - WithExplanation("Failed to create target parent directory"). - WithContext("target", targetDir). - Err() - } - - // Remove existing target directory if it exists and replacement is allowed. - if _, err := os.Stat(targetDir); err == nil { - if !vendorOpts.replaceTarget { - return errUtils.Build(errUtils.ErrSourceCopyFailed). - WithExplanation("Target directory already exists"). - WithContext("target", targetDir). - WithHint("Remove the target directory or enable replacement before provisioning"). - Err() - } - if err := os.RemoveAll(targetDir); err != nil { - return errUtils.Build(errUtils.ErrSourceCopyFailed). - WithCause(err). - WithExplanation("Failed to remove existing target directory"). - WithContext("target", targetDir). - Err() } - } else if err != nil && !os.IsNotExist(err) { - return errUtils.Build(errUtils.ErrSourceCopyFailed). - WithCause(err). - WithExplanation("Failed to inspect target directory"). - WithContext("target", targetDir). - Err() + return vendorOpts.captureArtifact(ctx, atmosConfig, uri, targetDir, downloader.FetchMetadata{}) } - // Copy from temp to target using the same code path as regular vendoring. - err = vendor.CopyToTarget(tempDir, targetDir, vendor.CopyOptions{ - IncludedPaths: sourceSpec.IncludedPaths, - ExcludedPaths: sourceSpec.ExcludedPaths, - }) - if err != nil { - return errUtils.Build(errUtils.ErrSourceCopyFailed). - WithCause(err). - WithExplanation("Failed to copy source to target directory"). - WithContext("source", tempDir). - WithContext("target", targetDir). - Err() - } - - return nil + return vendorRemoteSource(ctx, atmosConfig, sourceSpec, targetDir, vendorResolvedOptions{vendorSourceOptions: vendorOpts, uri: uri}) } -// downloadSource populates tempDir from uri through the shared go-getter downloader. OCI sources -// (oci://) need no special handling: the downloader registers an OCI getter alongside the other -// protocols. -func downloadSource(ctx context.Context, atmosConfig *schema.AtmosConfiguration, sourceSpec *schema.VendorComponentSource, uri, tempDir string) error { +// downloadSourceWithMetadata populates tempDir from uri through the shared go-getter downloader +// and returns its fetch receipt. OCI sources (oci://) need no special handling: the downloader +// registers an OCI getter alongside the other protocols. +func downloadSourceWithMetadata(ctx context.Context, atmosConfig *schema.AtmosConfiguration, sourceSpec *schema.VendorComponentSource, uri, tempDir string) (downloader.FetchMetadata, error) { downloadOpts := []downloader.GoGetterOption{downloader.WithRetryConfig(effectiveRetryConfig(sourceSpec))} dl := downloader.NewGoGetterDownloader(atmosConfig, downloadOpts...) - _, err := dl.(downloader.ContextFileDownloader).FetchWithMetadataContext(ctx, uri, tempDir, downloader.ClientModeAny, DefaultVendorTimeout) + metadata, err := dl.(downloader.ContextFileDownloader).FetchWithMetadataContext(ctx, uri, tempDir, downloader.ClientModeAny, DefaultVendorTimeout) if err != nil { - return errUtils.Build(errUtils.ErrSourceProvision). + return downloader.FetchMetadata{}, errUtils.Build(errUtils.ErrSourceProvision). WithCause(err). WithExplanation("Failed to download source"). WithContext("uri", uri). WithHint("Verify the source URI is accessible and credentials are configured"). Err() } - return nil + return metadata, nil } // Bounded default retry policy for source downloads that do not configure diff --git a/pkg/provisioner/source/vendor_directory_test.go b/pkg/provisioner/source/vendor_directory_test.go index 06414f47b30..b596069f6ae 100644 --- a/pkg/provisioner/source/vendor_directory_test.go +++ b/pkg/provisioner/source/vendor_directory_test.go @@ -77,7 +77,7 @@ func TestVendorToTarget_SingleFilePreservesDirectory(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = io.WriteString(w, template) })) defer server.Close() target := filepath.Join(t.TempDir(), "component") - require.NoError(t, vendorToTarget(context.Background(), &schema.AtmosConfiguration{}, &schema.VendorComponentSource{Uri: server.URL + "/template.yaml"}, vendorTarget{component: "example", path: target})) + require.NoError(t, vendorToTarget(context.Background(), &schema.AtmosConfiguration{}, &schema.VendorComponentSource{Uri: server.URL + "/template.yaml"}, &vendorTarget{component: "example", path: target})) require.DirExists(t, target) got, err := os.ReadFile(filepath.Join(target, "template.yaml")) require.NoError(t, err) diff --git a/pkg/provisioner/source/vendor_remote.go b/pkg/provisioner/source/vendor_remote.go new file mode 100644 index 00000000000..a23f452fc96 --- /dev/null +++ b/pkg/provisioner/source/vendor_remote.go @@ -0,0 +1,105 @@ +package source + +import ( + "context" + "os" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/schema" + "github.com/cloudposse/atmos/pkg/vendor" +) + +type vendorResolvedOptions struct { + vendorSourceOptions + uri string +} + +func vendorRemoteSource(ctx context.Context, atmosConfig *schema.AtmosConfiguration, sourceSpec *schema.VendorComponentSource, targetDir string, resolved vendorResolvedOptions) error { + vendorOpts, uri := resolved.vendorSourceOptions, resolved.uri + if err := inspectRemoteTarget(targetDir, vendorOpts); err != nil { + return err + } + + tempDir, err := reserveDownloadPath() + if err != nil { + return err + } + + defer os.RemoveAll(tempDir) + + // Download the source into tempDir. OCI registries aren't a go-getter scheme + // (there is no getter.Getter implementation for them, and go-getter's model + // doesn't fit pulling registry layers), so oci:// sources go through pkg/oci + // directly; everything else still goes through go-getter. + metadata, err := downloadSourceWithMetadata(ctx, atmosConfig, sourceSpec, uri, tempDir) + if err != nil { + return err + } + if err := vendorOpts.captureArtifact(ctx, atmosConfig, uri, tempDir, metadata); err != nil { + return err + } + + // Single-file downloads keep the component target as a directory. Handle + // them explicitly because go-getter stages local files as external symlinks, + // which the shared directory copier correctly refuses to follow. + if !vendor.IsOCIURI(uri) && !vendor.IsGitURI(uri) && !vendor.IsArchiveURI(uri) { + if singleFile, ok, err := singleFileInDir(tempDir); err != nil { + return err + } else if ok { + return copySingleFileToDirectory(singleFile, targetDir, sourceSpec, vendorOpts) + } + } + + return copySourceToTarget(tempDir, targetDir, sourceSpec, vendorOpts) +} + +func inspectRemoteTarget(targetDir string, vendorOpts vendorSourceOptions) error { + if !vendorOpts.replaceTarget { + if _, err := os.Stat(targetDir); err == nil { + return errUtils.Build(errUtils.ErrSourceCopyFailed). + WithExplanation("Target directory already exists"). + WithContext("target", targetDir). + WithHint("Remove the target directory or enable replacement before provisioning"). + Err() + } else if err != nil && !os.IsNotExist(err) { + return errUtils.Build(errUtils.ErrSourceCopyFailed). + WithCause(err). + WithExplanation("Failed to inspect target directory"). + WithContext("target", targetDir). + Err() + } else if targetPathBlockedByFile(targetDir) { + // os.Stat(targetDir) alone isn't enough: when an ancestor of targetDir is a + // regular file (not a directory), Unix reports ENOTDIR (distinct from + // ErrNotExist, caught above), but Windows reports the equivalent stat error + // as ErrNotExist, so it would otherwise fall through to a doomed download. + return errUtils.Build(errUtils.ErrSourceCopyFailed). + WithExplanation("Failed to inspect target directory"). + WithContext("target", targetDir). + WithHint("An ancestor of the target directory is a file, not a directory"). + Err() + } + } + + return nil +} + +// reserveDownloadPath reserves a unique name, leaving it absent so go-getter's +// local-file getter can create a symlink rather than rejecting a precreated directory. +func reserveDownloadPath() (string, error) { + tempDir, err := os.MkdirTemp("", "atmos-source-*") + if err != nil { + return "", errUtils.Build(errUtils.ErrCreateTempDir). + WithCause(err). + WithExplanation("Failed to create temporary directory for download"). + Err() + } + // Remove the empty directory so go-getter can create it as a symlink (for + // file:// URIs) or recreate it as a real directory (for remote URIs). + if removeErr := os.Remove(tempDir); removeErr != nil && !os.IsNotExist(removeErr) { + return "", errUtils.Build(errUtils.ErrCreateTempDir). + WithCause(removeErr). + WithExplanation("Failed to prepare temporary directory for download"). + Err() + } + return tempDir, nil +} diff --git a/pkg/provisioner/source/working_directory.go b/pkg/provisioner/source/working_directory.go new file mode 100644 index 00000000000..971a5a658e3 --- /dev/null +++ b/pkg/provisioner/source/working_directory.go @@ -0,0 +1,82 @@ +package source + +import ( + "fmt" + "os" + "path/filepath" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/edition" + "github.com/cloudposse/atmos/pkg/schema" +) + +const workingDirectoryPrecedence = "components.source.working_directory_precedence" + +func enforceSourceWorkdirOwner(config *schema.AtmosConfiguration, section map[string]any, isWorkdir bool) (bool, error) { + if !isWorkdir || getWorkingDirectoryOverride(section) == "" { + return false, nil + } + return edition.BehaviorChanged(config.Edition, workingDirectoryPrecedence) +} + +// sourceWorkdirOverride preserves edition-pinned placement and refuses an implicit migration. +func sourceWorkdirOverride(config *schema.AtmosConfiguration, section map[string]any, legacy string) (string, error) { + override := getWorkingDirectoryOverride(section) + if override == "" { + return legacy, nil + } + changed, err := edition.BehaviorChanged(config.Edition, workingDirectoryPrecedence) + if err != nil { + return "", err + } + if !changed { + return legacy, nil + } + if !filepath.IsAbs(override) { + override = filepath.Join(config.BasePath, override) + } + override, err = filepath.Abs(override) + if err != nil { + return "", fmt.Errorf("resolve source working_directory: %w", err) + } + old, err := filepath.Abs(legacy) + if err != nil { + return "", err + } + if override == old { + return override, nil + } + if err := checkSourceWorkdirMigration(old, override); err != nil { + return "", err + } + return override, nil +} + +// checkSourceWorkdirMigration prevents switching away from an existing runtime directory. +func checkSourceWorkdirMigration(old, override string) error { + // ReadDir on a regular file can report IsNotExist on Windows. Check the + // path itself first so existing caller data cannot be mistaken for absence. + info, err := os.Lstat(old) + if os.IsNotExist(err) { + return nil + } + if err != nil { + return fmt.Errorf("%w: inspect existing source workdir: %w", errUtils.ErrWorkdirProvision, err) + } + if !info.IsDir() { + return fmt.Errorf("%w: inspect existing source workdir: path is not a directory: %s", errUtils.ErrWorkdirProvision, old) + } + entries, err := os.ReadDir(old) + if err != nil && !os.IsNotExist(err) { + return fmt.Errorf("%w: inspect existing source workdir: %w", errUtils.ErrWorkdirProvision, err) + } + if len(entries) > 0 { + return errUtils.Build(errUtils.ErrWorkdirProvision). + WithExplanation("working_directory now takes precedence, but the previous workdir still contains files"). + WithContext("previous_workdir", old). + WithContext("requested_workdir", override). + WithHint("Keep an earlier edition pin to retain the previous path, or explicitly migrate the entire workdir and its Terraform state before removing the old directory. Atmos will not move or discard state automatically."). + Err() + } + return nil +} diff --git a/pkg/provisioner/source/working_directory_test.go b/pkg/provisioner/source/working_directory_test.go new file mode 100644 index 00000000000..a939365a22d --- /dev/null +++ b/pkg/provisioner/source/working_directory_test.go @@ -0,0 +1,96 @@ +package source + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/provisioner/workdir" + "github.com/cloudposse/atmos/pkg/schema" +) + +func TestSourceWorkingDirectoryPrecedenceEditions(t *testing.T) { + for _, field := range []string{"metadata", "settings"} { + for _, pin := range []string{"2026-10-27", "2026-10-28", "2026-11", "", "invalid"} { + t.Run(field+"/"+pin, func(t *testing.T) { + base := t.TempDir() + config := &schema.AtmosConfiguration{BasePath: base, Edition: pin} + section := map[string]any{ + "atmos_component": "nested/instance", "atmos_stack": "dev", + "component": "module", "source": "./source", + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + field: map[string]any{"working_directory": "custom/instance"}, + } + legacy, err := workdir.BuildPath(base, "terraform", "module", "dev", section) + require.NoError(t, err) + target, err := ResolveTarget(config, "terraform", "module", section) + if pin == "invalid" { + require.Error(t, err) + return + } + require.NoError(t, err) + require.True(t, target.IsWorkdir) + if pin == "2026-10-27" { + assert.Equal(t, legacy, target.Dir) + } else { + assert.Equal(t, filepath.Join(base, "custom", "instance"), target.Dir) + } + require.NoError(t, os.MkdirAll(legacy, 0o755)) + state := filepath.Join(legacy, "custom-state") + require.NoError(t, os.WriteFile(state, []byte("state must survive"), 0o600)) + _, err = ResolveTarget(config, "terraform", "module", section) + if pin == "2026-10-27" { + require.NoError(t, err) + } else { + require.ErrorIs(t, err, errUtils.ErrWorkdirProvision) + } + content, err := os.ReadFile(state) + require.NoError(t, err) + assert.Equal(t, "state must survive", string(content)) + }) + } + } +} + +func TestSourceWorkingDirectoryRetainsExplicitLegacyPath(t *testing.T) { + base := t.TempDir() + section := map[string]any{ + "component": "module", "atmos_component": "instance", "atmos_stack": "dev", + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + } + legacy, err := workdir.BuildPath(base, "terraform", "module", "dev", section) + require.NoError(t, err) + section["settings"] = map[string]any{"working_directory": legacy} + require.NoError(t, workdir.WriteMetadata(legacy, &workdir.WorkdirMetadata{Component: "instance", Stack: "dev"})) + refreshWrite(t, legacy, "terraform.tfstate", "preserved") + target, err := ResolveTarget(&schema.AtmosConfiguration{BasePath: base}, "terraform", "module", section) + require.NoError(t, err) + require.Equal(t, legacy, target.Dir, "an explicit existing path is not a migration") + contents, err := os.ReadFile(filepath.Join(legacy, "terraform.tfstate")) + require.NoError(t, err) + require.Equal(t, "preserved", string(contents)) +} + +func TestSourceWorkingDirectoryRefusesUninspectableLegacyPath(t *testing.T) { + base := t.TempDir() + section := map[string]any{ + "component": "module", "atmos_component": "instance", "atmos_stack": "dev", + "settings": map[string]any{"working_directory": "custom"}, + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + } + legacy, err := workdir.BuildPath(base, "terraform", "module", "dev", section) + require.NoError(t, err) + require.NoError(t, os.MkdirAll(filepath.Dir(legacy), 0o755)) + require.NoError(t, os.WriteFile(legacy, []byte("unexpected caller data"), 0o600)) + _, err = ResolveTarget(&schema.AtmosConfiguration{BasePath: base}, "terraform", "module", section) + require.ErrorIs(t, err, errUtils.ErrWorkdirProvision) + require.ErrorContains(t, err, "inspect existing source workdir") + require.NoDirExists(t, filepath.Join(base, "custom")) + contents, err := os.ReadFile(legacy) + require.NoError(t, err) + require.Equal(t, "unexpected caller data", string(contents)) +} diff --git a/pkg/scheduler/adapters/terraform.go b/pkg/scheduler/adapters/terraform.go index 73e4aa3bd59..0bb757ecc5a 100644 --- a/pkg/scheduler/adapters/terraform.go +++ b/pkg/scheduler/adapters/terraform.go @@ -1074,7 +1074,8 @@ func (d *TerraformDispatcher) runBeforeNodeHooks(ctx context.Context, nodeInfo * return wrapBeforeHookError(d.info.NodeHooks.Before(ctx, nodeInfo)) } -// wrapBeforeHookError labels a before-hook failure with ErrPerComponentHookFailed. +// wrapBeforeHookError labels a before-hook failure with ErrPerComponentHookFailed +// and marks its exit status as belonging to a prerequisite, not Terraform itself. // A policy admission error is returned unchanged: it is not a hook failure, and // the multi-%w wrap would hide the rule id and reason explanation the denial // carries from the error formatter. @@ -1082,7 +1083,7 @@ func wrapBeforeHookError(err error) error { if err == nil || policy.IsAdmissionError(err) { return err } - return fmt.Errorf("%w: %w", errUtils.ErrPerComponentHookFailed, err) + return fmt.Errorf("%w: %w", errUtils.ErrPerComponentHookFailed, errUtils.AsPrerequisiteError(err)) } // runAfterNodeHooks runs this node's after-event hooks, if wired, and returns @@ -1954,6 +1955,10 @@ func terraformPlanChangedError(info *schema.ConfigAndStacksInfo, err error) bool if info == nil || info.SubCommand != terraformSubCommandPlan { return false } + var prerequisiteErr *errUtils.PrerequisiteError + if errors.As(err, &prerequisiteErr) { + return false + } var exitCodeErr errUtils.ExitCodeError return errors.As(err, &exitCodeErr) && exitCodeErr.Code == 2 } diff --git a/pkg/scheduler/adapters/terraform_test.go b/pkg/scheduler/adapters/terraform_test.go index d4ecd0b3cb2..73f19739329 100644 --- a/pkg/scheduler/adapters/terraform_test.go +++ b/pkg/scheduler/adapters/terraform_test.go @@ -713,7 +713,7 @@ func TestExecuteTerraformInitUsesForwardDependencyOrder(t *testing.T) { func TestExecuteTerraformNodeHooksBeforeFailureAbortsNodeWithoutExecutor(t *testing.T) { stacks := terraformAdapterTestStacks() var executed []string - sentinelErr := errors.New("before hook failed") + sentinelErr := fmt.Errorf("before hook failed: %w", errUtils.ExitCodeError{Code: 2}) nodeHooks := &testNodeHooks{ beforeErr: map[string]error{"vpc@dev": sentinelErr}, } @@ -736,6 +736,11 @@ func TestExecuteTerraformNodeHooksBeforeFailureAbortsNodeWithoutExecutor(t *test require.Error(t, err) require.ErrorIs(t, err, errUtils.ErrPerComponentHookFailed) require.ErrorIs(t, err, sentinelErr) + var prerequisiteErr *errUtils.PrerequisiteError + require.ErrorAs(t, err, &prerequisiteErr) + require.ErrorIs(t, prerequisiteErr, sentinelErr) + require.Equal(t, 2, errUtils.GetExitCode(prerequisiteErr)) + require.Contains(t, nodeHooks.afterCalls, "vpc@dev", "after-hooks still receive the failed node outcome") require.NotContains(t, executed, "vpc@dev", "the executor must never run for a node whose before-hook failed") } @@ -2371,6 +2376,7 @@ func TestTerraformSummaryHelperBranches(t *testing.T) { require.False(t, terraformPlanChangedError(&schema.ConfigAndStacksInfo{SubCommand: "apply"}, errUtils.ExitCodeError{Code: 2})) require.False(t, terraformPlanChangedError(&schema.ConfigAndStacksInfo{SubCommand: "plan"}, errors.New("failed"))) require.True(t, terraformPlanChangedError(&schema.ConfigAndStacksInfo{SubCommand: "plan"}, errUtils.ExitCodeError{Code: 2})) + require.False(t, terraformPlanChangedError(&schema.ConfigAndStacksInfo{SubCommand: "plan"}, errUtils.AsPrerequisiteError(errUtils.ExitCodeError{Code: 2}))) require.Equal(t, 0, processedCount(nil)) require.Equal(t, 1, processedCount(&scheduler.AggregateResult{Results: []scheduler.Result{{Value: true}}})) diff --git a/pkg/store/authbridge/resolver_scoped_test.go b/pkg/store/authbridge/resolver_scoped_test.go index a64c59cc705..4cd57c2b844 100644 --- a/pkg/store/authbridge/resolver_scoped_test.go +++ b/pkg/store/authbridge/resolver_scoped_test.go @@ -40,7 +40,8 @@ func TestScopedResolverKeepsIdentityOwnership(t *testing.T) { err := operation(ctx, tt.auth) events = append(events, "released") return errors.Join(err, tt.cleanupError) - }) + }, + ) resolver := NewResolver(manager, &schema.ConfigAndStacksInfo{}) err := resolver.WithEnvironmentAuthContext(t.Context(), "reader", func(ctx context.Context, auth *store.EnvironmentAuthConfig) error { events = append(events, "operation") diff --git a/pkg/store/providers/hashicorp_vault_lifetime_test.go b/pkg/store/providers/hashicorp_vault_lifetime_test.go index f481ea77a36..b6c503b48ab 100644 --- a/pkg/store/providers/hashicorp_vault_lifetime_test.go +++ b/pkg/store/providers/hashicorp_vault_lifetime_test.go @@ -25,7 +25,8 @@ func scopedVault(t *testing.T, cleanup error) (*VaultStore, *fakeVaultKV, *int) err := operation(ctx, &store.EnvironmentAuthConfig{Environment: map[string]string{"VAULT_TOKEN": "synthetic-identity"}}) *releases++ return errors.Join(err, cleanup) - }).AnyTimes() + }, + ).AnyTimes() s.SetAuthContext(resolver, "openbao") return s, fake, releases } @@ -130,7 +131,8 @@ func TestVaultOperationLifetimeRejectsMissingCredentials(t *testing.T) { return operation(ctx, nil) } return operation(ctx, &store.EnvironmentAuthConfig{Environment: environment}) - }) + }, + ) s.SetAuthContext(resolver, "openbao") value, err := s.GetKey("key") require.ErrorIs(t, err, store.ErrAuthContextNotAvailable) diff --git a/pkg/terraform/autoinit/diagnostics.go b/pkg/terraform/autoinit/diagnostics.go index b30731848f2..4be929000d7 100644 --- a/pkg/terraform/autoinit/diagnostics.go +++ b/pkg/terraform/autoinit/diagnostics.go @@ -39,6 +39,8 @@ var signatures = []signature{ {`Backend initialization required, please run "terraform init"`, Diagnosis{InitRequired: true}}, {`Backend initialization required, please run "tofu init"`, Diagnosis{InitRequired: true}}, {"Required plugins are not installed", Diagnosis{InitRequired: true}}, + {"run tofu init to ensure all providers are correctly", Diagnosis{InitRequired: true}}, + {"run terraform init to ensure all providers are correctly", Diagnosis{InitRequired: true}}, {"Inconsistent dependency lock file", Diagnosis{InitRequired: true}}, {"Module not installed", Diagnosis{InitRequired: true}}, {"Module source has changed", Diagnosis{InitRequired: true}}, diff --git a/pkg/terraform/autoinit/fingerprint.go b/pkg/terraform/autoinit/fingerprint.go index cfcbec32223..e3ea8fe1fdc 100644 --- a/pkg/terraform/autoinit/fingerprint.go +++ b/pkg/terraform/autoinit/fingerprint.go @@ -15,6 +15,7 @@ import ( "github.com/cloudposse/atmos/pkg/perf" "github.com/cloudposse/atmos/pkg/terraform/clean" "github.com/cloudposse/atmos/pkg/terraform/lockfile" + "github.com/cloudposse/atmos/pkg/terraform/rc" ) // Environment variable names read while computing a fingerprint. @@ -294,7 +295,7 @@ func cliConfigRecord(lookup func(key string) (string, bool)) string { log.Debug("autoinit: cli config file not readable, excluding from fingerprint", "path", path, "error", err) continue } - parts = append(parts, fmt.Sprintf("%s:%s", key, string(content))) + parts = append(parts, fmt.Sprintf("%s:%s", key, rc.FingerprintContent(path, content))) } if len(parts) == 0 { return "" diff --git a/pkg/terraform/autoinit/preconditions.go b/pkg/terraform/autoinit/preconditions.go index 06569c4d36d..70fe9488730 100644 --- a/pkg/terraform/autoinit/preconditions.go +++ b/pkg/terraform/autoinit/preconditions.go @@ -5,24 +5,126 @@ import ( "os" "path/filepath" "regexp" + "runtime" + "strings" "github.com/cloudposse/atmos/pkg/terraform/clean" "github.com/cloudposse/atmos/pkg/terraform/lockfile" ) +const providerExecutablePerm = 0o111 + // moduleHCLPattern matches an HCL `module "..."` block header. var moduleHCLPattern = regexp.MustCompile(`(?m)^\s*module\s+"`) -// providersMissing reports whether the lock file declares at least one provider dependency but -// neither the terraform-managed provider cache nor the legacy plugins directory has been -// populated under dataDir -- i.e. `terraform init` has never successfully installed providers for -// this data directory. +// providersMissing checks the locked provider packages for the current platform. A directory +// alone is insufficient: an interrupted cleanup or an evicted shared cache can leave an empty +// package or a dangling symlink. Stat follows package/executable symlinks without hashing packages +// on every warm invocation; Terraform remains responsible for checksum verification. func providersMissing(dataDir, componentPath string) bool { providers, err := lockfile.ParseFile(filepath.Join(componentPath, lockfile.Name)) if err != nil || len(providers) == 0 { return false } - return !dirExists(filepath.Join(dataDir, "providers")) && !dirExists(filepath.Join(dataDir, "plugins")) + for _, provider := range providers { + if !providerInstalled(dataDir, provider) { + return true + } + } + return false +} + +// providerInstalled accepts the current registry layout and the legacy platform plugin layout. +func providerInstalled(dataDir string, provider lockfile.Provider) bool { + parts := strings.Split(provider.Source, "/") + if len(parts) != 3 || provider.Version == "" { + return false + } + prefix := "terraform-provider-" + parts[2] + "_v" + provider.Version + dirs := providerPackageDirs(dataDir, provider) + for i, dir := range dirs { + if providerExecutablePresent(dir, prefix, i < 2) { + return true + } + } + // The engine may run under architecture emulation. A valid same-OS package must not + // force perpetual init solely because Atmos itself has a different architecture. If the + // engine cannot use that package, its diagnostic still triggers bounded runtime recovery. + return alternativeProviderInstalled(dataDir, provider, prefix) +} + +func alternativeProviderInstalled(dataDir string, provider lockfile.Provider, prefix string) bool { + for _, dir := range alternateProviderPackageDirs(dataDir, provider) { + if providerExecutablePresent(dir, prefix, true) { + return true + } + } + return false +} + +func alternateProviderPackageDirs(dataDir string, provider lockfile.Provider) []string { + native := providerPackageDirs(dataDir, provider) + if len(native) == 0 { + return nil + } + var dirs []string + for _, path := range native[:2] { + parent := filepath.Dir(path) + entries, err := os.ReadDir(parent) + if err != nil { + continue + } + for _, entry := range entries { + if entry.Name() != filepath.Base(path) && strings.HasPrefix(entry.Name(), runtime.GOOS+"_") && !strings.HasSuffix(entry.Name(), ".lock") { + dirs = append(dirs, filepath.Join(parent, entry.Name())) + } + } + } + return dirs +} + +func providerPackageDirs(dataDir string, provider lockfile.Provider) []string { + parts := strings.Split(provider.Source, "/") + if len(parts) != 3 { + return nil + } + for _, part := range append(parts, provider.Version) { + if part == "" || part == "." || part == ".." || !filepath.IsLocal(part) || strings.ContainsAny(part, `/\\`) { + return nil + } + } + platform := runtime.GOOS + "_" + runtime.GOARCH + return []string{ + filepath.Join(dataDir, "providers", filepath.FromSlash(provider.Source), provider.Version, platform), + filepath.Join(dataDir, "plugins", filepath.FromSlash(provider.Source), provider.Version, platform), + filepath.Join(dataDir, "plugins", platform), + } +} + +func providerExecutablePresent(dir, prefix string, versionInPath bool) bool { + entries, err := os.ReadDir(dir) + if err != nil { + return false + } + for _, entry := range entries { + if !providerExecutableNameMatches(entry.Name(), prefix, versionInPath) { + continue + } + info, statErr := os.Stat(filepath.Join(dir, entry.Name())) + if statErr == nil && info.Mode().IsRegular() && (runtime.GOOS == "windows" || info.Mode().Perm()&providerExecutablePerm != 0) { + return true + } + } + return false +} + +func providerExecutableNameMatches(name, prefix string, versionInPath bool) bool { + base, _, _ := strings.Cut(prefix, "_v") + if versionInPath && (name == base || name == base+".exe") { + return true + } + suffix, matches := strings.CutPrefix(name, prefix) + return matches && (suffix == "" || suffix == ".exe" || strings.HasPrefix(suffix, "_")) } // modulesMissing reports whether the component declares module blocks but dataDir has no modules diff --git a/pkg/terraform/autoinit/preconditions_test.go b/pkg/terraform/autoinit/preconditions_test.go index d472d74ab6d..424901bc675 100644 --- a/pkg/terraform/autoinit/preconditions_test.go +++ b/pkg/terraform/autoinit/preconditions_test.go @@ -35,16 +35,16 @@ func TestProvidersMissing(t *testing.T) { want: true, }, { - name: "lock has providers, providers dir exists", + name: "lock has providers, empty providers dir", lockContent: validLockFile, makeDirs: []string{"providers"}, - want: false, + want: true, }, { - name: "lock has providers, plugins dir exists", + name: "lock has providers, empty plugins dir", lockContent: validLockFile, makeDirs: []string{"plugins"}, - want: false, + want: true, }, { name: "lock has zero providers", diff --git a/pkg/terraform/autoinit/provider_architecture_test.go b/pkg/terraform/autoinit/provider_architecture_test.go new file mode 100644 index 00000000000..8588a3d53e9 --- /dev/null +++ b/pkg/terraform/autoinit/provider_architecture_test.go @@ -0,0 +1,71 @@ +package autoinit + +import ( + "errors" + "os" + "path/filepath" + "runtime" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cloudposse/atmos/pkg/terraform/lockfile" +) + +func TestAlternateArchitectureKeepsWarmInitAndBoundedRecovery(t *testing.T) { + dir := t.TempDir() + data := filepath.Join(dir, ".terraform") + require.NoError(t, os.WriteFile(filepath.Join(dir, lockfile.Name), []byte(validLockFile), 0o600)) + provider := lockfile.Provider{Source: "registry.terraform.io/hashicorp/null", Version: "3.2.1"} + native := providerPackageDirs(data, provider)[0] + arch := "amd64" + if runtime.GOARCH == arch { + arch = "arm64" + } + alternate := filepath.Join(filepath.Dir(native), runtime.GOOS+"_"+arch) + require.NoError(t, os.MkdirAll(alternate, 0o755)) + executable := filepath.Join(alternate, "terraform-provider-null_v3.2.1_x5") + require.NoError(t, os.WriteFile(executable, []byte("alternate package"), 0o755)) + in := &Inputs{ComponentPath: dir, DataDir: data, Binary: testBinary()} + require.NoError(t, Record(in, []string{"init"}, "test")) + assert.False(t, Decide(&Request{Inputs: in}).RunInit, "an emulated engine's valid package must not cause repeated init") + // A native engine still diagnoses its missing package, and gets one init/retry. + require.NoError(t, os.MkdirAll(native, 0o755)) + assert.False(t, Decide(&Request{Inputs: in}).RunInit) + initCalls, retries := 0, 0 + failure := errors.New("provider installation failed") + err := Recover(RecoverParams{Err: failure, Output: "Required plugins are not installed", RunInit: func(Recovery) error { + initCalls++ + _, err := PrepareProviderInstallation(in) + return err + }, Retry: func() error { retries++; return failure }}) + require.ErrorIs(t, err, failure) + assert.Equal(t, 1, initCalls) + assert.Equal(t, 1, retries) + content, err := os.ReadFile(executable) + require.NoError(t, err) + assert.Equal(t, "alternate package", string(content)) + _, err = os.Stat(native) + assert.True(t, os.IsNotExist(err), "incomplete native package is preserved aside before retry") +} + +func TestProviderPreparationLeavesIrrelevantAlternatePackages(t *testing.T) { + dir := t.TempDir() + data := filepath.Join(dir, ".terraform") + require.NoError(t, os.WriteFile(filepath.Join(dir, lockfile.Name), []byte(validLockFile), 0o600)) + provider := lockfile.Provider{Source: "registry.terraform.io/hashicorp/null", Version: "3.2.1"} + native := providerPackageDirs(data, provider)[0] + require.NoError(t, os.MkdirAll(native, 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(native, "terraform-provider-null"), []byte("valid native package"), 0o755)) + alternate := filepath.Join(filepath.Dir(native), runtime.GOOS+"_other") + require.NoError(t, os.MkdirAll(alternate, 0o755)) + sentinel := filepath.Join(alternate, "LICENSE") + require.NoError(t, os.WriteFile(sentinel, []byte("preserve"), 0o600)) + cache, err := PrepareProviderInstallation(&Inputs{ComponentPath: dir, DataDir: data}) + require.NoError(t, err) + assert.Empty(t, cache) + content, err := os.ReadFile(sentinel) + require.NoError(t, err) + assert.Equal(t, "preserve", string(content)) +} diff --git a/pkg/terraform/autoinit/provider_installation_test.go b/pkg/terraform/autoinit/provider_installation_test.go new file mode 100644 index 00000000000..4c3bd0c5211 --- /dev/null +++ b/pkg/terraform/autoinit/provider_installation_test.go @@ -0,0 +1,104 @@ +package autoinit + +import ( + "os" + "path/filepath" + "runtime" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestProvidersMissingSelectedInstallation(t *testing.T) { + for _, tc := range []struct { + name, layout, damage string + missing bool + }{ + {"complete", "providers", "", false}, + {"unversioned executable in versioned package", "providers", "unversioned", false}, + {"empty package", "providers", "missing", true}, + {"wrong version", "providers", "version", true}, + {"other platform", "providers", "platform", true}, + {"directory named executable", "providers", "directory", true}, + {"broken executable symlink", "providers", "symlink", true}, + {"valid executable symlink", "providers", "valid-symlink", false}, + {"broken package symlink", "providers", "package-symlink", true}, + {"nonexecutable file", "providers", "nonexecutable", true}, + {"legacy complete", "plugins", "", false}, + {"legacy empty", "plugins", "missing", true}, + } { + t.Run(tc.name, func(t *testing.T) { + dir := t.TempDir() + data := filepath.Join(t.TempDir(), "custom-data") + require.NoError(t, os.WriteFile(filepath.Join(dir, ".terraform.lock.hcl"), []byte(validLockFile), 0o600)) + version := "3.2.1" + platform := runtime.GOOS + "_" + runtime.GOARCH + if tc.damage == "version" { + version = "3.2.10" + } + if tc.damage == "platform" { + platform = "other_arch" + } + installed := filepath.Join(data, tc.layout, "registry.terraform.io", "hashicorp", "null", version, platform) + if tc.layout == "plugins" { + installed = filepath.Join(data, tc.layout, platform) + } + require.NoError(t, os.MkdirAll(installed, 0o755)) + name := "terraform-provider-null_v" + version + "_x5" + if tc.damage == "unversioned" { + name = "terraform-provider-null" + } + if runtime.GOOS == "windows" { + name += ".exe" + } + executable := filepath.Join(installed, name) + switch tc.damage { + case "missing": + case "directory": + require.NoError(t, os.Mkdir(executable, 0o755)) + case "package-symlink": + if runtime.GOOS == "windows" { + t.Skip("symlink creation requires additional Windows privileges") + } + require.NoError(t, os.Remove(installed)) + require.NoError(t, os.Symlink(filepath.Join(t.TempDir(), "missing"), installed)) + case "valid-symlink": + if runtime.GOOS == "windows" { + t.Skip("symlink creation requires additional Windows privileges") + } + target := filepath.Join(t.TempDir(), "provider") + require.NoError(t, os.WriteFile(target, []byte("provider"), 0o755)) + require.NoError(t, os.Symlink(target, executable)) + case "nonexecutable": + if runtime.GOOS == "windows" { + t.Skip("Windows does not use POSIX executable permissions") + } + require.NoError(t, os.WriteFile(executable, []byte("provider"), 0o644)) + case "symlink": + if runtime.GOOS == "windows" { + t.Skip("symlink creation requires additional Windows privileges") + } + require.NoError(t, os.Symlink(filepath.Join(t.TempDir(), "missing"), executable)) + default: + require.NoError(t, os.WriteFile(executable, []byte("provider"), 0o755)) + } + assert.Equal(t, tc.missing, providersMissing(data, dir)) + }) + } +} + +func TestProviderInstallDiagnosticDoesNotUpgrade(t *testing.T) { + for _, output := range []string{ + "cached package does not match any of the checksums recorded in the dependency lock file, run tofu init to ensure all providers are correctly installed.", + "cached package does not match any of the checksums recorded in the dependency lock file, run terraform init to ensure all providers are correctly installed.", + } { + diagnosis := Classify(output) + assert.True(t, diagnosis.InitRequired) + assert.False(t, diagnosis.UpgradeRequired) + assert.False(t, diagnosis.ReconfigureRequired) + } + for _, output := range []string{"Failed to load plugin schemas: permission denied", "provider startup: connection refused", "Error acquiring the state lock", "AccessDenied: expired credentials"} { + assert.False(t, Classify(output).InitRequired) + } +} diff --git a/pkg/terraform/autoinit/provider_links.go b/pkg/terraform/autoinit/provider_links.go new file mode 100644 index 00000000000..1a70aa558e7 --- /dev/null +++ b/pkg/terraform/autoinit/provider_links.go @@ -0,0 +1,174 @@ +package autoinit + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + errUtils "github.com/cloudposse/atmos/errors" + log "github.com/cloudposse/atmos/pkg/logger" + "github.com/cloudposse/atmos/pkg/perf" + "github.com/cloudposse/atmos/pkg/terraform/lockfile" +) + +const providerRecoveryDirPerm = 0o700 + +// PrepareProviderInstallation preserves incomplete local packages, removes unusable links, and selects a component-local +// recovery cache when a shared package is incomplete. It never deletes shared package contents: +// Terraform refuses to reinstall over dangling links or import a cache package without a binary. +// Call only after policy permits init; nil inputs (dry run) are a no-op. Invalid lockfiles remain +// the engine's responsibility. The returned cache persists with the data directory so provider +// links created by init remain usable on subsequent warm commands. +func PrepareProviderInstallation(in *Inputs) (string, error) { + defer perf.Track(nil, "autoinit.PrepareProviderInstallation")() + + if in == nil { + return "", nil + } + providers, err := lockfile.ParseFile(filepath.Join(in.ComponentPath, lockfile.Name)) + if err != nil { + return "", nil + } + recovery := false + for _, provider := range providers { + needed, err := prepareProviderLinks(in, provider) + if err != nil { + return "", err + } + recovery = recovery || needed + } + if !recovery { + return "", nil + } + path := filepath.Join(in.effectiveDataDir(), "atmos-provider-recovery") + if err := os.MkdirAll(path, providerRecoveryDirPerm); err != nil { + return "", fmt.Errorf("%w: creating provider recovery cache: %w", errUtils.ErrTerraformInit, err) + } + entry, err := os.Lstat(path) + if err != nil { + return "", fmt.Errorf("%w: inspecting provider recovery cache: %w", errUtils.ErrTerraformInit, err) + } + if entry.Mode()&os.ModeSymlink != 0 { + return "", fmt.Errorf("%w: provider recovery directory must not be a symlink: %s", errUtils.ErrTerraformInit, path) + } + return path, nil +} + +func providerRepairDirs(dataDir string, provider lockfile.Provider) ([]string, string) { + parts := strings.Split(provider.Source, "/") + if len(parts) != 3 { + return nil, "" + } + prefix := "terraform-provider-" + parts[2] + "_v" + provider.Version + dirs := providerPackageDirs(dataDir, provider) + if len(dirs) == 0 { + return nil, "" + } + for i, path := range dirs { + if providerExecutablePresent(path, prefix, i < 2) { + return nil, "" + } + } + // Never move aggregate legacy plugin directories. Leave alternate installations alone + // when one already suffices; native engine diagnostics may still require repairing a + // partial native package before the runtime retry. + dirs = dirs[:2] + if !alternativeProviderInstalled(dataDir, provider, prefix) { + dirs = append(dirs, alternateProviderPackageDirs(dataDir, provider)...) + } + return dirs, prefix +} + +func prepareProviderLinks(in *Inputs, provider lockfile.Provider) (bool, error) { + dirs, prefix := providerRepairDirs(in.effectiveDataDir(), provider) + if len(dirs) == 0 { + return false, nil + } + recovery := false + for _, path := range dirs { + needed, err := prepareLocalPackage(in.effectiveDataDir(), path, prefix, true) + if err != nil { + return false, err + } + recovery = recovery || needed + } + + if cacheDir := envLookup(in.EnvLookup, envTFPluginCacheDir); cacheDir != "" { + dirs := providerPackageDirs(cacheDir, provider) + if len(dirs) > 0 { + // A shared cache has the registry layout directly under its root, without "providers". + packagePath := filepath.Join(cacheDir, filepath.FromSlash(provider.Source), provider.Version, filepath.Base(dirs[0])) + if dirExists(packagePath) && !providerExecutablePresent(packagePath, prefix, true) { + recovery = true + } + } + } + return recovery, nil +} + +// prepareLocalPackage returns whether init must bypass a shared package missing its executable. +func prepareLocalPackage(dataDir, path, prefix string, versionInPath bool) (bool, error) { + info, err := os.Lstat(path) + if os.IsNotExist(err) { + return false, nil + } + if err != nil { + return false, fmt.Errorf("%w: inspecting provider package %s: %w", errUtils.ErrTerraformInit, path, err) + } + if providerExecutablePresent(path, prefix, versionInPath) { + return false, nil + } + if !packageReadableOrMissing(path) { + return false, nil // An unreadable package is not evidence that its contents are missing. + } + if info.IsDir() && versionInPath { + return false, preserveIncompletePackage(dataDir, path) + } + if info.Mode()&os.ModeSymlink == 0 { + return false, nil + } + sharedPackageExists := dirExists(path) + // Unlink only the local installation reference; its target can belong to another component. + if err = os.Remove(path); err != nil && !os.IsNotExist(err) { + return false, fmt.Errorf("%w: removing unusable provider package link %s: %w", errUtils.ErrTerraformInit, path, err) + } + return sharedPackageExists, nil +} + +// preserveIncompletePackage moves an owned, incomplete package aside for OpenTofu, which otherwise +// refuses to replace it as locally modified. Resolve ancestors before moving anything: a provider +// directory reached through a shared-cache symlink belongs to that cache, not this component. +func preserveIncompletePackage(dataDir, packagePath string) error { + if !ownedProviderPackage(dataDir, packagePath) { + return nil + } + quarantine, err := os.MkdirTemp(dataDir, "atmos-incomplete-provider-") + if err != nil { + return fmt.Errorf("%w: preserving incomplete provider package: %w", errUtils.ErrTerraformInit, err) + } + if err := os.Rename(packagePath, filepath.Join(quarantine, "package")); err != nil { + _ = os.Remove(quarantine) + return fmt.Errorf("%w: preserving incomplete provider package: %w", errUtils.ErrTerraformInit, err) + } + log.Debug("Preserved incomplete provider installation before init", "path", packagePath, "quarantine", quarantine) + return nil +} + +func ownedProviderPackage(dataDir, packagePath string) bool { + root, rootErr := filepath.EvalSymlinks(dataDir) + resolved, pathErr := filepath.EvalSymlinks(packagePath) + if rootErr != nil || pathErr != nil { + return false + } + rel, err := filepath.Rel(root, resolved) + if err != nil || rel == ".." || filepath.IsAbs(rel) || strings.HasPrefix(rel, ".."+string(filepath.Separator)) { + return false + } + return true +} + +func packageReadableOrMissing(path string) bool { + _, err := os.ReadDir(path) + return err == nil || os.IsNotExist(err) +} diff --git a/pkg/terraform/autoinit/provider_links_test.go b/pkg/terraform/autoinit/provider_links_test.go new file mode 100644 index 00000000000..99525aa9f92 --- /dev/null +++ b/pkg/terraform/autoinit/provider_links_test.go @@ -0,0 +1,294 @@ +package autoinit + +import ( + "os" + "path/filepath" + "runtime" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/terraform/lockfile" +) + +func TestPrepareProviderInstallation(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("symlink creation requires additional Windows privileges") + } + for _, kind := range []string{"dangling", "live", "directory", "other-version"} { + t.Run(kind, func(t *testing.T) { + componentPath := t.TempDir() + data := filepath.Join(t.TempDir(), "custom-data") + require.NoError(t, os.WriteFile(filepath.Join(componentPath, lockfile.Name), []byte(validLockFile), 0o600)) + version := "3.2.1" + if kind == "other-version" { + version = "3.2.0" + } + packagePath := filepath.Join(data, "providers", "registry.terraform.io", "hashicorp", "null", version, runtime.GOOS+"_"+runtime.GOARCH) + require.NoError(t, os.MkdirAll(filepath.Dir(packagePath), 0o755)) + target := filepath.Join(t.TempDir(), "target") + if kind == "directory" { + require.NoError(t, os.Mkdir(packagePath, 0o755)) + } else { + if kind == "live" { + require.NoError(t, os.Mkdir(target, 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(target, "sentinel"), []byte("preserve"), 0o600)) + require.NoError(t, os.WriteFile(filepath.Join(target, "terraform-provider-null_v3.2.1_x5"), []byte("provider"), 0o755)) + } + require.NoError(t, os.Symlink(target, packagePath)) + } + in := &Inputs{ComponentPath: componentPath, DataDir: data} + _, err := PrepareProviderInstallation(in) + require.NoError(t, err) + _, err = PrepareProviderInstallation(in) + require.NoError(t, err) + _, err = os.Lstat(packagePath) + if kind == "dangling" || kind == "directory" { + assert.True(t, os.IsNotExist(err)) + } else { + require.NoError(t, err) + } + if kind == "live" { + b, e := os.ReadFile(filepath.Join(target, "sentinel")) + require.NoError(t, e) + assert.Equal(t, "preserve", string(b)) + } + }) + } + _, err := PrepareProviderInstallation(nil) + require.NoError(t, err) + _, err = PrepareProviderInstallation(&Inputs{ComponentPath: t.TempDir()}) + require.NoError(t, err) +} + +func TestProviderPackageDirsRejectTraversal(t *testing.T) { + for _, provider := range []lockfile.Provider{ + {Source: "../hashicorp/null", Version: "1.0"}, + {Source: "registry.example.com/hashicorp/null", Version: "../../elsewhere"}, + {Source: "registry.example.com/hashicorp/null", Version: `..\elsewhere`}, + {Source: "registry.example.com/hashicorp", Version: "1.0"}, + {Source: "registry.example.com//null", Version: "1.0"}, + } { + assert.Empty(t, providerPackageDirs(t.TempDir(), provider)) + assert.False(t, providerInstalled(t.TempDir(), provider)) + } +} + +func TestPrepareProviderInstallationPreservesIncompleteSharedPackage(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("symlink creation requires additional Windows privileges") + } + componentPath := t.TempDir() + data := filepath.Join(componentPath, ".terraform") + cache := t.TempDir() + require.NoError(t, os.WriteFile(filepath.Join(componentPath, lockfile.Name), []byte(validLockFile), 0o600)) + relative := filepath.Join("registry.terraform.io", "hashicorp", "null", "3.2.1", runtime.GOOS+"_"+runtime.GOARCH) + shared := filepath.Join(cache, relative) + local := filepath.Join(data, "providers", relative) + require.NoError(t, os.MkdirAll(shared, 0o755)) + require.NoError(t, os.MkdirAll(filepath.Dir(local), 0o755)) + sentinel := filepath.Join(shared, "LICENSE") + require.NoError(t, os.WriteFile(sentinel, []byte("preserved"), 0o600)) + require.NoError(t, os.Symlink(shared, local)) + in := &Inputs{ComponentPath: componentPath, DataDir: data, EnvLookup: func(key string) (string, bool) { return cache, key == envTFPluginCacheDir }} + recovery, err := PrepareProviderInstallation(in) + require.NoError(t, err) + assert.Equal(t, filepath.Join(data, "atmos-provider-recovery"), recovery) + _, err = os.Lstat(local) + assert.True(t, os.IsNotExist(err)) + content, err := os.ReadFile(sentinel) + require.NoError(t, err) + assert.Equal(t, "preserved", string(content)) + // A second attempt still bypasses the unchanged broken shared package even after unlinking it. + again, err := PrepareProviderInstallation(in) + require.NoError(t, err) + assert.Equal(t, recovery, again) +} + +func TestPreserveIncompletePackageOwnership(t *testing.T) { + data := t.TempDir() + local := filepath.Join(data, "providers", "partial") + require.NoError(t, os.MkdirAll(local, 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(local, "LICENSE"), []byte("preserve exact content"), 0o600)) + require.NoError(t, preserveIncompletePackage(data, local)) + matches, err := filepath.Glob(filepath.Join(data, "atmos-incomplete-provider-*", "package", "LICENSE")) + require.NoError(t, err) + require.Len(t, matches, 1) + content, err := os.ReadFile(matches[0]) + require.NoError(t, err) + assert.Equal(t, "preserve exact content", string(content)) + if runtime.GOOS == "windows" { + return + } + shared := t.TempDir() + outside := filepath.Join(shared, "partial") + require.NoError(t, os.Mkdir(outside, 0o755)) + viaLink := filepath.Join(data, "shared") + require.NoError(t, os.Symlink(shared, viaLink)) + require.NoError(t, preserveIncompletePackage(data, filepath.Join(viaLink, "partial"))) + _, err = os.Stat(outside) + require.NoError(t, err, "must not move shared-cache contents through an ancestor symlink") +} + +func TestProviderRecoveryFilesystemFailuresPreservePackages(t *testing.T) { + if runtime.GOOS == "windows" || os.Geteuid() == 0 { + t.Skip("requires non-root POSIX permissions") + } + for _, mode := range []string{"unreadable", "quarantine-create", "quarantine-rename"} { + t.Run(mode, func(t *testing.T) { + data := t.TempDir() + parent := filepath.Join(data, "providers") + path := filepath.Join(parent, "package") + require.NoError(t, os.MkdirAll(path, 0o755)) + sentinel := filepath.Join(path, "LICENSE") + require.NoError(t, os.WriteFile(sentinel, []byte("original"), 0o600)) + protected := data + if mode == "unreadable" { + protected = path + } + if mode == "quarantine-rename" { + protected = parent + } + permission := os.FileMode(0o500) + if mode == "unreadable" { + permission = 0 + } + require.NoError(t, os.Chmod(protected, permission)) + t.Cleanup(func() { _ = os.Chmod(protected, 0o755) }) + needed, err := prepareLocalPackage(data, path, "terraform-provider-null_v3.2.1", true) + assert.False(t, needed) + if mode == "unreadable" { + require.NoError(t, err) + } else { + require.ErrorIs(t, err, errUtils.ErrTerraformInit) + } + require.NoError(t, os.Chmod(protected, 0o755)) + content, readErr := os.ReadFile(sentinel) + require.NoError(t, readErr) + assert.Equal(t, "original", string(content)) + }) + } +} + +func TestProviderRecoveryCacheCreationFailure(t *testing.T) { + componentPath := t.TempDir() + data := filepath.Join(componentPath, ".terraform") + cache := t.TempDir() + require.NoError(t, os.WriteFile(filepath.Join(componentPath, lockfile.Name), []byte(validLockFile), 0o600)) + require.NoError(t, os.MkdirAll(filepath.Join(cache, "registry.terraform.io", "hashicorp", "null", "3.2.1", runtime.GOOS+"_"+runtime.GOARCH), 0o755)) + require.NoError(t, os.MkdirAll(data, 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(data, "atmos-provider-recovery"), []byte("reserved"), 0o600)) + in := &Inputs{ComponentPath: componentPath, DataDir: data, EnvLookup: func(key string) (string, bool) { return cache, key == envTFPluginCacheDir }} + _, err := PrepareProviderInstallation(in) + require.ErrorIs(t, err, errUtils.ErrTerraformInit) +} + +func TestProviderRecoveryRejectsReservedDirectorySymlink(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("symlink creation requires additional Windows privileges") + } + componentPath := t.TempDir() + data := filepath.Join(componentPath, ".terraform") + cache := t.TempDir() + external := t.TempDir() + require.NoError(t, os.WriteFile(filepath.Join(componentPath, lockfile.Name), []byte(validLockFile), 0o600)) + require.NoError(t, os.MkdirAll(filepath.Join(cache, "registry.terraform.io", "hashicorp", "null", "3.2.1", runtime.GOOS+"_"+runtime.GOARCH), 0o755)) + require.NoError(t, os.MkdirAll(data, 0o755)) + require.NoError(t, os.Symlink(external, filepath.Join(data, "atmos-provider-recovery"))) + sentinel := filepath.Join(external, "sentinel") + require.NoError(t, os.WriteFile(sentinel, []byte("unchanged"), 0o600)) + in := &Inputs{ComponentPath: componentPath, DataDir: data, EnvLookup: func(key string) (string, bool) { return cache, key == envTFPluginCacheDir }} + _, err := PrepareProviderInstallation(in) + require.ErrorIs(t, err, errUtils.ErrTerraformInit) + assert.Contains(t, err.Error(), "must not be a symlink") + content, err := os.ReadFile(sentinel) + require.NoError(t, err) + assert.Equal(t, "unchanged", string(content)) + entries, err := os.ReadDir(external) + require.NoError(t, err) + require.Len(t, entries, 1) + assert.Equal(t, "sentinel", entries[0].Name()) +} + +func TestProviderRecoveryInspectionFailure(t *testing.T) { + if runtime.GOOS == "windows" || os.Geteuid() == 0 { + t.Skip("requires non-root POSIX directory permissions") + } + data := t.TempDir() + parent := filepath.Join(data, "inaccessible") + require.NoError(t, os.Mkdir(parent, 0o700)) + sentinel := filepath.Join(parent, "sentinel") + require.NoError(t, os.WriteFile(sentinel, []byte("untouched"), 0o600)) + require.NoError(t, os.Chmod(parent, 0)) + t.Cleanup(func() { _ = os.Chmod(parent, 0o700) }) + _, err := prepareLocalPackage(data, filepath.Join(parent, "package"), "terraform-provider-null_v3.2.1", true) + require.ErrorIs(t, err, errUtils.ErrTerraformInit) + require.NoError(t, os.Chmod(parent, 0o700)) + content, err := os.ReadFile(sentinel) + require.NoError(t, err) + assert.Equal(t, "untouched", string(content)) +} + +func TestPrepareProviderInstallationPropagatesInspectionFailure(t *testing.T) { + if runtime.GOOS == "windows" || os.Geteuid() == 0 { + t.Skip("requires non-root POSIX directory permissions") + } + root := t.TempDir() + data := filepath.Join(root, ".terraform") + blocked := filepath.Join(data, "providers") + require.NoError(t, os.WriteFile(filepath.Join(root, lockfile.Name), []byte(validLockFile), 0o600)) + require.NoError(t, os.MkdirAll(blocked, 0o700)) + sentinel := filepath.Join(blocked, "sentinel") + require.NoError(t, os.WriteFile(sentinel, []byte("preserve"), 0o600)) + require.NoError(t, os.Chmod(blocked, 0)) + t.Cleanup(func() { _ = os.Chmod(blocked, 0o700) }) + cache, err := PrepareProviderInstallation(&Inputs{ComponentPath: root, DataDir: data}) + require.ErrorIs(t, err, errUtils.ErrTerraformInit) + assert.Empty(t, cache) + require.NoError(t, os.Chmod(blocked, 0o700)) + content, err := os.ReadFile(sentinel) + require.NoError(t, err) + assert.Equal(t, "preserve", string(content)) +} + +func TestPrepareProviderInstallationRejectsUnsafeLockAddresses(t *testing.T) { + for _, source := range []string{"broken", "../hashicorp/null"} { + t.Run(source, func(t *testing.T) { + root := t.TempDir() + data := filepath.Join(root, ".terraform") + require.NoError(t, os.WriteFile(filepath.Join(root, lockfile.Name), []byte("provider \""+source+"\" {\n version = \"3.2.1\"\n}\n"), 0o600)) + cache, err := PrepareProviderInstallation(&Inputs{ComponentPath: root, DataDir: data}) + require.NoError(t, err) + assert.Empty(t, cache) + assert.NoDirExists(t, data, "invalid addresses must not create or repair installations") + }) + } +} + +func TestPrepareProviderInstallationUnlinkFailurePreservesSharedTarget(t *testing.T) { + if runtime.GOOS == "windows" || os.Geteuid() == 0 { + t.Skip("requires non-root POSIX directory permissions") + } + root := t.TempDir() + data := filepath.Join(root, ".terraform") + shared := t.TempDir() + require.NoError(t, os.WriteFile(filepath.Join(root, lockfile.Name), []byte(validLockFile), 0o600)) + local := filepath.Join(data, "providers", "registry.terraform.io", "hashicorp", "null", "3.2.1", runtime.GOOS+"_"+runtime.GOARCH) + parent := filepath.Dir(local) + require.NoError(t, os.MkdirAll(parent, 0o755)) + require.NoError(t, os.Symlink(shared, local)) + sentinel := filepath.Join(shared, "LICENSE") + require.NoError(t, os.WriteFile(sentinel, []byte("shared content"), 0o600)) + require.NoError(t, os.Chmod(parent, 0o500)) + t.Cleanup(func() { _ = os.Chmod(parent, 0o755) }) + _, err := PrepareProviderInstallation(&Inputs{ComponentPath: root, DataDir: data}) + require.ErrorIs(t, err, errUtils.ErrTerraformInit) + target, err := os.Readlink(local) + require.NoError(t, err) + assert.Equal(t, shared, target) + content, err := os.ReadFile(sentinel) + require.NoError(t, err) + assert.Equal(t, "shared content", string(content)) +} diff --git a/pkg/terraform/cache/cache.go b/pkg/terraform/cache/cache.go index c47b64b748c..92fd4a11fb8 100644 --- a/pkg/terraform/cache/cache.go +++ b/pkg/terraform/cache/cache.go @@ -9,6 +9,7 @@ package cache import ( "context" + "crypto/sha256" "fmt" "time" @@ -58,6 +59,7 @@ type Setup struct { server *proxy.Server proxyURL string certPath string + identity string } // StartForExecution starts and verifies a registry cache for one complete @@ -170,7 +172,11 @@ func Start(ctx context.Context, atmosConfig *schema.AtmosConfiguration) (*Setup, log.Debug("Terraform registry cache started", "proxy", proxyURL, "root", root) ui.Success(fmt.Sprintf("Registry cache proxy listening on %s", proxyURL)) - return &Setup{server: server, proxyURL: proxyURL, certPath: cert.CertPEMPath}, nil + identity := fmt.Sprintf("root=%s\ncertificate=%x\nmetadata_ttl=%s\nstale_while_revalidate=%s", + root, sha256.Sum256(cert.Certificate.Certificate[0]), + parseDuration(cfg.MetadataTTL, defaultMetadataTTL), + parseDuration(cfg.StaleWhileRevalidate, defaultStaleWhileRevalidate)) + return &Setup{server: server, proxyURL: proxyURL, certPath: cert.CertPEMPath, identity: identity}, nil } // Contribute returns the Terraform CLI-config directives the cache injects into the @@ -187,12 +193,26 @@ func (s *Setup) Contribute() map[string]any { if s == nil { return nil } + return registryContribution(s.proxyURL) +} + +// FingerprintContribution describes the same installation rules with a stable, symbolic endpoint. +// Only this Atmos-owned contribution is normalized; user RC URLs are never rewritten. +func (s *Setup) FingerprintContribution() (map[string]any, string) { + defer perf.Track(nil, "tfcache.Setup.FingerprintContribution")() + + if s == nil { + return nil, "" + } + return registryContribution("https://atmos-managed-registry.invalid/"), s.identity +} +func registryContribution(proxyURL string) map[string]any { hosts := map[string]any{} for _, host := range publicModuleHosts { hosts[host] = map[string]any{ "services": map[string]any{ - "modules.v1": s.proxyURL + "modules/" + host + "/", + "modules.v1": proxyURL + "modules/" + host + "/", "providers.v1": "https://" + host + "/v1/providers/", }, } @@ -200,7 +220,7 @@ func (s *Setup) Contribute() map[string]any { return map[string]any{ "provider_installation": []any{ - map[string]any{"network_mirror": map[string]any{"url": s.proxyURL + "providers/"}}, + map[string]any{"network_mirror": map[string]any{"url": proxyURL + "providers/"}}, map[string]any{"direct": map[string]any{}}, }, "host": hosts, diff --git a/pkg/terraform/cache/cache_test.go b/pkg/terraform/cache/cache_test.go index e8ab221caf2..b0ed787b4a3 100644 --- a/pkg/terraform/cache/cache_test.go +++ b/pkg/terraform/cache/cache_test.go @@ -159,3 +159,29 @@ func TestGoGetterResolver_Resolve(t *testing.T) { r := goGetterResolver{downloader: md} require.NoError(t, r.Resolve(context.Background(), "git::https://example.com/repo.git", "/dest/dir")) } + +func TestFingerprintContributionStableEndpointAndTrust(t *testing.T) { + var absent *Setup + contribution, identity := absent.FingerprintContribution() + assert.Nil(t, contribution) + assert.Empty(t, identity) + cfg := &schema.AtmosConfiguration{} + cfg.Components.Terraform.Cache = &schema.TerraformCacheConfig{Enabled: true, Location: t.TempDir()} + first, err := Start(t.Context(), cfg) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, first.Close(context.Background())) }) + second, err := Start(t.Context(), cfg) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, second.Close(context.Background())) }) + a, aid := first.FingerprintContribution() + b, bid := second.FingerprintContribution() + assert.NotEqual(t, first.Contribute(), second.Contribute()) + assert.Equal(t, a, b) + assert.Equal(t, aid, bid) + cfg.Components.Terraform.Cache.Location = t.TempDir() + other, err := Start(t.Context(), cfg) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, other.Close(context.Background())) }) + _, otherID := other.FingerprintContribution() + assert.NotEqual(t, aid, otherID) +} diff --git a/pkg/terraform/output/config.go b/pkg/terraform/output/config.go index 8ba4030876b..ccd232d1c55 100644 --- a/pkg/terraform/output/config.go +++ b/pkg/terraform/output/config.go @@ -6,6 +6,7 @@ import ( errUtils "github.com/cloudposse/atmos/errors" cfg "github.com/cloudposse/atmos/pkg/config" "github.com/cloudposse/atmos/pkg/perf" + provSource "github.com/cloudposse/atmos/pkg/provisioner/source" provWorkdir "github.com/cloudposse/atmos/pkg/provisioner/workdir" "github.com/cloudposse/atmos/pkg/schema" u "github.com/cloudposse/atmos/pkg/utils" @@ -190,6 +191,13 @@ func extractComponentPath(atmosConfig *schema.AtmosConfiguration, sections map[s // reconstruct it here even when _workdir_path is absent from freshly-described // sections (e.g. during hook execution where DescribeComponent is called fresh). if provWorkdir.IsWorkdirEnabled(sections) { + if provSource.HasSource(sections) { + target, targetErr := provSource.ResolveTarget(atmosConfig, componentType, component, sections) + if targetErr != nil { + return "", targetErr + } + return target.Dir, nil + } basePath := atmosConfig.BasePath if basePath == "" { basePath = "." diff --git a/pkg/terraform/output/executor_test.go b/pkg/terraform/output/executor_test.go index b7e29d73b2d..c7d7825a3cd 100644 --- a/pkg/terraform/output/executor_test.go +++ b/pkg/terraform/output/executor_test.go @@ -2244,6 +2244,40 @@ func jitSections() map[string]any { } } +// With auto-provisioning off, outputs run in the workdir already on disk, and the +// metadata.component subpath must select the same directory the local-state reader uses. +func TestEnsureWorkdirProvisioned_AppliesSubpathWhenAutoProvisionIsOff(t *testing.T) { + ResetWorkdirProvisionCache() + ctrl, mockProvisioner, executor, config := setupEnsureWorkdirTest(t) + defer ctrl.Finish() + mockProvisioner.EXPECT().Provision(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(0) + + workdir := t.TempDir() + module := filepath.Join(workdir, "modules", "x") + require.NoError(t, os.MkdirAll(module, 0o755)) + config.AutoProvisionWorkdirForOutputs = false + config.ComponentPath = workdir + sections := jitSections() + sections["metadata"] = map[string]any{"component": "modules/x"} + + require.NoError(t, executor.ensureWorkdirProvisioned(context.Background(), &schema.AtmosConfiguration{}, sections, nil, "vpc", "dev", config)) + assert.Equal(t, module, config.ComponentPath) + + t.Run("a subpath missing on disk falls back to the workdir root", func(t *testing.T) { + config.ComponentPath = workdir + sections["metadata"] = map[string]any{"component": "modules/absent"} + require.NoError(t, executor.ensureWorkdirProvisioned(context.Background(), &schema.AtmosConfiguration{}, sections, nil, "vpc", "dev", config)) + assert.Equal(t, workdir, config.ComponentPath) + }) + + t.Run("a component without a workdir keeps its path", func(t *testing.T) { + config.ComponentPath = workdir + plain := map[string]any{"metadata": map[string]any{"component": "modules/x"}} + require.NoError(t, executor.ensureWorkdirProvisioned(context.Background(), &schema.AtmosConfiguration{}, plain, nil, "vpc", "dev", config)) + assert.Equal(t, workdir, config.ComponentPath) + }) +} + func TestEnsureWorkdirProvisioned_CallsProvisionerWhenEnabled(t *testing.T) { ResetWorkdirProvisionCache() ctrl, mockProvisioner, executor, config := setupEnsureWorkdirTest(t) diff --git a/pkg/terraform/output/executor_workdir.go b/pkg/terraform/output/executor_workdir.go index ae15e34477e..3112a48fbc9 100644 --- a/pkg/terraform/output/executor_workdir.go +++ b/pkg/terraform/output/executor_workdir.go @@ -2,12 +2,17 @@ package output import ( "context" + "encoding/json" "fmt" + "os" + "path/filepath" "sync" "golang.org/x/sync/singleflight" errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/auth/fingerprint" + componentpath "github.com/cloudposse/atmos/pkg/component" cfg "github.com/cloudposse/atmos/pkg/config" log "github.com/cloudposse/atmos/pkg/logger" "github.com/cloudposse/atmos/pkg/perf" @@ -119,15 +124,25 @@ func (e *Executor) ensureWorkdirProvisioned( ) error { defer perf.Track(atmosConfig, "output.Executor.ensureWorkdirProvisioned")() - if !config.AutoProvisionWorkdirForOutputs { + if !provWorkdir.IsWorkdirEnabled(sections) { return nil } - if !provWorkdir.IsWorkdirEnabled(sections) { - return nil + // Without auto-provisioning, outputs run in whatever workdir is already on disk. The + // metadata.component subpath must still select the same directory the local-state reader uses, + // resolved against the disk like that reader does. Resolving earlier (before provisioning) would + // see a cold workdir and fall back to its root permanently. + if !config.AutoProvisionWorkdirForOutputs { + return applyOutputSubpath(sections, config) } - cacheKey := stackComponentKey(stack, component) + cacheKey, err := workdirProvisionKey(&workdirProvisionIdentity{ + config: atmosConfig, sections: sections, auth: authContext, + component: component, stack: stack, path: config.ComponentPath, + }) + if err != nil { + return err + } // Capture before launching the provisioner: tests may install a follower-only // hook after the leader enters Provision, while its DoChan is still returning. @@ -149,7 +164,12 @@ func (e *Executor) ensureWorkdirProvisioned( // workdir — it must report false, or every later call would keep inheriting the // one-time freshness signal and force a full re-init on every subsequent call. if _, loaded := workdirProvisionCache.LoadOrStore(cacheKey, true); loaded { - return false, nil + if config.ComponentPath == "" { + return false, nil + } + if fi, statErr := os.Stat(config.ComponentPath); statErr == nil && fi.IsDir() { + return false, nil + } } log.Debug("Auto-provisioning JIT workdir for output fetch", "component", component, "stack", stack) @@ -207,8 +227,45 @@ func (e *Executor) ensureWorkdirProvisioned( if reprovisioned, _ := res.Val.(bool); reprovisioned { config.WorkdirReprovisioned = true } - return nil + return applyOutputSubpath(sections, config) case <-ctx.Done(): return ctx.Err() } } + +// applyOutputSubpath points config.ComponentPath at the metadata.component subpath inside the +// workdir. It consults the disk, so it must run after any provisioning has finished. +func applyOutputSubpath(sections map[string]any, config *ComponentConfig) error { + metadata, ok := sections["metadata"].(map[string]any) + if !ok { + return nil + } + subpath, _ := metadata["component"].(string) + resolved, err := componentpath.ResolveWorkdirSubpath(subpath, config.ComponentPath) + if err != nil { + return err + } + config.ComponentPath = resolved + return nil +} + +// workdirProvisionKey isolates HEAD/BASE checkouts and source/auth changes within a process. +// Auth material is keyed with a process-local secret and is never printed in diagnostics. +func workdirProvisionKey(identity *workdirProvisionIdentity) (string, error) { + base, err := filepath.Abs(identity.config.BasePath) + if err != nil { + return "", fmt.Errorf("%w: resolve provisioning checkout: %w", errUtils.ErrWorkdirProvision, err) + } + encoded, err := json.Marshal([]any{base, identity.config.CliConfigPath, identity.path, identity.component, identity.stack, identity.sections["source"], identity.sections["auth"], identity.auth}) + if err != nil { + return "", fmt.Errorf("%w: key output provisioning: %w", errUtils.ErrWorkdirProvision, err) + } + return fingerprint.Key(encoded), nil +} + +type workdirProvisionIdentity struct { + config *schema.AtmosConfiguration + sections map[string]any + auth *schema.AuthContext + component, stack, path string +} diff --git a/pkg/terraform/output/source_owner_test.go b/pkg/terraform/output/source_owner_test.go new file mode 100644 index 00000000000..a0cfc277bd7 --- /dev/null +++ b/pkg/terraform/output/source_owner_test.go @@ -0,0 +1,39 @@ +package output + +import ( + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/provisioner/workdir" +) + +func TestOutputConfigValidatesSourceOwnerWithoutProvisioning(t *testing.T) { + for _, owner := range []struct{ component, stack string }{{"instance", "dev"}, {"other", "dev"}, {"instance", "prod"}} { + t.Run(owner.component+"-"+owner.stack, func(t *testing.T) { + base := t.TempDir() + config := testAtmosConfig(base, true, false) + config.Components.Terraform.AutoProvisionWorkdirForOutputs = false + target := filepath.Join(base, "custom") + require.NoError(t, workdir.WriteMetadata(target, &workdir.WorkdirMetadata{Component: owner.component, Stack: owner.stack})) + sections := map[string]any{ + "atmos_component": "instance", "atmos_stack": "dev", "workspace": "dev", + "command": "terraform", "component_info": map[string]any{"component_type": "terraform"}, + "source": "./source", "component": "module", + "metadata": map[string]any{"working_directory": "custom"}, + "provision": map[string]any{"workdir": map[string]any{"enabled": true}}, + } + got, err := ExtractComponentConfig(config, sections, "instance", "dev") + if owner.component != "instance" || owner.stack != "dev" { + require.ErrorIs(t, err, errUtils.ErrWorkdirProvision) + require.Nil(t, got) + return + } + require.NoError(t, err) + require.False(t, got.AutoProvisionWorkdirForOutputs) + require.Equal(t, target, got.ComponentPath) + }) + } +} diff --git a/pkg/terraform/output/workdir_isolation_test.go b/pkg/terraform/output/workdir_isolation_test.go new file mode 100644 index 00000000000..12f7464a6d5 --- /dev/null +++ b/pkg/terraform/output/workdir_isolation_test.go @@ -0,0 +1,87 @@ +package output + +import ( + "context" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" + + "github.com/cloudposse/atmos/pkg/schema" +) + +func TestWorkdirProvisioningIsolatesCheckoutsAndSourceVersions(t *testing.T) { + ResetWorkdirProvisionCache() + t.Cleanup(ResetWorkdirProvisionCache) + ctrl := gomock.NewController(t) + provisioner := NewMockWorkdirProvisioner(ctrl) + executor := NewExecutor(nil, WithWorkdirProvisioner(provisioner)) + provisioner.EXPECT().Provision(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(3) + root := t.TempDir() + for _, checkout := range []string{"HEAD", "BASE"} { + base := filepath.Join(root, checkout) + require.NoError(t, os.MkdirAll(base, 0o755)) + config := &ComponentConfig{ComponentPath: base, AutoProvisionWorkdirForOutputs: true} + sections := jitSections() + sections["source"] = map[string]any{"uri": "git::fixture", "version": "v1"} + for range 2 { + require.NoError(t, executor.ensureWorkdirProvisioned(context.Background(), &schema.AtmosConfiguration{BasePath: base}, sections, nil, "vpc", "dev", config)) + } + if checkout == "HEAD" { + sections["source"] = map[string]any{"uri": "git::fixture", "version": "v2"} + require.NoError(t, executor.ensureWorkdirProvisioned(context.Background(), &schema.AtmosConfiguration{BasePath: base}, sections, nil, "vpc", "dev", config)) + } + } +} + +func TestWorkdirProvisioningRecoversRemovedTarget(t *testing.T) { + ResetWorkdirProvisionCache() + t.Cleanup(ResetWorkdirProvisionCache) + ctrl := gomock.NewController(t) + provisioner := NewMockWorkdirProvisioner(ctrl) + executor := NewExecutor(nil, WithWorkdirProvisioner(provisioner)) + target := filepath.Join(t.TempDir(), "workdir") + provisioner.EXPECT().Provision(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn( + func(context.Context, *schema.AtmosConfiguration, map[string]any, *schema.AuthContext) error { + return os.MkdirAll(target, 0o755) + }, + ).Times(2) + config := &ComponentConfig{ComponentPath: target, AutoProvisionWorkdirForOutputs: true} + for range 2 { + require.NoError(t, executor.ensureWorkdirProvisioned(context.Background(), &schema.AtmosConfiguration{}, jitSections(), nil, "vpc", "dev", config)) + require.DirExists(t, target) + require.NoError(t, os.Remove(target)) + } +} + +func TestWorkdirProvisioningIsolatesChangedCredentials(t *testing.T) { + ResetWorkdirProvisionCache() + t.Cleanup(ResetWorkdirProvisionCache) + provisioner := NewMockWorkdirProvisioner(gomock.NewController(t)) + executor := NewExecutor(nil, WithWorkdirProvisioner(provisioner)) + provisioner.EXPECT().Provision(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + base := t.TempDir() + config := &ComponentConfig{ComponentPath: base, AutoProvisionWorkdirForOutputs: true} + for _, credential := range []string{"initial-scope", "initial-scope", "rotated-scope"} { + sections := jitSections() + sections["auth"] = map[string]any{"password": credential} + require.NoError(t, executor.ensureWorkdirProvisioned(t.Context(), &schema.AtmosConfiguration{BasePath: base}, sections, nil, "vpc", "dev", config)) + } +} + +func TestWorkdirProvisioningIsolatesChangedAuthContext(t *testing.T) { + ResetWorkdirProvisionCache() + t.Cleanup(ResetWorkdirProvisionCache) + provisioner := NewMockWorkdirProvisioner(gomock.NewController(t)) + executor := NewExecutor(nil, WithWorkdirProvisioner(provisioner)) + provisioner.EXPECT().Provision(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + base := t.TempDir() + config := &ComponentConfig{ComponentPath: base, AutoProvisionWorkdirForOutputs: true} + sections := jitSections() + for _, profile := range []string{"initial-profile", "initial-profile", "rotated-profile"} { + authContext := &schema.AuthContext{AWS: &schema.AWSAuthContext{Profile: profile}} + require.NoError(t, executor.ensureWorkdirProvisioned(t.Context(), &schema.AtmosConfiguration{BasePath: base}, sections, authContext, "vpc", "dev", config)) + } +} diff --git a/pkg/terraform/output/workdir_subpath_test.go b/pkg/terraform/output/workdir_subpath_test.go new file mode 100644 index 00000000000..ee04482e969 --- /dev/null +++ b/pkg/terraform/output/workdir_subpath_test.go @@ -0,0 +1,67 @@ +package output + +import ( + "context" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/schema" +) + +// Output reads must resolve the same module directory as command execution, including +// when provisioning has already completed and the next read reuses its workdir. +func TestOutputProvisioningResolvesModuleSubpath(t *testing.T) { + for _, tc := range []struct { + name string + subpath string + createFile bool + wantError bool + }{ + {name: "nested module", subpath: "modules/network"}, + {name: "inheritance identity falls back to root", subpath: "abstract-base"}, + {name: "file cannot be module directory", subpath: "invalid", createFile: true, wantError: true}, + {name: "absolute subpath rejected", wantError: true}, + } { + t.Run(tc.name, func(t *testing.T) { + ResetWorkdirProvisionCache() + t.Cleanup(ResetWorkdirProvisionCache) + root := t.TempDir() + module := filepath.Join(root, "modules", "network") + require.NoError(t, os.MkdirAll(module, 0o755)) + if tc.createFile { + require.NoError(t, os.WriteFile(filepath.Join(root, tc.subpath), []byte("not a module"), 0o600)) + } + subpath := tc.subpath + if subpath == "" { + subpath = module + } + sections := jitSections() + sections["metadata"] = map[string]any{"component": subpath} + provisioner := NewMockWorkdirProvisioner(gomock.NewController(t)) + provisioner.EXPECT().Provision(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) + executor := NewExecutor(nil, WithWorkdirProvisioner(provisioner)) + for range 2 { + // A freshly described component starts with the package root on every lookup. + config := &ComponentConfig{ComponentPath: root, AutoProvisionWorkdirForOutputs: true} + err := executor.ensureWorkdirProvisioned(context.Background(), &schema.AtmosConfiguration{BasePath: root}, sections, nil, "network", "dev", config) + if tc.wantError { + require.ErrorIs(t, err, errUtils.ErrWorkdirProvision) + require.Equal(t, root, config.ComponentPath, "failed resolution must not publish an invalid execution path") + continue + } + require.NoError(t, err) + want := root + if tc.subpath == "modules/network" { + want = module + } + require.Equal(t, want, config.ComponentPath) + require.DirExists(t, config.ComponentPath) + } + }) + } +} diff --git a/pkg/terraform/rc/fingerprint.go b/pkg/terraform/rc/fingerprint.go new file mode 100644 index 00000000000..3138ec0edd9 --- /dev/null +++ b/pkg/terraform/rc/fingerprint.go @@ -0,0 +1,77 @@ +package rc + +import ( + "crypto/sha256" + "fmt" + "strings" + "sync" + + "github.com/cloudposse/atmos/pkg/perf" + "github.com/cloudposse/atmos/pkg/schema" +) + +// managedFingerprints records provenance only for live files generated in this process. Keeping +// the original digest prevents edits/replacements of a generated file from being hidden by its +// stable identity. Entries are removed with the file's pipeline-scoped cleanup, including errors. +var managedFingerprints sync.Map + +type managedFingerprint struct { + content [sha256.Size]byte + identity string +} + +// GenerateManaged renders a CLI config containing an Atmos-owned ephemeral proxy, while recording +// its stable semantic identity for smart init. User-controlled CLI config retains normal precedence +// and is never registered. A nil semanticMap uses ordinary content identity. Otherwise, semanticMap +// contains the same effective user settings and installation rules, with only the Atmos-generated +// endpoint replaced; identity covers cache location and trust. +func GenerateManaged(rcMap, semanticMap map[string]any, identity string, atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo) ([]string, func() error, error) { + defer perf.Track(atmosConfig, "rc.GenerateManaged")() + + if semanticMap == nil { + return Generate(rcMap, atmosConfig, info) + } + + if userControlsCLIConfig(atmosConfig, info) { + return nil, noop, nil + } + semantic, err := Render(semanticMap) + if err != nil { + return nil, noop, err + } + rendered, err := Render(rcMap) + if err != nil { + return nil, noop, err + } + env, cleanup, err := Generate(rcMap, atmosConfig, info) + if err != nil { + return env, cleanup, err + } + var path string + for _, entry := range env { + if p, ok := strings.CutPrefix(entry, EnvKeyTFCLIConfigFile+"="); ok { + path = p + break + } + } + if path == "" { + return env, cleanup, nil + } + semanticIdentity := fmt.Sprintf("atmos-managed-rc-v1:%x", sha256.Sum256(append(semantic, []byte("\n"+identity)...))) + managedFingerprints.Store(path, managedFingerprint{content: sha256.Sum256(rendered), identity: semanticIdentity}) + return env, func() error { managedFingerprints.Delete(path); return cleanup() }, nil +} + +// FingerprintContent substitutes a stable identity only for an unchanged, explicitly registered +// generated file. Arbitrary user files, including localhost mirrors, retain their exact content. +func FingerprintContent(path string, content []byte) string { + defer perf.Track(nil, "rc.FingerprintContent")() + + if v, ok := managedFingerprints.Load(path); ok { + record := v.(managedFingerprint) + if record.content == sha256.Sum256(content) { + return record.identity + } + } + return string(content) +} diff --git a/pkg/terraform/rc/fingerprint_test.go b/pkg/terraform/rc/fingerprint_test.go new file mode 100644 index 00000000000..5347c304357 --- /dev/null +++ b/pkg/terraform/rc/fingerprint_test.go @@ -0,0 +1,167 @@ +package rc + +import ( + "fmt" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + errUtils "github.com/cloudposse/atmos/errors" + "github.com/cloudposse/atmos/pkg/schema" +) + +func TestManagedFingerprintProvenance(t *testing.T) { + for _, key := range userCLIConfigEnvKeys { + t.Setenv(key, "") + } + cfg := &schema.AtmosConfiguration{} + generated := func(url, identity string) (string, []byte, string, func() error) { + t.Helper() + actual := map[string]any{"host": map[string]any{"registry.example.com": map[string]any{"services": map[string]any{"modules.v1": url}}}} + stable := map[string]any{"host": map[string]any{"registry.example.com": map[string]any{"services": map[string]any{"modules.v1": "https://managed.invalid/"}}}} + env, cleanup, err := GenerateManaged(actual, stable, identity, cfg, &schema.ConfigAndStacksInfo{}) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, cleanup()) }) + path := strings.TrimPrefix(env[0], EnvKeyTFCLIConfigFile+"=") + content, err := os.ReadFile(path) + require.NoError(t, err) + return path, content, FingerprintContent(path, content), cleanup + } + path, a, first, cleanup := generated("https://127.0.0.1:1234/", "root=A;cert=A") + _, b, second, _ := generated("https://127.0.0.1:5678/", "root=A;cert=A") + assert.NotEqual(t, a, b) + assert.Equal(t, first, second) + _, _, changed, _ := generated("https://127.0.0.1:5678/", "root=B;cert=A") + assert.NotEqual(t, first, changed) + _, _, trust, _ := generated("https://127.0.0.1:5678/", "root=A;cert=B") + assert.NotEqual(t, first, trust) + edited := append(append([]byte(nil), a...), []byte("\n# user edit\n")...) + assert.Equal(t, string(edited), FingerprintContent(path, edited), "modified generated content must never use stale identity") + assert.Equal(t, string(a), FingerprintContent("unregistered-user-file", a), "identical arbitrary user content must not acquire provenance") + require.NoError(t, cleanup()) + assert.Equal(t, string(a), FingerprintContent(path, a), "cleanup removes provenance as well as the file") +} + +func TestManagedFingerprintUserPrecedenceAndErrors(t *testing.T) { + for _, key := range userCLIConfigEnvKeys { + t.Setenv(key, "") + } + cfg := &schema.AtmosConfiguration{} + invalid := map[string]any{"provider_installation": "invalid"} + _, _, err := GenerateManaged(invalid, invalid, "", cfg, nil) + require.Error(t, err) + _, _, err = GenerateManaged(invalid, map[string]any{}, "", cfg, nil) + require.Error(t, err) + t.Setenv(EnvKeyTFCLIConfigFile, "user-config") + env, cleanup, err := GenerateManaged(invalid, invalid, "", cfg, nil) + require.NoError(t, err) + assert.Empty(t, env) + require.NoError(t, cleanup()) +} + +func TestManagedFingerprintSemanticRCChanges(t *testing.T) { + for _, key := range userCLIConfigEnvKeys { + t.Setenv(key, "") + } + cfg := &schema.AtmosConfiguration{} + hash := func(config map[string]any) string { + t.Helper() + env, cleanup, err := GenerateManaged(config, config, "same-cache", cfg, nil) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, cleanup()) }) + path := strings.TrimPrefix(env[0], EnvKeyTFCLIConfigFile+"=") + contents, err := os.ReadFile(path) + require.NoError(t, err) + return FingerprintContent(path, contents) + } + initial := hash(map[string]any{"plugin_cache_dir": "first-cache"}) + assert.NotEqual(t, initial, hash(map[string]any{"plugin_cache_dir": "second-cache"})) + assert.NotEqual(t, initial, hash(map[string]any{"credentials": map[string]any{"private.example.com": map[string]any{"token": "dummy-token"}}})) +} + +func TestManagedFingerprintConcurrentCleanup(t *testing.T) { + for _, key := range userCLIConfigEnvKeys { + t.Setenv(key, "") + } + type outcome struct { + identity string + clean bool + err error + } + results := make(chan outcome, 16) + for i := range 16 { + go func() { + config := map[string]any{"plugin_cache_dir": fmt.Sprintf("ephemeral-%d", i)} + semantic := map[string]any{"plugin_cache_dir": "stable"} + env, cleanup, err := GenerateManaged(config, semantic, "identity", &schema.AtmosConfiguration{}, nil) + if err != nil { + results <- outcome{err: err} + return + } + path := strings.TrimPrefix(env[0], EnvKeyTFCLIConfigFile+"=") + content, err := os.ReadFile(path) + if err != nil { + _ = cleanup() + results <- outcome{err: err} + return + } + identity := FingerprintContent(path, content) + err = cleanup() + results <- outcome{identity: identity, clean: FingerprintContent(path, content) == string(content), err: err} + }() + } + var first string + for range 16 { + result := <-results + require.NoError(t, result.err) + assert.True(t, result.clean) + if first == "" { + first = result.identity + } + assert.Equal(t, first, result.identity) + } +} + +func TestGenerateManagedWithoutSemanticContributionUsesActualContent(t *testing.T) { + for _, key := range userCLIConfigEnvKeys { + t.Setenv(key, "") + } + config := map[string]any{"plugin_cache_dir": "user-cache"} + env, cleanup, err := GenerateManaged(config, nil, "unused-identity", &schema.AtmosConfiguration{}, nil) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, cleanup()) }) + require.Len(t, env, 2) + path := strings.TrimPrefix(env[0], EnvKeyTFCLIConfigFile+"=") + content, err := os.ReadFile(path) + require.NoError(t, err) + assert.Contains(t, string(content), `plugin_cache_dir = "user-cache"`) + assert.Equal(t, string(content), FingerprintContent(path, content), "ordinary generated user configuration must not receive proxy provenance") +} + +func TestGenerateManagedTempFailureDoesNotExportConfiguration(t *testing.T) { + for _, key := range userCLIConfigEnvKeys { + t.Setenv(key, "") + } + parent := t.TempDir() + blocked := filepath.Join(parent, "not-a-directory") + require.NoError(t, os.WriteFile(blocked, []byte("sentinel"), 0o600)) + for _, key := range []string{"TMPDIR", "TMP", "TEMP"} { + t.Setenv(key, blocked) + } + config := map[string]any{"plugin_cache_dir": "user-cache"} + env, cleanup, err := GenerateManaged(config, config, "identity", &schema.AtmosConfiguration{}, nil) + require.ErrorIs(t, err, errUtils.ErrInvalidConfig) + assert.Empty(t, env) + require.NoError(t, cleanup()) + content, err := os.ReadFile(blocked) + require.NoError(t, err) + assert.Equal(t, "sentinel", string(content)) + entries, err := os.ReadDir(parent) + require.NoError(t, err) + require.Len(t, entries, 1) + assert.Equal(t, "not-a-directory", entries[0].Name()) +} diff --git a/plugins/auth-secrets/README.md b/plugins/auth-secrets/README.md index 8b92b8440ea..55e0d3ea3a3 100644 --- a/plugins/auth-secrets/README.md +++ b/plugins/auth-secrets/README.md @@ -11,7 +11,7 @@ plugins: packages: secrets: source: oci://ghcr.io/cloudposse/atmos/plugins/auth-secrets - version: 1.1.0 + version: 1.1.1 stores: team: diff --git a/plugins/auth-secrets/auth_test.go b/plugins/auth-secrets/auth_test.go index f2429b02e9f..6bdd42198bf 100644 --- a/plugins/auth-secrets/auth_test.go +++ b/plugins/auth-secrets/auth_test.go @@ -197,7 +197,7 @@ func TestNilRequestsFailWithoutPanicking(t *testing.T) { func TestDescriptionUsesManifestIdentityAndExports(t *testing.T) { info := description() require.Equal(t, "cloudposse/auth-secrets", info.PluginName) - require.Equal(t, "1.1.0", info.PluginVersion) + require.Equal(t, "1.1.1", info.PluginVersion) require.Len(t, info.Services, 2) require.Equal(t, "secrets/store", info.Exports[0].Kind) require.Equal(t, "secrets/env", info.Exports[1].Kind) diff --git a/plugins/auth-secrets/plugin.yaml b/plugins/auth-secrets/plugin.yaml index 97132977767..f6897a3accd 100644 --- a/plugins/auth-secrets/plugin.yaml +++ b/plugins/auth-secrets/plugin.yaml @@ -2,7 +2,7 @@ apiVersion: atmos/v1 kind: AtmosPluginConfig metadata: name: cloudposse/auth-secrets - version: 1.1.0 + version: 1.1.1 display_name: Secret store authentication description: Read declared Atmos secret values and map them to an identity environment author: Cloud Posse diff --git a/tests/cli_jit_engine_test.go b/tests/cli_jit_engine_test.go new file mode 100644 index 00000000000..534eac8bbc4 --- /dev/null +++ b/tests/cli_jit_engine_test.go @@ -0,0 +1,92 @@ +package tests + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/stretchr/testify/require" +) + +const jitEngineLogEnv = "ATMOS_TEST_JIT_ENGINE_LOG" + +// runJITEngineHelper is dispatched before testing flags are parsed. Reusing the +// compiled test executable keeps the provisioning tests portable without a shell +// script or an installed Terraform binary. It models only successful execution; +// these tests assert Atmos's real source downloads, precedence and engine cwd. +func runJITEngineHelper() bool { + logPath := os.Getenv(jitEngineLogEnv) + if logPath == "" { + return false + } + cwd, err := os.Getwd() + if err != nil { + panic(err) + } + f, err := os.OpenFile(logPath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o600) + if err != nil { + panic(err) + } + if err := json.NewEncoder(f).Encode(jitEngineCall{Cwd: cwd, Args: os.Args[1:]}); err != nil { + panic(err) + } + if err := f.Close(); err != nil { + panic(err) + } + args := strings.Join(os.Args[1:], " ") + switch { + case strings.Contains(args, "version"): + if strings.Contains(args, "-json") { + fmt.Println(`{"terraform_version":"1.15.6","platform":"test","provider_selections":{}}`) + } else { + fmt.Println("Terraform v1.15.6") + } + case strings.HasPrefix(args, "workspace list"): + fmt.Println("* dev") + case strings.HasPrefix(args, "workspace show"): + fmt.Println("dev") + case strings.HasPrefix(args, "output"): + fmt.Println(`{}`) + case strings.HasPrefix(args, "show") && strings.Contains(args, "-json"): + fmt.Println(`{"format_version":"1.2","terraform_version":"1.15.6"}`) + } + return true +} + +type jitEngineCall struct { + Cwd string + Args []string +} + +func setupJITEngine(t *testing.T) (string, string) { + t.Helper() + executable, err := os.Executable() + require.NoError(t, err) + logPath := filepath.Join(t.TempDir(), "engine.jsonl") + t.Setenv(jitEngineLogEnv, logPath) + return executable, logPath +} + +func requireJITEngineCommand(t *testing.T, logPath, workdir, command string) { + t.Helper() + data, err := os.ReadFile(logPath) + require.NoError(t, err, "real execution must invoke the test engine") + absWorkdir, err := filepath.Abs(workdir) + require.NoError(t, err) + absWorkdir, err = filepath.EvalSymlinks(absWorkdir) + require.NoError(t, err) + for _, line := range strings.Split(strings.TrimSpace(string(data)), "\n") { + var call jitEngineCall + require.NoError(t, json.Unmarshal([]byte(line), &call)) + if len(call.Args) > 0 && call.Args[0] == command { + cwd, err := filepath.EvalSymlinks(call.Cwd) + require.NoError(t, err) + require.Equal(t, absWorkdir, cwd, "engine must execute vendored source, not local component") + return + } + } + t.Fatalf("expected engine command %q in %s", command, data) +} diff --git a/tests/cli_jit_source_oci_test.go b/tests/cli_jit_source_oci_test.go index 317a1c6c332..d8aa0de0c90 100644 --- a/tests/cli_jit_source_oci_test.go +++ b/tests/cli_jit_source_oci_test.go @@ -4,6 +4,7 @@ import ( "os" "path/filepath" "runtime" + "strconv" "testing" "github.com/stretchr/testify/require" @@ -30,6 +31,7 @@ func TestJITSource_OCIScheme(t *testing.T) { resetSourceCommandState(t) root := t.TempDir() t.Chdir(root) + executable, logPath := setupJITEngine(t) imageRef := ocitest.NewRegistry(t, "test/component:v1", map[string]string{ "context.tf": "# OCI_JIT_MARKER\n", @@ -56,6 +58,7 @@ stacks: components: terraform: oci-component: + command: ` + strconv.Quote(executable) + ` source: uri: "oci://` + imageRef + `" provision: @@ -72,11 +75,15 @@ components: "--stack", "dev", "--dry-run", }) - // Execute may error since terraform isn't configured here, but JIT source - // provisioning should have already run before that point is reached. - _ = cmd.Execute() + require.NoError(t, cmd.Execute()) + require.NoDirExists(t, filepath.Join(root, ".workdir"), "cold dry-run must not download OCI source") + require.NoFileExists(t, logPath, "dry-run must not execute the engine") + resetSourceCommandState(t) + cmd.RootCmd.SetArgs([]string{"terraform", "plan", "oci-component", "--stack", "dev"}) + require.NoError(t, cmd.Execute()) workdirPath := filepath.Join(root, ".workdir", "terraform", "dev-oci-component-751f8f04") + requireJITEngineCommand(t, logPath, workdirPath, "plan") info, err := os.Stat(workdirPath) require.NoError(t, err, "workdir should exist at %s", workdirPath) require.True(t, info.IsDir(), "workdir path should be a directory") diff --git a/tests/cli_jit_source_workdir_test.go b/tests/cli_jit_source_workdir_test.go index 52814455a35..5827388cc50 100644 --- a/tests/cli_jit_source_workdir_test.go +++ b/tests/cli_jit_source_workdir_test.go @@ -3,6 +3,7 @@ package tests import ( "os" "path/filepath" + "strconv" "strings" "testing" @@ -30,6 +31,17 @@ func setupJITSourceWorkdirFixture(t *testing.T) { t.Chdir(sandbox) } +func configureJITWorkdirEngine(t *testing.T) string { + t.Helper() + executable, logPath := setupJITEngine(t) + path := filepath.Join("stacks", "deploy", "dev.yaml") + data, err := os.ReadFile(path) + require.NoError(t, err) + data = []byte(strings.Replace(string(data), " vpc-remote-workdir:\n", " vpc-remote-workdir:\n command: "+strconv.Quote(executable)+"\n", 1)) + require.NoError(t, os.WriteFile(path, data, 0o600)) + return logPath +} + // TestJITSource_WorkdirWithLocalComponent verifies that when: // - source.uri is configured // - provision.workdir.enabled: true @@ -62,18 +74,19 @@ func TestJITSource_WorkdirWithLocalComponent(t *testing.T) { 0o644, )) - // Run terraform plan with --dry-run to trigger the provisioning flow - // without actually running terraform. The dry-run flag skips terraform - // execution but still runs through the JIT provisioning logic. - cmd.RootCmd.SetArgs([]string{ - "terraform", "plan", "vpc-remote-workdir", - "--stack", "dev", - "--dry-run", - }) - - // Execute - this may error due to terraform not being configured, - // but the provisioning should have been attempted. - _ = cmd.Execute() + logPath := configureJITWorkdirEngine(t) + workdir := filepath.Join(".workdir", "terraform", "dev-vpc-remote-workdir-b01dcf0a") + cmd.RootCmd.SetArgs([]string{"terraform", "plan", "vpc-remote-workdir", "--stack", "dev", "--dry-run"}) + require.NoError(t, cmd.Execute()) + require.NoDirExists(t, workdir, "cold dry-run must not download source") + require.NoFileExists(t, logPath, "dry-run must not execute the engine") + localAfter, err := os.ReadFile(filepath.Join(localComponent, "main.tf")) + require.NoError(t, err) + require.Equal(t, localMarker+"\n\nresource \"null_resource\" \"local\" {}\n", string(localAfter)) + resetSourceCommandState(t) + cmd.RootCmd.SetArgs([]string{"terraform", "plan", "vpc-remote-workdir", "--stack", "dev"}) + require.NoError(t, cmd.Execute()) + requireJITEngineCommand(t, logPath, workdir, "plan") // Check the workdir path where the component should have been provisioned. // With source + workdir enabled, the workdir should contain files from REMOTE source, @@ -196,17 +209,14 @@ func TestJITSource_WorkdirWithLocalComponent_AllSubcommands(t *testing.T) { 0o644, )) - // Run terraform with --dry-run to trigger the provisioning flow - // without actually running terraform. - cmd.RootCmd.SetArgs([]string{ - "terraform", tc.subcommand, "vpc-remote-workdir", - "--stack", "dev", - "--dry-run", - }) - - // Execute - this may error due to terraform not being configured, - // but the provisioning should have been attempted. - _ = cmd.Execute() + logPath := configureJITWorkdirEngine(t) + cmd.RootCmd.SetArgs([]string{"terraform", tc.subcommand, "vpc-remote-workdir", "--stack", "dev"}) + require.NoError(t, cmd.Execute()) + expectedCommand := tc.subcommand + if expectedCommand == "deploy" { + expectedCommand = "apply" + } + requireJITEngineCommand(t, logPath, filepath.Join(".workdir", "terraform", "dev-vpc-remote-workdir-b01dcf0a"), expectedCommand) // Check the workdir path where the component should have been provisioned. workdirPath := filepath.Join(".workdir", "terraform", "dev-vpc-remote-workdir-b01dcf0a") diff --git a/tests/cli_source_provisioner_workdir_test.go b/tests/cli_source_provisioner_workdir_test.go index d261ed8a2ff..299f5991297 100644 --- a/tests/cli_source_provisioner_workdir_test.go +++ b/tests/cli_source_provisioner_workdir_test.go @@ -155,6 +155,11 @@ func TestJITSource_MetadataComponentSubpath(t *testing.T) { func TestJITSource_MetadataComponentSubpath_TerraformShell(t *testing.T) { setupJITSourceWorkdirFixture(t) + // Dry-run must inspect an existing module without downloading or copying it. + cmd.RootCmd.SetArgs([]string{"terraform", "source", "pull", "null-label-exports", "--stack", "dev"}) + require.NoError(t, cmd.Execute()) + require.DirExists(t, filepath.Join(".workdir", "terraform", "dev-null-label-exports-83954218", "exports")) + // Capture stderr (where ui.Writeln output goes) for the dry-run banner. // Drain the pipe in a goroutine that starts BEFORE cmd.Execute so the OS // pipe buffer (~64KB) cannot fill while Execute writes — that would diff --git a/tests/cli_test.go b/tests/cli_test.go index 9e9e41f8ce3..dcfe0be507a 100644 --- a/tests/cli_test.go +++ b/tests/cli_test.go @@ -800,6 +800,9 @@ func validateAtmosBinary(repoRoot string) (string, string) { // Entry point for tests to parse flags and handle setup/teardown. func TestMain(m *testing.M) { + if runJITEngineHelper() { + os.Exit(0) + } // Parse flags first to get -v status flag.Parse() diff --git a/website/blog/2026-10-28-source-working-directory-precedence.mdx b/website/blog/2026-10-28-source-working-directory-precedence.mdx new file mode 100644 index 00000000000..5744dd5568f --- /dev/null +++ b/website/blog/2026-10-28-source-working-directory-precedence.mdx @@ -0,0 +1,24 @@ +--- +slug: source-working-directory-precedence +title: "Explicit Source Working Directories and Upgrade Safety" +authors: [osterman] +tags: [fix] +draft: true +--- + +Source components with workdir provisioning enabled can use an explicit +`metadata.working_directory` or `settings.working_directory`. The change is protected by +edition `2026-10-28` so an upgrade cannot silently relocate an existing pinned project. + + + +Metadata takes precedence over settings, followed by the generated workdir path. Relative +overrides resolve from the Atmos base path, including invocation from nested directories. +Source commands, Terraform execution, shell, and reference lookups share this placement. + +Projects pinned before `2026-10-28` retain the generated workdir path. For later or unpinned +projects, Atmos refuses to switch when the old workdir contains files. Explicitly migrate the +whole workdir, including hidden files, local state, provider locks and saved plans, or retain +the earlier edition pin. Atmos never moves Terraform state automatically. + +See [source commands](/cli/commands/terraform/source) for the configuration contract. diff --git a/website/docs/automation/lifecycle-hooks.mdx b/website/docs/automation/lifecycle-hooks.mdx index 745a934276a..717d56726c9 100644 --- a/website/docs/automation/lifecycle-hooks.mdx +++ b/website/docs/automation/lifecycle-hooks.mdx @@ -135,7 +135,10 @@ and the supported step settings. Use before-events for checks that must pass before an operation starts. After-hooks run on success by default; set `when: failure` for failure handling -or `when: always` for either outcome. +or `when: always` for either outcome. Terraform/OpenTofu plans that return detailed +exit code `2` (changes detected) are successful operations: success hooks run once, +failure hooks do not run, and the command retains exit code `2`. A required +after-hook failure still fails the command. `when` tests the parent operation's outcome. `on_failure` controls what happens if the hook itself fails. Set `on_failure: fail` for a required check: a failed diff --git a/website/docs/cli/commands/terraform/source/source.mdx b/website/docs/cli/commands/terraform/source/source.mdx index a5d2b328078..0b2def24384 100644 --- a/website/docs/cli/commands/terraform/source/source.mdx +++ b/website/docs/cli/commands/terraform/source/source.mdx @@ -58,6 +58,18 @@ The explicit CLI commands are useful for fine-grained control: - Delete vendored sources - List components with sources +### Explicit working directory + +For source components with workdir provisioning enabled, `metadata.working_directory` takes precedence +over `settings.working_directory`, then the generated workdir path. Relative overrides resolve from +the Atmos base path, including commands invoked from a nested directory. + +This behavior starts with edition `2026-10-28`; earlier edition pins retain the generated path. If the +previous workdir still contains files, Atmos stops before switching paths. Explicitly migrate the whole +workdir and its state, or retain the earlier edition pin. Advancing an edition never moves state automatically. + +Dry-run Terraform commands resolve the intended directory without fetching source or creating a workdir. + ## How It Works The source provisioner enables just-in-time vendoring of Terraform components directly from stack configuration. Instead of pre-vendoring components or maintaining separate `component.yaml` files, you can declare the source inline: diff --git a/website/docs/cli/commands/terraform/terraform-backend.mdx b/website/docs/cli/commands/terraform/terraform-backend.mdx index 8a535e3190f..6e8c56e96bc 100644 --- a/website/docs/cli/commands/terraform/terraform-backend.mdx +++ b/website/docs/cli/commands/terraform/terraform-backend.mdx @@ -38,7 +38,7 @@ atmos terraform backend [options]
Update backend configuration (idempotent)
`delete `
-
Delete backend infrastructure (requires --force)
+
Delete backend infrastructure and its contents (requires `--force`, even when empty)
## Creating Backends @@ -102,7 +102,7 @@ atmos terraform backend update vpc --stack dev ### Delete Backend -Remove backend infrastructure (requires --force for safety): +Deletion requires `--force`, even for an empty backend. With `--force`, Atmos permanently deletes stored state and other backend contents before removing the backend. Back up any state you need first: ```shell atmos terraform backend delete vpc --stack dev --force @@ -136,12 +136,12 @@ atmos terraform backend create rds --stack dev
Output format for list and describe commands: `table`, `yaml`, `json` (default: varies by command)
`--force`
-
Force deletion without confirmation (delete command only)
+
Permanently delete backend contents, including Terraform state, before deleting the backend (delete command only)
## Authentication -Backend commands support both global and component-level authentication, consistent with regular Terraform commands. +Backend create, update, and delete support both global and component-level authentication, consistent with regular Terraform commands. Use `--identity=false` to disable Atmos identity selection. Backend `!env` values are resolved after authentication using component environment settings before process environment variables. Nested Terraform output/state functions are not evaluated during manual backend provisioning. ### Component-Level Identity diff --git a/website/static/casts/screengrabs/atmos-terraform-backend--help.cast b/website/static/casts/screengrabs/atmos-terraform-backend--help.cast index 58e0ab5bc18..05e500b2901 100644 --- a/website/static/casts/screengrabs/atmos-terraform-backend--help.cast +++ b/website/static/casts/screengrabs/atmos-terraform-backend--help.cast @@ -1,47 +1,47 @@ -{"version":3,"term":{"cols":90,"rows":36,"type":"xterm-256color"},"timestamp":1793820444,"command":"atmos terraform backend --help","env":{"COLORTERM":"truecolor","SHELL":"/bin/zsh"}} -[0.029101125,"o","\n"] -[0.000143625,"o","\u001b[38;5;203m \u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;204m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\n\u001b[38;5;203m█\u001b[0m\u001b[38;5;204m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\n\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\n\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\n\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m \u001b[0m\n\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\n\n"] -[0.000086167,"o","👽 \u001b[38;2;73;85;104mtest\u001b[0m \u001b[38;2;73;85;104mdarwin/arm64\u001b[0m\n"] -[0.000002667,"o","\n"] -[0.000008125,"o","\u001b[48;2;236;201;75m \u001b[0m\u001b[1;38;2;26;32;44;48;2;236;201;75mEXPERIMENTAL\u001b[0m\u001b[48;2;236;201;75m \u001b[0m\n"] -[0.000001541,"o","\n"] -[0.000998834,"o","\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mCreate, list, describe, update, and delete Terraform state\u001b[0m\u001b[38;2;247;250;252m backends.\u001b[0m\n"] -[0.000023458,"o","\n"] -[0.000003792,"o","\u001b[1;38;2;0;163;224mUSAGE\u001b[0m\n"] +{"version":3,"term":{"cols":90,"rows":36,"type":"xterm-256color"},"timestamp":1794164024,"command":"atmos terraform backend --help","env":{"COLORTERM":"truecolor","SHELL":"/bin/zsh"}} +[0.029073458,"o","\n"] +[0.000146709,"o","\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;99m \u001b[0m\n\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\n\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\n\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\n\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;69m█\u001b[0m\u001b[38;5;33m \u001b[0m\n\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\n\n"] +[0.000054416,"o","👽 \u001b[38;2;73;85;104mtest\u001b[0m \u001b[38;2;73;85;104mdarwin/arm64\u001b[0m\n"] +[0.000001917,"o","\n"] +[0.000006083,"o","\u001b[48;2;236;201;75m \u001b[0m\u001b[1;38;2;26;32;44;48;2;236;201;75mEXPERIMENTAL\u001b[0m\u001b[48;2;236;201;75m \u001b[0m\n"] +[0.000001334,"o","\n"] +[0.001210666,"o","\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mCreate, list, describe, update, and delete Terraform state\u001b[0m\u001b[38;2;247;250;252m backends.\u001b[0m\n"] +[0.00000225,"o","\n"] +[0.000003209,"o","\u001b[1;38;2;0;163;224mUSAGE\u001b[0m\n"] +[0.000013375,"o","\n"] +[0.000050458,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;87;83;78;48;2;47;46;54m$ \u001b[0m\u001b[1;38;2;155;81;224;48;2;47;46;54matmos\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mterraform\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mbackend\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[sub-command]\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[flags]\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] +[0.0000025,"o","\n"] +[0.000094958,"o","\u001b[1;38;2;0;163;224mBUILT-IN COMMANDS\u001b[0m\n"] [0.000001375,"o","\n"] -[0.000053,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;87;83;78;48;2;47;46;54m$ \u001b[0m\u001b[1;38;2;155;81;224;48;2;47;46;54matmos\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mterraform\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mbackend\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[sub-command]\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[flags]\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] -[0.000006791,"o","\n"] -[0.000096875,"o","\u001b[1;38;2;0;163;224mBUILT-IN COMMANDS\u001b[0m\n"] -[0.000001292,"o","\n"] -[0.000001417,"o"," "] -[0.000002583,"o","\u001b[1;38;2;0;163;224mcreate\u001b[0m"] -[0.00000225,"o"," "] -[0.000105042,"o","\u001b[38;2;73;85;104m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mProvision backend\u001b[0m\u001b[38;2;255;255;255m infrastructure\u001b[0m\u001b[0m\n"] -[0.000002458,"o"," "] -[0.000002875,"o","\u001b[1;38;2;0;163;224mdelete\u001b[0m"] -[0.0000025,"o"," "] -[0.000093,"o","\u001b[38;2;73;85;104m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mDelete backend\u001b[0m\u001b[38;2;255;255;255m infrastructure\u001b[0m\u001b[0m\n"] -[0.000001958,"o"," "] -[0.000002792,"o","\u001b[1;38;2;0;163;224mdescribe\u001b[0m"] -[0.000002125,"o"," "] -[0.000100167,"o","\u001b[38;2;73;85;104m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mDescribe backend\u001b[0m\u001b[38;2;255;255;255m configuration\u001b[0m\u001b[0m\n"] -[0.000001541,"o"," "] -[0.000002209,"o","\u001b[1;38;2;0;163;224mlist\u001b[0m"] -[0.000001875,"o"," "] -[0.0000925,"o","\u001b[38;2;73;85;104m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mList all backends in\u001b[0m\u001b[38;2;255;255;255m stack\u001b[0m\u001b[0m\n"] -[0.000001458,"o"," "] -[0.000002042,"o","\u001b[1;38;2;0;163;224mupdate\u001b[0m"] -[0.000001833,"o"," "] -[0.000095917,"o","\u001b[38;2;73;85;104m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mUpdate backend\u001b[0m\u001b[38;2;255;255;255m configuration\u001b[0m\u001b[0m\n"] -[0.000001791,"o","\n"] -[0.000013917,"o","\u001b[1;38;2;0;163;224mFLAGS\u001b[0m\n"] +[0.000003334,"o"," "] +[0.000003041,"o","\u001b[1;38;2;0;163;224mcreate\u001b[0m"] +[0.000001959,"o"," "] +[0.000138541,"o","\u001b[38;2;73;85;104m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mProvision backend\u001b[0m\u001b[38;2;255;255;255m infrastructure\u001b[0m\u001b[0m\n"] +[0.000001792,"o"," "] +[0.000002208,"o","\u001b[1;38;2;0;163;224mdelete\u001b[0m"] +[0.000001667,"o"," "] +[0.000100708,"o","\u001b[38;2;73;85;104m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mDelete backend\u001b[0m\u001b[38;2;255;255;255m infrastructure\u001b[0m\u001b[0m\n"] +[0.000001584,"o"," "] +[0.00000225,"o","\u001b[1;38;2;0;163;224mdescribe\u001b[0m"] +[0.000001833,"o"," "] +[0.000093125,"o","\u001b[38;2;73;85;104m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mDescribe backend\u001b[0m\u001b[38;2;255;255;255m configuration\u001b[0m\u001b[0m\n"] +[0.000001542,"o"," "] +[0.000002208,"o","\u001b[1;38;2;0;163;224mlist\u001b[0m"] +[0.000001833,"o"," "] +[0.000126,"o","\u001b[38;2;73;85;104m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mList all backends in\u001b[0m\u001b[38;2;255;255;255m stack\u001b[0m\u001b[0m\n"] +[0.0000015,"o"," "] +[0.000002209,"o","\u001b[1;38;2;0;163;224mupdate\u001b[0m"] +[0.000001583,"o"," "] +[0.000087375,"o","\u001b[38;2;73;85;104m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mUpdate backend\u001b[0m\u001b[38;2;255;255;255m configuration\u001b[0m\u001b[0m\n"] +[0.000001458,"o","\n"] +[0.000012667,"o","\u001b[1;38;2;0;163;224mFLAGS\u001b[0m\n"] +[0.000001042,"o","\n"] +[0.000080083,"o"," "] +[0.000002875,"o","\u001b[1;38;2;0;163;224m-h, --help\u001b[0m"] +[0.000001542,"o"," "] +[0.00012175,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mhelp for\u001b[0m\u001b[38;2;255;255;255m backend\u001b[0m\u001b[0m\n"] +[0.000001416,"o","\n"] [0.000001,"o","\n"] -[0.000084375,"o"," "] -[0.000003667,"o","\u001b[1;38;2;0;163;224m-h, --help\u001b[0m"] -[0.000001583,"o"," "] -[0.000087167,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mhelp for\u001b[0m\u001b[38;2;255;255;255m backend\u001b[0m\u001b[0m\n"] -[0.000001916,"o","\n"] -[0.00000125,"o","\n"] -[0.000980459,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1matmos terraform backend [command] --help\u001b[0m\u001b[38;2;247;250;252m for more information about a\u001b[0m\u001b[38;2;247;250;252m command.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] -[0.000941833,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1m--help=usage\u001b[0m\u001b[38;2;247;250;252m for examples or \u001b[0m\u001b[38;2;0;255;255;1m--help=all\u001b[0m\u001b[38;2;247;250;252m for all flags and full\u001b[0m\u001b[38;2;247;250;252m help.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] -[0.00005025,"o","\n \u001b[38;2;73;85;104mDocumentation:\u001b[0m \u001b[38;2;65;153;225mhttps://atmos.tools/cli/commands/terraform/terraform-backend\u001b[0m\n"] +[0.000917125,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1matmos terraform backend [command] --help\u001b[0m\u001b[38;2;247;250;252m for more information about a\u001b[0m\u001b[38;2;247;250;252m command.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] +[0.000931375,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1m--help=usage\u001b[0m\u001b[38;2;247;250;252m for examples or \u001b[0m\u001b[38;2;0;255;255;1m--help=all\u001b[0m\u001b[38;2;247;250;252m for all flags and full\u001b[0m\u001b[38;2;247;250;252m help.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] +[0.000022042,"o","\n \u001b[38;2;73;85;104mDocumentation:\u001b[0m \u001b[38;2;65;153;225mhttps://atmos.tools/cli/commands/terraform/terraform-backend\u001b[0m\n"] diff --git a/website/static/casts/screengrabs/atmos-terraform-backend-create--help.cast b/website/static/casts/screengrabs/atmos-terraform-backend-create--help.cast index 15b624c4ca3..c56065e93c5 100644 --- a/website/static/casts/screengrabs/atmos-terraform-backend-create--help.cast +++ b/website/static/casts/screengrabs/atmos-terraform-backend-create--help.cast @@ -1,40 +1,40 @@ -{"version":3,"term":{"cols":90,"rows":36,"type":"xterm-256color"},"timestamp":1793820445,"command":"atmos terraform backend create --help","env":{"COLORTERM":"truecolor","SHELL":"/bin/zsh"}} -[0.029436292,"o","\n"] -[0.000138292,"o","\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\n\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\n\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;69m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\n\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\n\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;69m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;39m \u001b[0m\n\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\n\n"] -[0.000060583,"o","👽 \u001b[38;2;73;85;104mtest\u001b[0m \u001b[38;2;73;85;104mdarwin/arm64\u001b[0m\n"] -[0.000001833,"o","\n"] -[0.001108334,"o","\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mCreate or update S3 backend with secure defaults (versioning, encryption, public\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252maccess blocking). This operation is\u001b[0m\u001b[38;2;247;250;252m idempotent.\u001b[0m\n"] -[0.000004916,"o","\n"] -[0.000003875,"o","\u001b[1;38;2;0;163;224mUSAGE\u001b[0m\n"] -[0.000001584,"o","\n"] -[0.000052041,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;87;83;78;48;2;47;46;54m$ \u001b[0m\u001b[1;38;2;155;81;224;48;2;47;46;54matmos\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mterraform\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mbackend\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mcreate\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[component]\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[flags]\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] -[0.000035959,"o","\n"] -[0.000005166,"o","\u001b[1;38;2;0;163;224mEXAMPLES\u001b[0m\n"] -[0.000001375,"o","\n"] -[0.000015125,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;231;229;227;48;2;47;46;54matmos terraform backend create vpc --stack dev\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] -[0.000001459,"o","\n"] -[0.000012625,"o","\u001b[1;38;2;0;163;224mFLAGS\u001b[0m\n"] -[0.000001083,"o","\n"] -[0.000103375,"o"," "] -[0.000003917,"o","\u001b[1;38;2;0;163;224m-h, --help\u001b[0m"] -[0.000001625,"o"," "] -[0.000119583,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mhelp for\u001b[0m\u001b[38;2;255;255;255m create\u001b[0m\u001b[0m\n"] +{"version":3,"term":{"cols":90,"rows":36,"type":"xterm-256color"},"timestamp":1794164025,"command":"atmos terraform backend create --help","env":{"COLORTERM":"truecolor","SHELL":"/bin/zsh"}} +[0.028378792,"o","\n"] +[0.000111958,"o","\u001b[38;5;43m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;119m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\n\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;119m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\n\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;119m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\n\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;148m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m \u001b[0m\n\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;148m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m \u001b[0m\n\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;148m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\n\n"] +[0.000054959,"o","👽 \u001b[38;2;73;85;104mtest\u001b[0m \u001b[38;2;73;85;104mdarwin/arm64\u001b[0m\n"] +[0.000002416,"o","\n"] +[0.001025459,"o","\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mCreate or update S3 backend with secure defaults (versioning, encryption, public\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252maccess blocking). This operation is\u001b[0m\u001b[38;2;247;250;252m idempotent.\u001b[0m\n"] +[0.000002625,"o","\n"] +[0.000003833,"o","\u001b[1;38;2;0;163;224mUSAGE\u001b[0m\n"] +[0.000001542,"o","\n"] +[0.000055666,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;87;83;78;48;2;47;46;54m$ \u001b[0m\u001b[1;38;2;155;81;224;48;2;47;46;54matmos\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mterraform\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mbackend\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mcreate\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[component]\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[flags]\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] +[0.000002667,"o","\n"] +[0.000004,"o","\u001b[1;38;2;0;163;224mEXAMPLES\u001b[0m\n"] +[0.000001292,"o","\n"] +[0.000015166,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;231;229;227;48;2;47;46;54matmos terraform backend create vpc --stack dev\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] [0.00000175,"o","\n"] -[0.000001458,"o"," "] -[0.000002625,"o","\u001b[1;38;2;0;163;224m-i, --identity\u001b[0m"] -[0.000001125,"o"," "] -[0.000002167,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] -[0.000001125,"o"," "] -[0.000104292,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mIdentity to use for authentication (use without value to\u001b[0m\u001b[38;2;255;255;255m select\u001b[0m\u001b[0m\n"] -[0.000004041,"o"," \u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255minteractively)\u001b[0m\u001b[0m\n"] -[0.00000125,"o","\n"] -[0.000001167,"o"," "] -[0.000002125,"o","\u001b[1;38;2;0;163;224m-s, --stack\u001b[0m"] -[9.58e-7,"o"," "] -[0.000002084,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] -[0.000001208,"o"," "] -[0.000106708,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mStack\u001b[0m\u001b[38;2;255;255;255m name\u001b[0m\u001b[0m\n"] -[0.000001459,"o","\n"] -[0.000001208,"o","\n"] -[0.001018125,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1m--help=usage\u001b[0m\u001b[38;2;247;250;252m for examples or \u001b[0m\u001b[38;2;0;255;255;1m--help=all\u001b[0m\u001b[38;2;247;250;252m for all flags and full\u001b[0m\u001b[38;2;247;250;252m help.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] -[0.000021583,"o","\n \u001b[38;2;73;85;104mDocumentation:\u001b[0m \u001b[38;2;65;153;225mhttps://atmos.tools/cli/commands/terraform/terraform-backend\u001b[0m\n"] +[0.00001525,"o","\u001b[1;38;2;0;163;224mFLAGS\u001b[0m\n"] +[0.0000015,"o","\n"] +[0.000097042,"o"," "] +[0.000003833,"o","\u001b[1;38;2;0;163;224m-h, --help\u001b[0m"] +[0.000001917,"o"," "] +[0.000094958,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mhelp for\u001b[0m\u001b[38;2;255;255;255m create\u001b[0m\u001b[0m\n"] +[0.00000225,"o","\n"] +[0.000001584,"o"," "] +[0.000003166,"o","\u001b[1;38;2;0;163;224m-i, --identity\u001b[0m"] +[0.000001542,"o"," "] +[0.000003083,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] +[0.000001584,"o"," "] +[0.0001075,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mIdentity to use for authentication (use without value to\u001b[0m\u001b[38;2;255;255;255m select\u001b[0m\u001b[0m\n"] +[0.000004208,"o"," \u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255minteractively)\u001b[0m\u001b[0m\n"] +[0.000001708,"o","\n"] +[0.000002084,"o"," "] +[0.000003291,"o","\u001b[1;38;2;0;163;224m-s, --stack\u001b[0m"] +[0.000001292,"o"," "] +[0.000002333,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] +[0.000001334,"o"," "] +[0.000121666,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mStack\u001b[0m\u001b[38;2;255;255;255m name\u001b[0m\u001b[0m\n"] +[0.000001834,"o","\n"] +[0.000001541,"o","\n"] +[0.000890625,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1m--help=usage\u001b[0m\u001b[38;2;247;250;252m for examples or \u001b[0m\u001b[38;2;0;255;255;1m--help=all\u001b[0m\u001b[38;2;247;250;252m for all flags and full\u001b[0m\u001b[38;2;247;250;252m help.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] +[0.00001925,"o","\n \u001b[38;2;73;85;104mDocumentation:\u001b[0m \u001b[38;2;65;153;225mhttps://atmos.tools/cli/commands/terraform/terraform-backend\u001b[0m\n"] diff --git a/website/static/casts/screengrabs/atmos-terraform-backend-delete--help.cast b/website/static/casts/screengrabs/atmos-terraform-backend-delete--help.cast index 3076aa39abc..dd81e09913a 100644 --- a/website/static/casts/screengrabs/atmos-terraform-backend-delete--help.cast +++ b/website/static/casts/screengrabs/atmos-terraform-backend-delete--help.cast @@ -1,45 +1,46 @@ -{"version":3,"term":{"cols":90,"rows":36,"type":"xterm-256color"},"timestamp":1793820445,"command":"atmos terraform backend delete --help","env":{"COLORTERM":"truecolor","SHELL":"/bin/zsh"}} -[0.028616458,"o","\n"] -[0.000135875,"o","\u001b[38;5;208m \u001b[0m\u001b[38;5;209m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;204m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m \u001b[0m\n\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;204m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\n\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;204m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\n\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;204m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\n\u001b[38;5;203m█\u001b[0m\u001b[38;5;204m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\n\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\n\n"] -[0.000064083,"o","👽 \u001b[38;2;73;85;104mtest\u001b[0m \u001b[38;2;73;85;104mdarwin/arm64\u001b[0m\n"] -[0.000002167,"o","\n"] -[0.001150792,"o","\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mPermanently delete backend\u001b[0m\u001b[38;2;247;250;252m infrastructure.\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mRequires the --force flag for safety. The backend must be\u001b[0m\u001b[38;2;247;250;252m empty \u001b[0m\u001b[38;2;247;250;252m(no state files)\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m \u001b[38;2;247;250;252mbefore\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mit can be\u001b[0m\u001b[38;2;247;250;252m deleted.\u001b[0m\n"] -[0.000018208,"o","\n"] -[0.000003875,"o","\u001b[1;38;2;0;163;224mUSAGE\u001b[0m\n"] -[0.000002083,"o","\n"] -[0.000048584,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;87;83;78;48;2;47;46;54m$ \u001b[0m\u001b[1;38;2;155;81;224;48;2;47;46;54matmos\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mterraform\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mbackend\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mdelete\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[component]\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[flags]\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] -[0.000002625,"o","\n"] -[0.0000035,"o","\u001b[1;38;2;0;163;224mEXAMPLES\u001b[0m\n"] -[0.000001291,"o","\n"] -[0.000014542,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;231;229;227;48;2;47;46;54matmos terraform backend delete vpc --stack dev --force\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] -[0.000001458,"o","\n"] -[0.000012709,"o","\u001b[1;38;2;0;163;224mFLAGS\u001b[0m\n"] +{"version":3,"term":{"cols":90,"rows":36,"type":"xterm-256color"},"timestamp":1794164025,"command":"atmos terraform backend delete --help","env":{"COLORTERM":"truecolor","SHELL":"/bin/zsh"}} +[0.028690708,"o","\n"] +[0.000117083,"o","\u001b[38;5;44m \u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;43m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;119m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\n\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;84m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\n\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\n\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;84m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;148m \u001b[0m\n\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;148m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m \u001b[0m\n\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;148m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\n\n"] +[0.000056959,"o","👽 \u001b[38;2;73;85;104mtest\u001b[0m \u001b[38;2;73;85;104mdarwin/arm64\u001b[0m\n"] +[0.000002,"o","\n"] +[0.001149416,"o","\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mPermanently delete backend\u001b[0m\u001b[38;2;247;250;252m infrastructure.\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mRequires --force even when the backend is empty. With --force, stored\u001b[0m\u001b[38;2;247;250;252m state \u001b[0m\u001b[38;2;247;250;252mand other\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mbackend contents are permanently deleted before the backend is\u001b[0m\u001b[38;2;247;250;252m removed. \u001b[0m\u001b[38;2;247;250;252mBack up any\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mstate you need before forcing\u001b[0m\u001b[38;2;247;250;252m deletion.\u001b[0m\n"] +[0.000013375,"o","\n"] +[0.000003917,"o","\u001b[1;38;2;0;163;224mUSAGE\u001b[0m\n"] +[0.000001375,"o","\n"] +[0.000040917,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;87;83;78;48;2;47;46;54m$ \u001b[0m\u001b[1;38;2;155;81;224;48;2;47;46;54matmos\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mterraform\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mbackend\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mdelete\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[component]\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[flags]\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] +[0.000002458,"o","\n"] +[0.000003792,"o","\u001b[1;38;2;0;163;224mEXAMPLES\u001b[0m\n"] +[0.000001,"o","\n"] +[0.000014458,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;231;229;227;48;2;47;46;54matmos terraform backend delete vpc --stack dev --force\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] +[0.000001333,"o","\n"] +[0.000012042,"o","\u001b[1;38;2;0;163;224mFLAGS\u001b[0m\n"] [0.000001083,"o","\n"] -[0.000091792,"o"," "] -[0.000002916,"o","\u001b[1;38;2;0;163;224m --force\u001b[0m"] -[0.000001459,"o"," "] -[0.000100916,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mForce deletion without\u001b[0m\u001b[38;2;255;255;255m confirmation\u001b[0m\u001b[0m\n"] -[0.000001917,"o","\n"] -[0.00000125,"o"," "] -[0.000003083,"o","\u001b[1;38;2;0;163;224m-h, --help\u001b[0m"] +[0.000102625,"o"," "] +[0.000003209,"o","\u001b[1;38;2;0;163;224m --force\u001b[0m"] +[0.000001416,"o"," "] +[0.000106834,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mDelete backend contents, including stored Terraform\u001b[0m\u001b[38;2;255;255;255m state,\u001b[0m\u001b[0m\n"] +[0.000004125,"o"," \u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mbefore deleting the\u001b[0m\u001b[38;2;255;255;255m backend\u001b[0m\u001b[0m\n"] +[0.000001208,"o","\n"] +[0.000001167,"o"," "] +[0.000002416,"o","\u001b[1;38;2;0;163;224m-h, --help\u001b[0m"] [0.0000015,"o"," "] -[0.000085,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mhelp for\u001b[0m\u001b[38;2;255;255;255m delete\u001b[0m\u001b[0m\n"] -[0.000001542,"o","\n"] +[0.000104875,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mhelp for\u001b[0m\u001b[38;2;255;255;255m delete\u001b[0m\u001b[0m\n"] +[0.000002542,"o","\n"] +[0.000001833,"o"," "] +[0.000002625,"o","\u001b[1;38;2;0;163;224m-i, --identity\u001b[0m"] +[0.000001584,"o"," "] +[0.000002291,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] +[0.000001625,"o"," "] +[0.000096334,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mIdentity to use for authentication (use without value to\u001b[0m\u001b[38;2;255;255;255m select\u001b[0m\u001b[0m\n"] +[0.000003583,"o"," \u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255minteractively)\u001b[0m\u001b[0m\n"] +[0.000001167,"o","\n"] [0.000001125,"o"," "] -[0.0000025,"o","\u001b[1;38;2;0;163;224m-i, --identity\u001b[0m"] -[0.000001292,"o"," "] +[0.000003083,"o","\u001b[1;38;2;0;163;224m-s, --stack\u001b[0m"] +[0.000001167,"o"," "] [0.000002,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] -[0.000001458,"o"," "] -[0.000099333,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mIdentity to use for authentication (use without value to\u001b[0m\u001b[38;2;255;255;255m select\u001b[0m\u001b[0m\n"] -[0.000004667,"o"," \u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255minteractively)\u001b[0m\u001b[0m\n"] -[0.000001083,"o","\n"] -[0.000001875,"o"," "] -[0.000002084,"o","\u001b[1;38;2;0;163;224m-s, --stack\u001b[0m"] -[9.58e-7,"o"," "] -[0.000002417,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] -[0.000001041,"o"," "] -[0.00009525,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mStack\u001b[0m\u001b[38;2;255;255;255m name\u001b[0m\u001b[0m\n"] -[0.000001334,"o","\n"] -[0.000001083,"o","\n"] -[0.000878042,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1m--help=usage\u001b[0m\u001b[38;2;247;250;252m for examples or \u001b[0m\u001b[38;2;0;255;255;1m--help=all\u001b[0m\u001b[38;2;247;250;252m for all flags and full\u001b[0m\u001b[38;2;247;250;252m help.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] -[0.0000325,"o","\n \u001b[38;2;73;85;104mDocumentation:\u001b[0m \u001b[38;2;65;153;225mhttps://atmos.tools/cli/commands/terraform/terraform-backend\u001b[0m\n"] +[0.000009458,"o"," "] +[0.000089625,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mStack\u001b[0m\u001b[38;2;255;255;255m name\u001b[0m\u001b[0m\n"] +[0.000001333,"o","\n"] +[0.000001125,"o","\n"] +[0.000914542,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1m--help=usage\u001b[0m\u001b[38;2;247;250;252m for examples or \u001b[0m\u001b[38;2;0;255;255;1m--help=all\u001b[0m\u001b[38;2;247;250;252m for all flags and full\u001b[0m\u001b[38;2;247;250;252m help.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] +[0.00001575,"o","\n \u001b[38;2;73;85;104mDocumentation:\u001b[0m \u001b[38;2;65;153;225mhttps://atmos.tools/cli/commands/terraform/terraform-backend\u001b[0m\n"] diff --git a/website/static/casts/screengrabs/atmos-terraform-backend-describe--help.cast b/website/static/casts/screengrabs/atmos-terraform-backend-describe--help.cast index cf597a44fc9..9036bc3e17e 100644 --- a/website/static/casts/screengrabs/atmos-terraform-backend-describe--help.cast +++ b/website/static/casts/screengrabs/atmos-terraform-backend-describe--help.cast @@ -1,47 +1,47 @@ -{"version":3,"term":{"cols":90,"rows":36,"type":"xterm-256color"},"timestamp":1793820446,"command":"atmos terraform backend describe --help","env":{"COLORTERM":"truecolor","SHELL":"/bin/zsh"}} -[0.029923167,"o","\n"] -[0.000125083,"o","\u001b[38;5;203m \u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;204m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\n\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m \u001b[0m\u001b[38;5;204m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\n\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;204m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\n\u001b[38;5;203m█\u001b[0m\u001b[38;5;203m█\u001b[0m\u001b[38;5;204m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\n\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\n\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;198m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\n\n"] -[0.000055083,"o","👽 \u001b[38;2;73;85;104mtest\u001b[0m \u001b[38;2;73;85;104mdarwin/arm64\u001b[0m\n"] -[0.000001709,"o","\n"] -[0.001077166,"o","\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mShow component's backend configuration from\u001b[0m\u001b[38;2;247;250;252m stack.\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mReturns the actual stack configuration for the backend, not a\u001b[0m\u001b[38;2;247;250;252m schema. \u001b[0m\u001b[38;2;247;250;252mDoes not\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mauthenticate, evaluate stack expressions, or inspect remote provisioning\u001b[0m\u001b[38;2;247;250;252m status.\u001b[0m\n"] -[0.000024375,"o","\n"] -[0.000003667,"o","\u001b[1;38;2;0;163;224mUSAGE\u001b[0m\n"] -[0.000001167,"o","\n"] -[0.000041875,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;87;83;78;48;2;47;46;54m$ \u001b[0m\u001b[1;38;2;155;81;224;48;2;47;46;54matmos\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mterraform\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mbackend\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mdescribe\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[component]\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[flags]\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] +{"version":3,"term":{"cols":90,"rows":36,"type":"xterm-256color"},"timestamp":1794164026,"command":"atmos terraform backend describe --help","env":{"COLORTERM":"truecolor","SHELL":"/bin/zsh"}} +[0.026963666,"o","\n"] +[0.000127917,"o","\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\n\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\n\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;69m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m \u001b[0m\n\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;69m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m \u001b[0m\n\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;38m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m \u001b[0m\n\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;38m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\n\n"] +[0.000058,"o","👽 \u001b[38;2;73;85;104mtest\u001b[0m \u001b[38;2;73;85;104mdarwin/arm64\u001b[0m\n"] +[0.0000025,"o","\n"] +[0.00164875,"o","\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mShow component's backend configuration from\u001b[0m\u001b[38;2;247;250;252m stack.\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mReturns the actual stack configuration for the backend, not a\u001b[0m\u001b[38;2;247;250;252m schema. \u001b[0m\u001b[38;2;247;250;252mDoes not\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mauthenticate, evaluate stack expressions, or inspect remote provisioning\u001b[0m\u001b[38;2;247;250;252m status.\u001b[0m\n"] +[0.000033208,"o","\n"] +[0.000007584,"o","\u001b[1;38;2;0;163;224mUSAGE\u001b[0m\n"] [0.000002041,"o","\n"] -[0.000002959,"o","\u001b[1;38;2;0;163;224mEXAMPLES\u001b[0m\n"] -[0.000001458,"o","\n"] -[0.0000225,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;231;229;227;48;2;47;46;54matmos terraform backend describe vpc --stack dev\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;231;229;227;48;2;47;46;54m atmos terraform backend describe vpc --stack dev --format json\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] -[0.0000015,"o","\n"] -[0.00001375,"o","\u001b[1;38;2;0;163;224mFLAGS\u001b[0m\n"] -[9.58e-7,"o","\n"] -[0.000109084,"o"," "] -[0.000003416,"o","\u001b[1;38;2;0;163;224m-f, --format\u001b[0m"] -[0.000001084,"o"," "] -[0.000002458,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] -[0.000001042,"o"," "] -[0.000107875,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mOutput format: yaml, json, table (default \u001b[0m\u001b[38;2;155;81;224;1myaml\u001b[0m\u001b[38;2;255;255;255m)\u001b[0m\u001b[0m\n"] -[0.0000015,"o","\n"] -[0.000001208,"o"," "] -[0.000002333,"o","\u001b[1;38;2;0;163;224m-h, --help\u001b[0m"] -[0.0000015,"o"," "] -[0.000095,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mhelp for\u001b[0m\u001b[38;2;255;255;255m describe\u001b[0m\u001b[0m\n"] +[0.00006125,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;87;83;78;48;2;47;46;54m$ \u001b[0m\u001b[1;38;2;155;81;224;48;2;47;46;54matmos\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mterraform\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mbackend\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mdescribe\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[component]\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[flags]\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] +[0.000002542,"o","\n"] +[0.000003667,"o","\u001b[1;38;2;0;163;224mEXAMPLES\u001b[0m\n"] +[0.00000125,"o","\n"] +[0.0000285,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;231;229;227;48;2;47;46;54matmos terraform backend describe vpc --stack dev\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;231;229;227;48;2;47;46;54m atmos terraform backend describe vpc --stack dev --format json\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] +[0.000001875,"o","\n"] +[0.000013,"o","\u001b[1;38;2;0;163;224mFLAGS\u001b[0m\n"] +[0.00000125,"o","\n"] +[0.000178791,"o"," "] +[0.000004834,"o","\u001b[1;38;2;0;163;224m-f, --format\u001b[0m"] +[0.000001375,"o"," "] +[0.000003458,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] +[0.000001458,"o"," "] +[0.000266,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mOutput format: yaml, json, table (default \u001b[0m\u001b[38;2;155;81;224;1myaml\u001b[0m\u001b[38;2;255;255;255m)\u001b[0m\u001b[0m\n"] +[0.0000065,"o","\n"] +[0.000002167,"o"," "] +[0.000004958,"o","\u001b[1;38;2;0;163;224m-h, --help\u001b[0m"] +[0.000005459,"o"," "] +[0.000388958,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mhelp for\u001b[0m\u001b[38;2;255;255;255m describe\u001b[0m\u001b[0m\n"] +[0.000002875,"o","\n"] +[0.000001917,"o"," "] +[0.000003875,"o","\u001b[1;38;2;0;163;224m-i, --identity\u001b[0m"] +[0.000001375,"o"," "] +[0.000002416,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] +[0.000001084,"o"," "] +[0.000120958,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mIdentity to use for authentication (use without value to\u001b[0m\u001b[38;2;255;255;255m select\u001b[0m\u001b[0m\n"] +[0.000004125,"o"," \u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255minteractively)\u001b[0m\u001b[0m\n"] [0.000001375,"o","\n"] -[0.000001334,"o"," "] -[0.00000275,"o","\u001b[1;38;2;0;163;224m-i, --identity\u001b[0m"] -[0.00000125,"o"," "] -[0.000002333,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] -[0.000001042,"o"," "] -[0.000201583,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mIdentity to use for authentication (use without value to\u001b[0m\u001b[38;2;255;255;255m select\u001b[0m\u001b[0m\n"] -[0.000008708,"o"," \u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255minteractively)\u001b[0m\u001b[0m\n"] -[0.000001959,"o","\n"] -[0.000002125,"o"," "] -[0.00000325,"o","\u001b[1;38;2;0;163;224m-s, --stack\u001b[0m"] -[0.000001125,"o"," "] -[0.000002333,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] -[0.000025958,"o"," "] -[0.000110917,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mStack\u001b[0m\u001b[38;2;255;255;255m name\u001b[0m\u001b[0m\n"] +[0.000001208,"o"," "] +[0.000002917,"o","\u001b[1;38;2;0;163;224m-s, --stack\u001b[0m"] +[0.000001,"o"," "] +[0.000002208,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] +[0.000001125,"o"," "] +[0.000105167,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mStack\u001b[0m\u001b[38;2;255;255;255m name\u001b[0m\u001b[0m\n"] +[0.000020208,"o","\n"] [0.000001917,"o","\n"] -[0.000001125,"o","\n"] -[0.000968833,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1m--help=usage\u001b[0m\u001b[38;2;247;250;252m for examples or \u001b[0m\u001b[38;2;0;255;255;1m--help=all\u001b[0m\u001b[38;2;247;250;252m for all flags and full\u001b[0m\u001b[38;2;247;250;252m help.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] -[0.000024,"o","\n \u001b[38;2;73;85;104mDocumentation:\u001b[0m \u001b[38;2;65;153;225mhttps://atmos.tools/cli/commands/terraform/terraform-backend\u001b[0m\n"] +[0.001019083,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1m--help=usage\u001b[0m\u001b[38;2;247;250;252m for examples or \u001b[0m\u001b[38;2;0;255;255;1m--help=all\u001b[0m\u001b[38;2;247;250;252m for all flags and full\u001b[0m\u001b[38;2;247;250;252m help.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] +[0.000024834,"o","\n \u001b[38;2;73;85;104mDocumentation:\u001b[0m \u001b[38;2;65;153;225mhttps://atmos.tools/cli/commands/terraform/terraform-backend\u001b[0m\n"] diff --git a/website/static/casts/screengrabs/atmos-terraform-backend-list--help.cast b/website/static/casts/screengrabs/atmos-terraform-backend-list--help.cast index 7b72b7bf0b7..a4fdf118270 100644 --- a/website/static/casts/screengrabs/atmos-terraform-backend-list--help.cast +++ b/website/static/casts/screengrabs/atmos-terraform-backend-list--help.cast @@ -1,47 +1,47 @@ -{"version":3,"term":{"cols":90,"rows":36,"type":"xterm-256color"},"timestamp":1793820446,"command":"atmos terraform backend list --help","env":{"COLORTERM":"truecolor","SHELL":"/bin/zsh"}} -[0.02899225,"o","\n"] -[0.000133084,"o","\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\n\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\n\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;69m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m \u001b[0m\n\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;69m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m \u001b[0m\n\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;33m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;38m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m \u001b[0m\n\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;39m \u001b[0m\u001b[38;5;38m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\n\n"] -[0.000085458,"o","👽 \u001b[38;2;73;85;104mtest\u001b[0m \u001b[38;2;73;85;104mdarwin/arm64\u001b[0m\n"] -[0.000001833,"o","\n"] -[0.000976084,"o","\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mShow merged backend configurations for concrete Terraform components in a\u001b[0m\u001b[38;2;247;250;252m stack. \u001b[0m\u001b[38;2;247;250;252mDoes\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mnot authenticate, evaluate stack expressions, or inspect remote provisioning\u001b[0m\u001b[38;2;247;250;252m status.\u001b[0m\n"] +{"version":3,"term":{"cols":90,"rows":36,"type":"xterm-256color"},"timestamp":1794164026,"command":"atmos terraform backend list --help","env":{"COLORTERM":"truecolor","SHELL":"/bin/zsh"}} +[0.028528084,"o","\n"] +[0.000112916,"o","\u001b[38;5;39m \u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;38m█\u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;43m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\n\u001b[38;5;39m█\u001b[0m\u001b[38;5;39m█\u001b[0m\u001b[38;5;38m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;43m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\n\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;43m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;119m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\n\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;43m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\n\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m█\u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;43m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\n\u001b[38;5;44m \u001b[0m\u001b[38;5;44m \u001b[0m\u001b[38;5;43m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\n\n"] +[0.000054,"o","👽 \u001b[38;2;73;85;104mtest\u001b[0m \u001b[38;2;73;85;104mdarwin/arm64\u001b[0m\n"] +[0.000002167,"o","\n"] +[0.000999042,"o","\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mShow merged backend configurations for concrete Terraform components in a\u001b[0m\u001b[38;2;247;250;252m stack. \u001b[0m\u001b[38;2;247;250;252mDoes\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mnot authenticate, evaluate stack expressions, or inspect remote provisioning\u001b[0m\u001b[38;2;247;250;252m status.\u001b[0m\n"] [0.000002625,"o","\n"] -[0.000005458,"o","\u001b[1;38;2;0;163;224mUSAGE\u001b[0m\n"] -[0.000014875,"o","\n"] -[0.000046375,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;87;83;78;48;2;47;46;54m$ \u001b[0m\u001b[1;38;2;155;81;224;48;2;47;46;54matmos\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mterraform\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mbackend\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mlist\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[flags]\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] -[0.000003417,"o","\n"] -[0.000004333,"o","\u001b[1;38;2;0;163;224mEXAMPLES\u001b[0m\n"] -[0.000001167,"o","\n"] -[0.000014916,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;231;229;227;48;2;47;46;54matmos terraform backend list --stack dev\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] -[0.000003667,"o","\n"] -[0.000015167,"o","\u001b[1;38;2;0;163;224mFLAGS\u001b[0m\n"] +[0.000003625,"o","\u001b[1;38;2;0;163;224mUSAGE\u001b[0m\n"] +[0.000001458,"o","\n"] +[0.000115167,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;87;83;78;48;2;47;46;54m$ \u001b[0m\u001b[1;38;2;155;81;224;48;2;47;46;54matmos\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mterraform\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mbackend\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mlist\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[flags]\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] +[0.0000475,"o","\n"] +[0.000003958,"o","\u001b[1;38;2;0;163;224mEXAMPLES\u001b[0m\n"] [0.000001333,"o","\n"] -[0.000105208,"o"," "] -[0.000003667,"o","\u001b[1;38;2;0;163;224m-f, --format\u001b[0m"] -[0.000001458,"o"," "] -[0.000003292,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] -[0.000001333,"o"," "] -[0.000133375,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mOutput format: table, yaml, json (default \u001b[0m\u001b[38;2;155;81;224;1mtable\u001b[0m\u001b[38;2;255;255;255m)\u001b[0m\u001b[0m\n"] -[0.00000225,"o","\n"] -[0.000001584,"o"," "] -[0.000002916,"o","\u001b[1;38;2;0;163;224m-h, --help\u001b[0m"] -[0.00000175,"o"," "] -[0.000090375,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mhelp for\u001b[0m\u001b[38;2;255;255;255m list\u001b[0m\u001b[0m\n"] -[0.000001917,"o","\n"] -[0.000001458,"o"," "] -[0.00000275,"o","\u001b[1;38;2;0;163;224m-i, --identity\u001b[0m"] -[0.000001292,"o"," "] -[0.000002625,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] -[0.000001292,"o"," "] -[0.0001025,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mIdentity to use for authentication (use without value to\u001b[0m\u001b[38;2;255;255;255m select\u001b[0m\u001b[0m\n"] -[0.000004875,"o"," \u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255minteractively)\u001b[0m\u001b[0m\n"] -[0.0000015,"o","\n"] -[0.0000015,"o"," "] -[0.000002666,"o","\u001b[1;38;2;0;163;224m-s, --stack\u001b[0m"] -[0.000001542,"o"," "] -[0.000002792,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] -[0.000001083,"o"," "] -[0.000091708,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mStack\u001b[0m\u001b[38;2;255;255;255m name\u001b[0m\u001b[0m\n"] +[0.000014792,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;231;229;227;48;2;47;46;54matmos terraform backend list --stack dev\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] +[0.000001583,"o","\n"] +[0.000017042,"o","\u001b[1;38;2;0;163;224mFLAGS\u001b[0m\n"] +[0.000001375,"o","\n"] +[0.000091292,"o"," "] +[0.000003916,"o","\u001b[1;38;2;0;163;224m-f, --format\u001b[0m"] +[0.000002125,"o"," "] +[0.00000275,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] +[0.000001542,"o"," "] +[0.000127625,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mOutput format: table, yaml, json (default \u001b[0m\u001b[38;2;155;81;224;1mtable\u001b[0m\u001b[38;2;255;255;255m)\u001b[0m\u001b[0m\n"] [0.000002042,"o","\n"] -[0.000001208,"o","\n"] -[0.000892125,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1m--help=usage\u001b[0m\u001b[38;2;247;250;252m for examples or \u001b[0m\u001b[38;2;0;255;255;1m--help=all\u001b[0m\u001b[38;2;247;250;252m for all flags and full\u001b[0m\u001b[38;2;247;250;252m help.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] -[0.000019292,"o","\n \u001b[38;2;73;85;104mDocumentation:\u001b[0m \u001b[38;2;65;153;225mhttps://atmos.tools/cli/commands/terraform/terraform-backend\u001b[0m\n"] +[0.000001541,"o"," "] +[0.000003167,"o","\u001b[1;38;2;0;163;224m-h, --help\u001b[0m"] +[0.000001792,"o"," "] +[0.000099208,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mhelp for\u001b[0m\u001b[38;2;255;255;255m list\u001b[0m\u001b[0m\n"] +[0.000001875,"o","\n"] +[0.000001333,"o"," "] +[0.000002709,"o","\u001b[1;38;2;0;163;224m-i, --identity\u001b[0m"] +[0.000001666,"o"," "] +[0.000002417,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] +[0.000001333,"o"," "] +[0.000087542,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mIdentity to use for authentication (use without value to\u001b[0m\u001b[38;2;255;255;255m select\u001b[0m\u001b[0m\n"] +[0.000004792,"o"," \u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255minteractively)\u001b[0m\u001b[0m\n"] +[0.000001791,"o","\n"] +[0.000001459,"o"," "] +[0.00000375,"o","\u001b[1;38;2;0;163;224m-s, --stack\u001b[0m"] +[0.000001166,"o"," "] +[0.000002,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] +[0.000001125,"o"," "] +[0.000092792,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mStack\u001b[0m\u001b[38;2;255;255;255m name\u001b[0m\u001b[0m\n"] +[0.000001625,"o","\n"] +[0.000001417,"o","\n"] +[0.000865291,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1m--help=usage\u001b[0m\u001b[38;2;247;250;252m for examples or \u001b[0m\u001b[38;2;0;255;255;1m--help=all\u001b[0m\u001b[38;2;247;250;252m for all flags and full\u001b[0m\u001b[38;2;247;250;252m help.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] +[0.00001725,"o","\n \u001b[38;2;73;85;104mDocumentation:\u001b[0m \u001b[38;2;65;153;225mhttps://atmos.tools/cli/commands/terraform/terraform-backend\u001b[0m\n"] diff --git a/website/static/casts/screengrabs/atmos-terraform-backend-update--help.cast b/website/static/casts/screengrabs/atmos-terraform-backend-update--help.cast index d6ddae08444..10bd1fd3a67 100644 --- a/website/static/casts/screengrabs/atmos-terraform-backend-update--help.cast +++ b/website/static/casts/screengrabs/atmos-terraform-backend-update--help.cast @@ -1,40 +1,40 @@ -{"version":3,"term":{"cols":90,"rows":36,"type":"xterm-256color"},"timestamp":1793820447,"command":"atmos terraform backend update --help","env":{"COLORTERM":"truecolor","SHELL":"/bin/zsh"}} -[0.028419125,"o","\n"] -[0.000131583,"o","\u001b[38;5;198m \u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;198m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;99m \u001b[0m\n\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\n\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\n\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m█\u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;199m \u001b[0m\u001b[38;5;163m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\n\u001b[38;5;199m█\u001b[0m\u001b[38;5;163m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m█\u001b[0m\u001b[38;5;128m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m█\u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;93m█\u001b[0m\u001b[38;5;99m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;63m█\u001b[0m\u001b[38;5;69m \u001b[0m\n\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;164m \u001b[0m\u001b[38;5;128m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;129m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;93m \u001b[0m\u001b[38;5;99m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;63m \u001b[0m\u001b[38;5;69m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\u001b[38;5;33m \u001b[0m\n\n"] -[0.000051834,"o","👽 \u001b[38;2;73;85;104mtest\u001b[0m \u001b[38;2;73;85;104mdarwin/arm64\u001b[0m\n"] -[0.00000225,"o","\n"] -[0.001146583,"o","\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mApply configuration changes to existing\u001b[0m\u001b[38;2;247;250;252m backend.\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mThis operation is idempotent and will update backend settings\u001b[0m\u001b[38;2;247;250;252m like \u001b[0m\u001b[38;2;247;250;252mversioning,\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mencryption, and public access blocking to match secure\u001b[0m\u001b[38;2;247;250;252m defaults.\u001b[0m\n"] -[0.000022125,"o","\n"] -[0.000004792,"o","\u001b[1;38;2;0;163;224mUSAGE\u001b[0m\n"] -[0.000001458,"o","\n"] -[0.000046375,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;87;83;78;48;2;47;46;54m$ \u001b[0m\u001b[1;38;2;155;81;224;48;2;47;46;54matmos\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mterraform\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mbackend\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mupdate\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[component]\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[flags]\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] -[0.000002958,"o","\n"] -[0.000003167,"o","\u001b[1;38;2;0;163;224mEXAMPLES\u001b[0m\n"] +{"version":3,"term":{"cols":90,"rows":36,"type":"xterm-256color"},"timestamp":1794164027,"command":"atmos terraform backend update --help","env":{"COLORTERM":"truecolor","SHELL":"/bin/zsh"}} +[0.027789583,"o","\n"] +[0.0001215,"o","\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;84m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;119m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\n\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m \u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;119m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\n\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;119m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;148m \u001b[0m\n\u001b[38;5;49m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;119m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;148m \u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m \u001b[0m\n\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;48m█\u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;83m█\u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m█\u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m█\u001b[0m\u001b[38;5;148m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m█\u001b[0m\u001b[38;5;184m \u001b[0m\n\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;48m \u001b[0m\u001b[38;5;84m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;83m \u001b[0m\u001b[38;5;119m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;118m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;154m \u001b[0m\u001b[38;5;148m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\u001b[38;5;184m \u001b[0m\n\n"] +[0.000057959,"o","👽 \u001b[38;2;73;85;104mtest\u001b[0m \u001b[38;2;73;85;104mdarwin/arm64\u001b[0m\n"] [0.000001833,"o","\n"] -[0.000014792,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;231;229;227;48;2;47;46;54matmos terraform backend update vpc --stack dev\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] +[0.000988792,"o","\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mApply configuration changes to existing\u001b[0m\u001b[38;2;247;250;252m backend.\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mThis operation is idempotent and will update backend settings\u001b[0m\u001b[38;2;247;250;252m like \u001b[0m\u001b[38;2;247;250;252mversioning,\u001b[0m\n\u001b[38;2;73;85;104m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mencryption, and public access blocking to match secure\u001b[0m\u001b[38;2;247;250;252m defaults.\u001b[0m\n"] +[0.000013375,"o","\n"] +[0.000003833,"o","\u001b[1;38;2;0;163;224mUSAGE\u001b[0m\n"] [0.0000015,"o","\n"] -[0.000027792,"o","\u001b[1;38;2;0;163;224mFLAGS\u001b[0m\n"] -[0.000004583,"o","\n"] -[0.00011775,"o"," "] -[0.000005125,"o","\u001b[1;38;2;0;163;224m-h, --help\u001b[0m"] -[0.0000015,"o"," "] -[0.000130958,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mhelp for\u001b[0m\u001b[38;2;255;255;255m update\u001b[0m\u001b[0m\n"] -[0.000002417,"o","\n"] -[0.000001708,"o"," "] -[0.00000375,"o","\u001b[1;38;2;0;163;224m-i, --identity\u001b[0m"] -[0.0000015,"o"," "] -[0.00000325,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] -[0.000001334,"o"," "] -[0.000109625,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mIdentity to use for authentication (use without value to\u001b[0m\u001b[38;2;255;255;255m select\u001b[0m\u001b[0m\n"] -[0.000004666,"o"," \u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255minteractively)\u001b[0m\u001b[0m\n"] -[0.000001167,"o","\n"] -[0.000001333,"o"," "] -[0.000009625,"o","\u001b[1;38;2;0;163;224m-s, --stack\u001b[0m"] -[0.000001417,"o"," "] -[0.000002292,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] -[0.000001083,"o"," "] -[0.000096875,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mStack\u001b[0m\u001b[38;2;255;255;255m name\u001b[0m\u001b[0m\n"] -[0.000001458,"o","\n"] -[0.000001042,"o","\n"] -[0.001017417,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1m--help=usage\u001b[0m\u001b[38;2;247;250;252m for examples or \u001b[0m\u001b[38;2;0;255;255;1m--help=all\u001b[0m\u001b[38;2;247;250;252m for all flags and full\u001b[0m\u001b[38;2;247;250;252m help.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] -[0.000026333,"o","\n \u001b[38;2;73;85;104mDocumentation:\u001b[0m \u001b[38;2;65;153;225mhttps://atmos.tools/cli/commands/terraform/terraform-backend\u001b[0m\n"] +[0.000039917,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;87;83;78;48;2;47;46;54m$ \u001b[0m\u001b[1;38;2;155;81;224;48;2;47;46;54matmos\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mterraform\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mbackend\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54mupdate\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[component]\u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m \u001b[0m\u001b[3;38;2;231;229;227;48;2;47;46;54m[flags]\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] +[0.000002,"o","\n"] +[0.000002833,"o","\u001b[1;38;2;0;163;224mEXAMPLES\u001b[0m\n"] +[9.17e-7,"o","\n"] +[0.000014083,"o"," \u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\u001b[38;2;231;229;227;48;2;47;46;54m\u001b[38;2;231;229;227;48;2;47;46;54matmos terraform backend update vpc --stack dev\u001b[0m\u001b[0m\u001b[48;2;47;46;54m \u001b[0m\n \u001b[48;2;47;46;54m \u001b[0m\n"] +[0.00000125,"o","\n"] +[0.000010667,"o","\u001b[1;38;2;0;163;224mFLAGS\u001b[0m\n"] +[0.000001916,"o","\n"] +[0.000097834,"o"," "] +[0.000002625,"o","\u001b[1;38;2;0;163;224m-h, --help\u001b[0m"] +[0.000001166,"o"," "] +[0.000098792,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mhelp for\u001b[0m\u001b[38;2;255;255;255m update\u001b[0m\u001b[0m\n"] +[0.000001375,"o","\n"] +[0.000001167,"o"," "] +[0.000002416,"o","\u001b[1;38;2;0;163;224m-i, --identity\u001b[0m"] +[0.000001667,"o"," "] +[0.000002375,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] +[0.000001042,"o"," "] +[0.000103041,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mIdentity to use for authentication (use without value to\u001b[0m\u001b[38;2;255;255;255m select\u001b[0m\u001b[0m\n"] +[0.000003792,"o"," \u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255minteractively)\u001b[0m\u001b[0m\n"] +[0.000001208,"o","\n"] +[0.00000125,"o"," "] +[0.000002959,"o","\u001b[1;38;2;0;163;224m-s, --stack\u001b[0m"] +[0.000001458,"o"," "] +[0.000001792,"o","\u001b[38;2;73;85;104mstring\u001b[0m"] +[0.000001208,"o"," "] +[0.000087792,"o","\u001b[38;2;255;255;255m\u001b[38;2;255;255;255m\u001b[0m\u001b[38;2;255;255;255m\u001b[0m \u001b[38;2;255;255;255m \u001b[0m\u001b[38;2;255;255;255mStack\u001b[0m\u001b[38;2;255;255;255m name\u001b[0m\u001b[0m\n"] +[0.000001375,"o","\n"] +[9.16e-7,"o","\n"] +[0.000868875,"o","\n\u001b[38;2;73;85;104m\u001b[38;2;247;250;252m\u001b[0m\u001b[38;2;247;250;252m\u001b[0m \u001b[38;2;247;250;252mUse \u001b[0m\u001b[38;2;0;255;255;1m--help=usage\u001b[0m\u001b[38;2;247;250;252m for examples or \u001b[0m\u001b[38;2;0;255;255;1m--help=all\u001b[0m\u001b[38;2;247;250;252m for all flags and full\u001b[0m\u001b[38;2;247;250;252m help.\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\u001b[0m\n"] +[0.0000155,"o","\n \u001b[38;2;73;85;104mDocumentation:\u001b[0m \u001b[38;2;65;153;225mhttps://atmos.tools/cli/commands/terraform/terraform-backend\u001b[0m\n"]