cloudposse / cloudposse/atmos

Planfiles storage priority is ignored

Open
#2,368 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
1.4k
Forks
175
Avg merge
2d 3h
Merged PRs (30d)
134

Description

### Describe the Bug

The `priority` list under `components.terraform.planfiles` is documented as the way to choose which configured store atmos uploads/downloads planfiles from, but `createPlanfileStore` never reads it. With `priority` set and `default` unset, atmos falls through to environment-based detection and ends up trying to use `github/artifacts` even when a named S3 store is configured.

### Expected Behavior

Per [docs/ci/planfile-storage](https://atmos.tools/ci/planfile-storage):

```yaml
components:
terraform:
planfiles:
# Stores are tried in priority order
priority:
- "github"
- "s3"
- "local"
stores:
s3:
type: aws/s3
options:
bucket: my-planfiles
region: us-east-1
```

With this config, atmos should attempt the stores in the listed order. With a single-entry list (`priority: [s3]`), atmos should use the `s3` store.

### Steps to Reproduce

1. Configure planfile storage with a `priority` list and named stores, but no `default`:

```yaml
components:
terraform:
planfiles:
priority:
- s3
stores:
s3:
type: aws/s3
options:
bucket: my-planfile-bucket
region: ap-southeast-2
prefix: atmos/
```

2. Run `atmos terraform plan -s --ci` in a GitHub Actions workflow.
3. Observe the upload attempts `github/artifacts` instead of the configured `s3` store.

### Screenshots

_No response_

### Environment

- atmos version: v1.216.0
- Provider: GitHub Actions
- OS: ubuntu-latest

### Additional Context

## Root cause

In [pkg/ci/executor.go:166-208](https://github.com/cloudposse/atmos/blob/v1.216.0/pkg/ci/executor.go#L166), `createPlanfileStore` reads only `planfilesConfig.Default`:

```go
if opts.AtmosConfig != nil {
planfilesConfig := opts.AtmosConfig.Components.Terraform.Planfiles
if planfilesConfig.Default != "" {
if storeSpec, ok := planfilesConfig.Stores[planfilesConfig.Default]; ok {
// ... use this store
}
}
}

// Fall back to environment-based detection.
if envOpts := detectStoreFromEnv(); envOpts != nil {
// GITHUB_ACTIONS=true → github/artifacts
}
```

There is no read of `planfilesConfig.Priority`. The `isPlanfileStorageEnabled` check at [pkg/ci/plugins/terraform/handlers.go:723-727](https://github.com/cloudposse/atmos/blob/v1.216.0/pkg/ci/plugins/terraform/handlers.go#L723) does inspect `Priority`, so the storage code path is enabled, but the factory then ignores the list.

Contributor guide

Open the contributing guide

Research direction

Read createPlanfileStore in pkg/ci/executor.go:166-208 and compare it with the priority handling described in docs/ci/planfile-storage. Check the isPlanfileStorageEnabled logic in pkg/ci/plugins/terraform/handlers.go:723-727. Done means a configured priority list selects stores in order, including a single s3 entry when default is unset, instead of falling through to environment detection.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, github-actions, go, terraform
Domain
cli, cloud, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.