This message was deleted.
# atlantis-community
s
This message was deleted.
c
ok so it required me adding
version: 3
to this file... so it ran but those variables don't seem to be added to the plan so getting
No value for required variable
still in the atlantis plan output
d
So you are trying to update the workflow in the Server Config with the repo config? You can only define it once.
environment variables are project specific
d
Luke is no longer on the project, that's a 5 year old issue
c
and since I need to leverage things like TOKEN from secret can't commit that to tfvars file
I just wanted to post that where it was documented because it's not working as expected... or at least how I'm understanding it to be expected
I'm also using the default built in workflow so I was only able to get jobs to start triggering on atlantis with open Merge Request... before that regular pushes to the repo didn't trigger anything in the pipelines... only after I opened an ongoing MR it showed up... not sure if that's configurable or not
d
Okay, I understand. Please open a new issue in the future and tag the closed issue
βœ… 1
There's a lot of missing context here as well as multiple questions. I would suggest a GH issue and post both your repo and server config.
c
i deployed Atlantis with Fargate it's using default server config... where can I get that from?
d
just using
env
step won't do anything, and I'm guessing that workflow isn't being used properly
c
I added the custom workflows to the terragrunt project but haven't been able to figure out how to get the TF project to trigger the TG project when commits are made... (basically to see if it breaks anything in the TG environments deployed using that module)
I figured both of these were more discussions than bugs/features but if it makes more sense to have over in GH then I'm okay with having that there. Thanks
πŸ‘ 1
as an example
c
@PePe Amengual this is still workflow within same repo (just one dir referring to another dir)... The request is for 2 repos (module) and Terragrunt wrapper around that module. So when the module changes it kicks off plan for the TG wrapper so we can see what that module change does when planned against multiple environments
@PePe Amengual as far as the ENV issue I'm tried just that:
Copy code
version: 3
workflows:
  default:
    plan:
      steps:
      - env:
          name: TF_VAR_aws_account_id
          value: "1111111111111"
      - env:
          name: TF_VAR_gitlab_token
          command: 'echo "$ATLANTIS_GITLAB_TOKEN"'
      - env:
          name: TF_VAR_aws_region
          value: "us-east-1"
      - env:
          name: TF_VAR_account_name
          value: "awsdev"
and none of these are available when atlantis runs the plan complains about missing variables
aws_account_id
,
gitlab_token
,
aws_region
and
account_name
the server config looks like:
Copy code
repos:
  - id: /.*/
    allow_custom_workflows: true
    allowed_overrides:
      - apply_requirements
      - workflow
    apply_requirements:
      - approved
    workflow: default
