This message was deleted.
# atlantis-community
s
This message was deleted.
p
repos.yaml passing json?
I’m confused
I think this is expecting you pass the json for the whole repo config
the whole json
n
oh duh, yeah that wouldn’t even work, how would i actually set up a repo config then?
p
just pass the config to it as a whole
n
p
yes, that is to pass the file that should be in the container
you can do it both ways
n
yeah what i had converted the yaml file to json and then added the config there, but i’m not sure if it was working
so i’ll try just passing the path of the yaml file and see if that works
p
ok
keep us updated
n
oh wait, i’m not sure that will work because the repos.yaml file was never written to disk and that other one is just looking for a path.
hmmmm
The reason i think it isn’t picking up my file is because when i run
atlantis plan -d stacks/artillery/
i get this error
Copy code
Ran Plan for dir: stacks/artillery workspace: default

Plan Error

running "/usr/local/bin/terraform plan -input=false -refresh -out \"/root/.atlantis/repos/rakuten-shopstyle/shopstyle-cdk/1192/default/stacks/artillery/default.tfplan\"" in "/root/.atlantis/repos/rakuten-shopstyle/shopstyle-cdk/1192/default/stacks/artillery": exit status 1
╷
│ Error: No configuration files
│ 
│ Plan requires configuration to be present. Planning without a configuration
│ would mark everything for destruction, which is normally not what is
│ desired. If you would like to destroy everything, run plan with the
│ -destroy option. Otherwise, create a Terraform configuration file (.tf
│ file) and try again.
╵
my repo.yaml file btw
p
so then just pass the json content to the previous flag
that is a normal practice
n
ok, so i still get the plan error above, how do i know if it’s actually getting that config?
p
logs in the container
enable debug
it will tell you about reading the config and such
n
so it looks like it’s getting it but error out when looking for a plan. my repo looks like this which i think is pretty standard for a cdk repo. it says “plan requires configuration to be present” it doesn’t look like it’s actually able to find the config file and doesn’t look like it even tries to run the pre-workflow hooks here is my repo style for reference
Copy code
- lib (for custom library stuff)
- scripts
- stacks
  - stack-name
    - main.py
    - cdktf.json
    - cdktf.out
      - stacks/atlantis-ops-us-east-1
        - .terraform
        - .terraform.lock.hcl
        - cdk.tf.json
      - manifest.json
  - stack-name
    - main.py
    - cdktf.json
    - cdktf.out
      - stacks/atlantis-ops-us-east-1
        - .terraform
        - .terraform.lock.hcl
        - cdk.tf.json
      - manifest.json
p
@RB have run CDK
n
anybody here have experience working with cdktf? the debug logs don’t seem to show me much and no matter what i get an error that looks like this. logs definitely make it seem like it’s getting the pre-workflow hooks, but that’s only because when it wasn’t, it was giving me an error.
Copy code
{
  "level": "error",
  "ts": "2024-02-09T19:17:36.977Z",
  "caller": "models/shell_command_runner.go:158",
  "msg": "running \"/root/.tfenv/bin/terraform plan -input=false -refresh -out \\\"/root/.atlantis/repos/rakuten-shopstyle/shopstyle-cdk/1184/default/stacks/atlantis/default.tfplan\\\"\" in \"/root/.atlantis/repos/rakuten-shopstyle/shopstyle-cdk/1184/default/stacks/atlantis\": exit status 1",
  "json": {
    "repo": "rakuten-shopstyle/shopstyle-cdk",
    "pull": "1184",
    "duration": 0.048867454
  },
  "stacktrace": "<http://github.com/runatlantis/atlantis/server/core/runtime/models.(*ShellCommandRunner).RunCommandAsync.func1|github.com/runatlantis/atlantis/server/core/runtime/models.(*ShellCommandRunner).RunCommandAsync.func1>\n\t/home/runner/work/atlantis/atlantis/server/core/runtime/models/shell_command_runner.go:158"
}
r
I ran it a while ago and it was successful with a custom workflow.
Looks like atlantis hides the error
n
was the custom workflow anything more than just this?
Copy code
repos:
  - id: /.*cdktf.*/
    pre_workflow_hooks:
      - run: make init && make install && npm i && cdktf synth --output ci-cdktf.out
      #- run: npm i && cdktf get && cdktf synth --output ci-cdktf.out
r
Could you try simplifying your pre workflow to just
echo "hello world"
or similarly trivial to see if you can avoid the error
this way we will know if its the workflow causing an error
are you using a custom container with npm and cdktf installed ?
n
yeah i’ll try that, and yep have both installed
hmmm, doesn’t seem like it’s getting run
i don’t see a mention of hello world anywhere in the logs
Copy code
repos:
  - id: /.*cdktf.*/
    pre_workflow_hooks:
      - run: echo "hello world"
let me try it with
/.*/
instead
ok that shows up, so it doesn’t like the /.*cdktf.*/ even though there’s pretty clearly a cdktf.json file in the directory i’m pointing too
does atlantis not look at the directory i’m pointing to when running that pre workflow hook?
p
- id: /.*cdktf.*/
is for the repo name not the content of the repo
n
ohhhhh, alright I was understanding it as looking for a folder that contained a file that contained cdktf in it
so does this just run at the root of the repo?
p
at the root of the checkout of the PR
n
hmmm okay, that’s not ideal, is there a way to run it in the directory that you specify? or a directory with changes to them that also has a file containing cdktf.json or something?
p
you need to have a atlantis.yaml and a custom workflow
repo.yaml is a config for all repos
atlantis.yaml can be configured for repo level specific actions
n
we’re only using it for one repo right now, but okay that makes sense, that gets rid of the autodiscovery though right?
p
not necessarily
n
hmmm okay, i’ll give it a try
is there a way to do this for like 100 stacks in the same repo without having to modify the stacks each time?
p
you can run a post_workflow hook to autogenerate the atlantis.yaml file
there is examples in the docs
n
oh so we would need to write a script for that?
or is there a script someone made i can yoink from?
p
look at the docs
see first if what you need is available on the atlantis.yaml
there is even a cdk section