In the docs I see that we can use custom commands ...
# atmos
a
In the docs I see that we can use custom commands to override an existing Terraform command, but this doesn't seem to work for me. Am I doing something wrong? https://atmos.tools/cli/configuration/commands#override-an-existing-terraform-command In my atmos.yaml:
Copy code
commands:
  - name: terraform
    description: Execute 'terraform' commands
    # subcommands
    commands:
      - name: plan
        description: This command executes 'terraform plan' on terraform components, passing in the current commit hash
        arguments:
          - name: component
            description: Name of the component
        flags:
          - name: stack
            shorthand: s
            description: Name of the stack
            required: true
        steps:
          - atmos terraform plan {{ .Arguments.component }} -s {{ .Flags.stack }} -- -var "commit=$(git rev-parse HEAD)"
It works if I don't attempt to override
terraform plan
-- if I change the command name to
foo
then I can run
atmos terraform foo $component -s $stack
and the commit gets passed in like I want. But I can't figure out how to override terraform plan.
e
Overriding this way may no longer be supported.
If you can share the error, that would help.
That said, we have plans support entirely overriding the behavior of any command, but it's on hold right now as we focus on overall stability.
a
There's no error, just that I can see in my plan output that the variable isn't being passed in
e
Aha, so it silently continues - probably just calling the built-in command.
a
Yes, seems so
e
Could I trouble you to open an issue for this? we'll confirm one way or another, as well as link to the upcoming feature that formally enables overriding commands.
That said, can you share what you want to accomplish?
-var "commit=$(git rev-parse HEAD)"
If this is it, there's a better way
a
Sure, would love to know a better way 🙂
e
Copy code
vars:
  commit: !exec git rev-parse HEAD
a
Trying to pass in a commit hash that we can add to tags of Azure resources:
Copy code
~ resource "azurerm_route_table" "this" {
      ~ tags                          = {
          ~ "commit"         = "$oldcommit" -> "$newcommit"
        }
    }
ah, that's pretty neat, let me try it
Adding the
!exec
worked great, thanks a lot!
🎉 1
I'll open up an issue for overriding commands as well
🙏 1