Skip to content

Commit f1ee039

Browse files
authored
feat: add IAM auth support (required for stack config templating as of atmos 1.86.2) (#33)
* Added aws auth * Added aws auth * Added aws auth * Added aws auth * Added aws auth
1 parent c116ef6 commit f1ee039

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

.github/workflows/test-matrix-2-levels.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
# pull_request: {}
88
workflow_dispatch: {}
99

10+
permissions:
11+
id-token: write
12+
contents: read
13+
1014
jobs:
1115
setup:
1216
runs-on: ubuntu-latest
@@ -21,10 +25,17 @@ jobs:
2125
steps:
2226
- name: Checkout
2327
uses: actions/checkout@v4
28+
29+
- shell: bash
30+
run: |
31+
mkdir -p ${{ runner.temp }}
32+
cp ./tests/atmos.yaml ${{ runner.temp }}/atmos.yaml
33+
sed -i -e 's#__PLAN_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
34+
2435
- uses: ./
2536
id: current
2637
with:
27-
atmos-config-path: "./tests"
38+
atmos-config-path: "${{ runner.temp }}"
2839
select-filter: '.settings.github.actions_enabled // false'
2940
nested-matrices-count: '2'
3041

.github/workflows/test-matrix-3-levels.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
# pull_request: {}
88
workflow_dispatch: {}
99

10+
permissions:
11+
id-token: write
12+
contents: read
13+
1014
jobs:
1115
setup:
1216
runs-on: ubuntu-latest
@@ -22,10 +26,16 @@ jobs:
2226
- name: Checkout
2327
uses: actions/checkout@v4
2428

29+
- shell: bash
30+
run: |
31+
mkdir -p ${{ runner.temp }}
32+
cp ./tests/atmos.yaml ${{ runner.temp }}/atmos.yaml
33+
sed -i -e 's#__PLAN_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
34+
2535
- uses: ./
2636
id: current
2737
with:
28-
atmos-config-path: "./tests"
38+
atmos-config-path: "${{ runner.temp }}"
2939
select-filter: '.settings.github.actions_enabled // false'
3040
nested-matrices-count: '3'
3141

.github/workflows/test-positive.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
# pull_request: {}
88
workflow_dispatch: {}
99

10+
permissions:
11+
id-token: write
12+
contents: read
13+
1014
jobs:
1115
setup:
1216
runs-on: ubuntu-latest
@@ -22,10 +26,16 @@ jobs:
2226
- name: Checkout
2327
uses: actions/checkout@v4
2428

29+
- shell: bash
30+
run: |
31+
mkdir -p ${{ runner.temp }}
32+
cp ./tests/atmos.yaml ${{ runner.temp }}/atmos.yaml
33+
sed -i -e 's#__PLAN_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
34+
2535
- uses: ./
2636
id: current
2737
with:
28-
atmos-config-path: "./tests"
38+
atmos-config-path: "${{ runner.temp }}"
2939

3040
outputs:
3141
selected-components: "${{ steps.current.outputs.selected-components }}"

action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ runs:
8282
echo "terraform-version=$(atmos describe config -f json | jq -r '.integrations.github.gitops["terraform-version"]')" >> $GITHUB_OUTPUT
8383
echo "group-by=$(atmos describe config -f json | jq -r '.integrations.github.gitops.matrix["group-by"]')" >> $GITHUB_OUTPUT
8484
echo "sort-by=$(atmos describe config -f json | jq -r '.integrations.github.gitops.matrix["sort-by"]')" >> $GITHUB_OUTPUT
85+
echo "aws-region=$(atmos describe config -f json | jq -r '.integrations.github.gitops["artifact-storage"].region')" >> $GITHUB_OUTPUT
86+
echo "terraform-plan-role=$(atmos describe config -f json | jq -r '.integrations.github.gitops.role.plan')" >> $GITHUB_OUTPUT
8587
8688
- name: Install Terraform
8789
if: ${{ steps.config.outputs.terraform-version != '' && steps.config.outputs.terraform-version != 'null' }}
@@ -99,6 +101,14 @@ runs:
99101
opentofu/opentofu:
100102
tag: ${{ startsWith(steps.config.outputs.opentofu-version, 'v') && steps.config.outputs.opentofu-version || format('v{0}', steps.config.outputs.opentofu-version) }}
101103
104+
- name: Configure Plan AWS Credentials
105+
uses: aws-actions/configure-aws-credentials@v4
106+
with:
107+
aws-region: ${{ steps.config.outputs.aws-region }}
108+
role-to-assume: ${{ steps.config.outputs.terraform-plan-role }}
109+
role-session-name: "atmos-terraform-plan-gitops"
110+
mask-aws-account-id: "no"
111+
102112
- name: Filter Components
103113
id: selected-components
104114
shell: bash

tests/atmos.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ integrations:
7070
table: cptest-core-ue2-auto-gitops-plan-storage
7171
role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha
7272
role:
73-
plan: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops
73+
plan: __PLAN_ROLE__
7474
apply: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops
7575
matrix:
7676
sort-by: .stack_slug

0 commit comments

Comments
 (0)