so based on the docs that
altantis.yaml
which is setting those 4 environment variables should be working when the project MR is sent to the webhook
p
FYI atlantis will spawn a shell for the plan step and another for apply step
that means the ENV variables are lost between steps
so you need to repeat them
c
this is the gitlab webhook documentation so nothing I'm doing specifically
Comment from Atlantis shows: Ran Plan for dir:
.
workspace:
default
Copy code
running "/home/atlantis/.atlantis/bin/terraform1.7.3 plan -input=false -refresh -out \"/home/atlantis/.atlantis/repos/gitops/infra/eks_cluster/24/default/default.tfplan\"" in "/home/atlantis/.atlantis/repos/gitops/infra/eks_cluster/24/default": exit status 1
β•·
β”‚ Error: No value for required variable
β”‚ 
β”‚   on <http://variables.tf|variables.tf> line 27:
β”‚   27: variable "account_name" {
β”‚ 
β”‚ The root module input variable "account_name" is not set, and has no
β”‚ default value. Use a -var or -var-file command line argument to provide a
β”‚ value for this variable.
β•΅
β•·
β”‚ Error: No value for required variable
β”‚ 
β”‚   on <http://variables.tf|variables.tf> line 30:
β”‚   30: variable "aws_account_id" {
β”‚ 
β”‚ The root module input variable "aws_account_id" is not set, and has no
β”‚ default value. Use a -var or -var-file command line argument to provide a
β”‚ value for this variable.
β•΅
β•·
β”‚ Error: No value for required variable
β”‚ 
β”‚   on <http://variables.tf|variables.tf> line 38:
β”‚   38: variable "gitlab_token" {
β”‚ 
β”‚ The root module input variable "gitlab_token" is not set, and has no
β”‚ default value. Use a -var or -var-file command line argument to provide a
β”‚ value for this variable.
β•΅
β•·
β”‚ Error: No value for required variable
β”‚ 
β”‚   on <http://variables.tf|variables.tf> line 58:
β”‚   58: variable "aws_region" {
β”‚ 
β”‚ The root module input variable "aws_region" is not set, and has no default
β”‚ value. Use a -var or -var-file command line argument to provide a value for
β”‚ this variable.
β•΅
@PePe Amengual I'm not looking to do apply... this is just plan steps and it's still not taking the TF_VAR environment vars passed in the repo's
atlantis.yaml
p
can you run a echo.command before plan to see if the ENVs are present ?
c
where would that be added to this atlantis.yaml?
Copy code
version: 3
workflows:
  default:
    plan:
      steps:
      - env:
          name: TF_VAR_aws_account_id
          value: "11111111111"
      - env:
          name: TF_VAR_gitlab_token
          command: 'echo "$ATLANTIS_GITLAB_TOKEN"'
      - env:
          name: TF_VAR_aws_region
          value: "us-east-1"
      - env:
          name: TF_VAR_account_name
          value: "capdev"
p
like echo MYVAR && terraform plan
c
I'm using the built-in default workflow... nothing in my server-atlantis.yaml has a command set... and this is what's in my repo's atlantis.yaml ... so do I add something to these steps? I just don't think these steps are being hit since it's not finding those variables... also since I'm using the default workflow and it's not defined anywhere I'm not sure best way to make this a full custom workflow... is the default yaml posted somewhere in git so I can customize it? As far as I have read the env overrides like this should work
p
you can customize the default workflow
just like you are doing with env
you can just do run: echo MYVAR
c
so I couldn't get this to work with
default
but if I add the following to make a custom workflow it seems to not complain about the variables missing:
Copy code
version: 3
projects:
- name: eks_cluster
  dir: .
  workflow: terraform
workflows:
  terraform:
    plan:
      steps:
        - env:
            name: TF_VAR_aws_account_id
            value: "11111111111"
        - env:
            name: TF_VAR_gitlab_token
            command: 'echo "$ATLANTIS_GITLAB_TOKEN"'
        - env:
            name: TF_VAR_aws_region
            value: "us-east-1"
        - env:
            name: TF_VAR_account_name
            value: "capdev"
        - init
        - plan
so only thing I did different was add a
projects
block and change
default
to
terraform
and then add an
init
and
plan
at bottom... now my error is slightly different due to an STS assume thing but that's something I can work out... but if this should work for default then it doesn't make much sense to me as to why it wasn't working with what I had before
p
that is interesting
unless you had bad indentention or invalid yaml?
d
I haven't tested it, but I wouldn't be surprised if you can't override the default workflow from the repo config because it already exists in the server config, Haven't tested it out
p
ohhhhhh good point
you are right, that could be the issue and plus the repos.yaml might now have :
Copy code
# allowed_overrides specifies which keys can be overridden by this repo in
  # its atlantis.yaml file.
  allowed_overrides: [apply_requirements, workflow, delete_source_branch_on_merge, repo_locking, custom_policy_check]
Copy code
allowed_overrides: [ workflow]
he does have that…
that is a good test, move the workflow definition to repos.yaml
c
with Fargate deployment I've done the server json config but not sure how you set a repos.yaml (also don't fully understand the difference)... if I have a server.yaml and then in the repo an atlantis.yaml ... why would I need a repos.yaml if the server.yaml is a regex for all repos?
c
still need to figure out how to do this in a Fargate deployment
p
the server.json is basically the config flags for atlantis ( server binary flags)
then you need the repo.yaml to be passed too
for example :
atlantis server --config=atlantis-server-config.yaml
Copy code
#atlantis-url: "localhost"
gh-user: jamengual
gh-token: "SDFSFGSFSDGSDFGSDFGSDFGSDFGSDFG"
repo-allowlist: "*"
gh-webhook-secret: "#$%%$$%$%#%#$%%#"
repo-config: atlantis-repo-config.yaml
enable-diff-markdown-format: true
silence-vcs-status-no-plans: true
hide-prev-plan-comments: true 
log-level: debug
atlantis-url: "<http://localhost:4141>"
api-secret: "$%^$%^$%^$^DFGDFGDFGDFG"
# enable-regexp-cmd: true
atlantis-repo-config.yaml
Copy code
repos:
- id: /.*/
  allowed_overrides: [apply_requirements, workflow, delete_source_branch_on_merge]
  allow_custom_workflows: true
  apply_requirements: [mergeable]
atlantis-server-config.yaml
could be pass all as flags to the container definition