Unhandled error using multiple providers in stack configuration
- Dominant language
- Go
- Stars
- 1.4k
- Forks
- 175
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 134
Description
### Describe the Bug
I am using a modified version of the "dns-delegated" component that does not require account-map, instead takes in two providers, as shown below:
```
dns-delegated:
providers:
aws:
- region: eu-west-1
alias: delegated
assume_role:
role_arn: arn:aws:iam::1234567890:role/admin
- region: eu-west-1
metadata:
component: aws/networking/dns-delegated
vars:
enabled: true
```
And as described here: https://atmos.tools/core-concepts/components/terraform/providers/
When running atmos, the following error occurs:
```
❯ atmos
█████ ████████ ███ ███ ██████ ███████
██ ██ ██ ████ ████ ██ ██ ██
███████ ██ ██ ████ ██ ██ ██ ███████
██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██████ ███████
panic: reflect: call of reflect.Value.Index on map Value
goroutine 27 [running]:
reflect.Value.Index({0x2ab0600?, 0xc001a9d1a0?, 0xcc00d694698?}, 0x28da8e0?)
/usr/lib/go/src/reflect/value.go:1432 +0x154
dario.cat/mergo.deepMerge({0x2ab0600?, 0xc000c9f518?, 0x2ab0600?}, {0x2ab0600?, 0xc001a9d2f0?, 0xc000dd05
f0?}, 0xc000dd06a0, 0x0, 0xc0013fb458)
/home/kylan11/go/pkg/mod/dario.cat/mergo@v1.0.1/merge.go:180 +0x2c6a
dario.cat/mergo.merge({0x2886180, 0xc000c9f518}, {0x2ab0600, 0xc001a9d2f0}, {0xc0003beb60, 0x3, 0x1?})
/home/kylan11/go/pkg/mod/dario.cat/mergo@v1.0.1/merge.go:395 +0x2d3
dario.cat/mergo.Merge(...)
/home/kylan11/go/pkg/mod/dario.cat/mergo@v1.0.1/merge.go:319
github.com/cloudposse/atmos/pkg/merge.MergeWithOptions({0xc000dd16a0, 0x4, 0xc000f44dc0?}, 0x0, 0x1)
/home/kylan11/go/pkg/mod/github.com/cloudposse/atmos@v1.110.0/pkg/merge/merge.go:68 +0x293
github.com/cloudposse/atmos/pkg/merge.Merge({{0xc0000581d0, 0x26}, {{{0xc000c921e0, 0x13}, 0x0, {0xc000c9
a9f0, 0x2f}, 0x1, 0x1, 0x1, ...}, ...}, ...}, ...)
/home/kylan11/go/pkg/mod/github.com/cloudposse/atmos@v1.110.0/pkg/merge/merge.go:105 +0x1ef
github.com/cloudposse/atmos/internal/exec.ProcessStackConfig({{0xc0000581d0, 0x26}, {{{0xc000c921e0, 0x13
}, 0x0, {0xc000c9a9f0, 0x2f}, 0x1, 0x1, 0x1, ...}, ...}, ...}, ...)
/home/kylan11/go/pkg/mod/github.com/cloudposse/atmos@v1.110.0/internal/exec/stack_processor_utils
.go:1008 +0x45d4
github.com/cloudposse/atmos/internal/exec.ProcessYAMLConfigFiles.func1(0x5, {0xc0009e36d0, 0x4d})
/home/kylan11/go/pkg/mod/github.com/cloudposse/atmos@v1.110.0/internal/exec/stack_processor_utils
.go:103 +0x7e5
created by github.com/cloudposse/atmos/internal/exec.ProcessYAMLConfigFiles in goroutine 1
/home/kylan11/go/pkg/mod/github.com/cloudposse/atmos@v1.110.0/internal/exec/stack_processor_utils
.go:58 +0x145
```
This stack's _defaults.yaml uses a single provider (not a list):
```
terraform:
providers:
aws:
region: "eu-west-1"
assume_role:
role_arn: arn:aws:iam::1234567890:role/admin
```
list_merge_strategy is set to "merge".
There are multiple ways to fix, including:
- setting list_merge_strategy to replace or append (this results in a correctly handled error message)
- deleting one of the providers, making it an object
- making the _defaults.yaml provider a list of 1.
### Expected Behavior
Atmos should either handle the use case of merging a single provider object to a list, or showing an handled error message.
### Steps to Reproduce
Outlined in the bug description
### Screenshots
_No response_
### Environment
_No response_
### Additional Context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.