Hey guys! Trying to use Atmos GitHub actions for m...
# atmos
t
Hey guys! Trying to use Atmos GitHub actions for my project and I'm stuck. Working right now on migrating slap-glued TF code (the usual stuff we all love) into Atmos framework for GCP project. I'm working on Atmos Terraform Plan at the moment. I'm using Determine Affected Stacks jobs to generate job matrix for components. It generates Plan jobs, but it seems underlying Terraform code is not executed in Plan at all, despite jobs are passing all green. I've added simple step
Atmos plan (raw)
that executes
atmos terraform plan
directly and then I get to see TF plan output
Copy code
- name: Atmos plan (raw)
        run: |
          set -eo pipefail
          echo "Component=${{ matrix.component }} | Stack=${{ matrix.stack }}"
          atmos terraform plan '${{ matrix.component }}' -s '${{ matrix.stack }}' -- -input=false -no-color | tee plan.txt
First time trying to reuse Atmos actions, so I'm assuming it is some kind of misconfig on my end. The catch is I'm using GCP, so I cannot simply set
integrations.github.gitops
with
artifact-storage
just yet. GCP storage API is compatible with S3 but I guess the authentication flow is a bit different (no AWS ARN roles and such). Not sure how much it affects the Action I'm trying to use though. Hoping for some direction! Snippet from my
atmos.yaml
:
Copy code
integrations:
  github:
      terraform-version: "1.13.1"
      infracost-enabled: false
      artifact-storage:
        plan-repository-type: "s3"
        metadata-repository-type: ""
        region: "us-xxxx"
        bucket: "toka-xxxxxxxx-bucket"
        table: ""
        role: ""
      role:
        plan: ""
        apply: ""
      matrix:
        sort-by: .stack_slug
        group-by: .stack_slug

components:
  terraform:
    [...]
    settings:
      github:
        actions_enabled: true
p
how are you calling the plan workflow when you create a PR?
are you using describe-affected action to find the components that changed?
t
im using this action
Copy code
- id: affected
        name: Atmos Affected Stacks
        uses: cloudposse/github-action-atmos-affected-stacks@v6
        with:
          atmos-config-path: ${{ env.ATMOS_CONFIG_PATH }}
          atmos-version: ${{ env.ATMOS_VERSION }}
          nested-matrices-count: 1
          install-atmos: false # We already installed it in the previous step

    outputs:
      matrix: ${{ steps.affected.outputs.matrix }}
      has-affected-stacks: ${{ steps.affected.outputs.has-affected-stacks }}
p
perfect, what does the matrix show?
you should have a matrix output from that action
which then you need to use to pass it to the plan action
t
yup and thats working fine, and I have generated TF plans
p
so, what is your problem? I'm confused
t
The problem is that
Atmos Terraform Plan
action does not produce TF Plans, does not trigger it, does not init terraform and make following steps etc. Below snippet from action output:
Copy code
Run cloudposse/github-action-atmos-terraform-plan@v5
Run actions/checkout@v4
[...]
Run cloudposse/github-action-setup-atmos@v2
Run cloudposse/github-action-atmos-get-setting@v2
Run cat << EOF > aqua.yaml
Run echo "${AQUA_ROOT_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/aquaproj-aqua}/bin" >> $GITHUB_PATH
Run if [ "${SKIP_INSTALL_AQUA:-}" = true ] && command -v aqua >/dev/null; then
Run aqua i $AQUA_OPTS
Run if [[ -f "" ]]; then
Run if [[ "false" == "true" ]]; then
 found
Drift detection mode disabled
Run echo "rand=$(openssl rand -hex 5)" >> "$GITHUB_OUTPUT"
p
usually that is because of the
Copy code
settings:
      github:
        actions_enabled: true
that is missplaced in the yaml
t
I was hoping that using
cloudposse/github-action-atmos-terraform-plan@v5
will produce plans, save them in buckets if possible and add comments into PRs
p
do you see anything happening here
Run cloudposse/github-action-atmos-get-setting@v2
?
you should see the action_enable in the get settings
t
Im using latest version of actions since Im starting from scratch basically. I've added
Copy code
components:
  terraform:
    settings:
      github:
        actions_enabled: true
into main
amots.yaml
file
p
we have settings as a global
t
do you see anything happening here
Run cloudposse/github-action-atmos-get-setting@v2
?
I see all the detected components like so:
Copy code
- component: folder_xxxxxxx
    stack: 01-xxxxxxxx-folder-global-hq
    settingsPath: settings.integrations.github.gitops.artifact-storage.blob-container-name
    outputPath: blob-container-name
p
Copy code
settings:
  azure:
    XXX
  github:
    actions_enabled: true
  integrations:
    github:
      gitops:
        terraform-version: 1.12.2`
fb wow 1
that is at the same level than terraform
t
That is defined at component level or globally within atmos.yaml?
p
I put in as an import on my stacks
t
Ok so stacks/component level. Will try that!
p
I do not have anything on atmos.yaml
t
That actually makes sense now
@PePe Amengual adding that import hepled! I think reading this from Action README
Copy code
For example, to migrate from v1 to v2, you should have something similar to the following in your atmos.yaml
made me think I need to have it in main
atmos.yaml
file. Thanks a lot!
p
No problem
❤️ 1