Skip to content

Adding Cognito module to Terraform #40

Adding Cognito module to Terraform

Adding Cognito module to Terraform #40

name: PR Terraform Plan
on: [pull_request]
permissions:
contents: read
pull-requests: write
jobs:
changed-files:
name: Get changed terraform directories
runs-on: ubuntu-latest
outputs:
module-change: ${{ steps.changed-files.outputs.module-change }}
project-change: ${{ steps.changed-files.outputs.project-change }}
environment-change: ${{ steps.changed-files.outputs.environment-change }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: dorny/paths-filter@v2
with:
filters: |
module-change:
- 'terraform-modules/**'
project-change:
- 'terraform-incubator/*/project/*.tf'
environment-change:
- 'terraform-incubator/*/!(project)/*.tf'
list-files: json
- name: List all changed files
run: |
echo "Module changes: ${{ steps.changed-files.outputs.module-change_files }}"
echo "Project changes: ${{ steps.changed-files.outputs.project-change_files }}"
echo "Environment changes: ${{ steps.changed-files.outputs.environment-change_files }}"
plan-all:
runs-on: ubuntu-latest
name: Terraform plan - all directories
needs: [changed-files]
if: ${{ fromJson(needs.changed-files.outputs.module-change_files).length > 0 }}
strategy:
matrix:
directory: ${{ fromJson(needs.changed-files.outputs.module-change_files) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.INCUBATOR_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.INCUBATOR_AWS_SECRET_ACCESS_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: terraform plan
uses: dflook/terraform-plan@v1
with:
path: ${{ matrix.directory }}
plan-project:
runs-on: ubuntu-latest
name: Terraform plan - Project changes
needs: [changed-files]
if: ${{ fromJson(needs.changed-files.outputs.project-change_files).length > 0 && fromJson(needs.changed-files.outputs.module-change_files).length == 0 }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.INCUBATOR_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.INCUBATOR_AWS_SECRET_ACCESS_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: terraform plan
uses: dflook/terraform-plan@v1
with:
path: terraform-incubator/people-depot/dev
plan-environment:
runs-on: ubuntu-latest
name: Terraform plan - Env changes
needs: [changed-files]
if: ${{ fromJson(needs.changed-files.outputs.environment-change_files).length > 0 && fromJson(needs.changed-files.outputs.module-change_files).length == 0 && fromJson(needs.changed-files.outputs.project-change_files).length == 0 }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.INCUBATOR_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.INCUBATOR_AWS_SECRET_ACCESS_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: terraform plan
uses: dflook/terraform-plan@v1
with:
path: terraform-incubator/people-depot/dev