Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add IAM auth support (required for stack config templating as of atmos 1.86.2) #33

Merged
merged 5 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading