Skip to content

Commit

Permalink
feat: add IAM auth support (required for stack config templating as o…
Browse files Browse the repository at this point in the history
…f atmos 1.86.2) (#33)

* Added aws auth

* Added aws auth

* Added aws auth

* Added aws auth

* Added aws auth
  • Loading branch information
goruha authored Sep 12, 2024
1 parent c116ef6 commit f1ee039
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/test-matrix-2-levels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
# pull_request: {}
workflow_dispatch: {}

permissions:
id-token: write
contents: read

jobs:
setup:
runs-on: ubuntu-latest
Expand All @@ -21,10 +25,17 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- shell: bash
run: |
mkdir -p ${{ runner.temp }}
cp ./tests/atmos.yaml ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__PLAN_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
- uses: ./
id: current
with:
atmos-config-path: "./tests"
atmos-config-path: "${{ runner.temp }}"
select-filter: '.settings.github.actions_enabled // false'
nested-matrices-count: '2'

Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/test-matrix-3-levels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
# pull_request: {}
workflow_dispatch: {}

permissions:
id-token: write
contents: read

jobs:
setup:
runs-on: ubuntu-latest
Expand All @@ -22,10 +26,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- shell: bash
run: |
mkdir -p ${{ runner.temp }}
cp ./tests/atmos.yaml ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__PLAN_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
- uses: ./
id: current
with:
atmos-config-path: "./tests"
atmos-config-path: "${{ runner.temp }}"
select-filter: '.settings.github.actions_enabled // false'
nested-matrices-count: '3'

Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/test-positive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
# pull_request: {}
workflow_dispatch: {}

permissions:
id-token: write
contents: read

jobs:
setup:
runs-on: ubuntu-latest
Expand All @@ -22,10 +26,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- shell: bash
run: |
mkdir -p ${{ runner.temp }}
cp ./tests/atmos.yaml ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__PLAN_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
- uses: ./
id: current
with:
atmos-config-path: "./tests"
atmos-config-path: "${{ runner.temp }}"

outputs:
selected-components: "${{ steps.current.outputs.selected-components }}"
Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ runs:
echo "terraform-version=$(atmos describe config -f json | jq -r '.integrations.github.gitops["terraform-version"]')" >> $GITHUB_OUTPUT
echo "group-by=$(atmos describe config -f json | jq -r '.integrations.github.gitops.matrix["group-by"]')" >> $GITHUB_OUTPUT
echo "sort-by=$(atmos describe config -f json | jq -r '.integrations.github.gitops.matrix["sort-by"]')" >> $GITHUB_OUTPUT
echo "aws-region=$(atmos describe config -f json | jq -r '.integrations.github.gitops["artifact-storage"].region')" >> $GITHUB_OUTPUT
echo "terraform-plan-role=$(atmos describe config -f json | jq -r '.integrations.github.gitops.role.plan')" >> $GITHUB_OUTPUT
- name: Install Terraform
if: ${{ steps.config.outputs.terraform-version != '' && steps.config.outputs.terraform-version != 'null' }}
Expand All @@ -99,6 +101,14 @@ runs:
opentofu/opentofu:
tag: ${{ startsWith(steps.config.outputs.opentofu-version, 'v') && steps.config.outputs.opentofu-version || format('v{0}', steps.config.outputs.opentofu-version) }}
- name: Configure Plan AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ steps.config.outputs.aws-region }}
role-to-assume: ${{ steps.config.outputs.terraform-plan-role }}
role-session-name: "atmos-terraform-plan-gitops"
mask-aws-account-id: "no"

- name: Filter Components
id: selected-components
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion tests/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ integrations:
table: cptest-core-ue2-auto-gitops-plan-storage
role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha
role:
plan: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops
plan: __PLAN_ROLE__
apply: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops
matrix:
sort-by: .stack_slug
Expand Down

0 comments on commit f1ee039

Please sign in to comment.