Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled error using multiple providers in stack configuration #897

Open
kylan11 opened this issue Dec 27, 2024 · 1 comment
Open

Unhandled error using multiple providers in stack configuration #897

kylan11 opened this issue Dec 27, 2024 · 1 comment
Labels
bug 🐛 An issue with the system

Comments

@kylan11
Copy link

kylan11 commented Dec 27, 2024

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/[email protected]/merge.go:180 +0x2c6a
dario.cat/mergo.merge({0x2886180, 0xc000c9f518}, {0x2ab0600, 0xc001a9d2f0}, {0xc0003beb60, 0x3, 0x1?})
        /home/kylan11/go/pkg/mod/dario.cat/[email protected]/merge.go:395 +0x2d3
dario.cat/mergo.Merge(...)
        /home/kylan11/go/pkg/mod/dario.cat/[email protected]/merge.go:319
github.com/cloudposse/atmos/pkg/merge.MergeWithOptions({0xc000dd16a0, 0x4, 0xc000f44dc0?}, 0x0, 0x1)
        /home/kylan11/go/pkg/mod/github.com/cloudposse/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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

@kylan11 kylan11 added the bug 🐛 An issue with the system label Dec 27, 2024
@aknysh
Copy link
Member

aknysh commented Dec 27, 2024

@kylan11 thank you for reporting this.

This case was def not tested - define a map in the defaults, and a list in the other manifests.

for now, the best way for you to move forward would be "making the _defaults.yaml provider a list of 1.".

We are going to review and improve this in the next Atmos releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

2 participants