added http group to bastion #70
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Connect to an AWS role from a GitHub repository | |
on: | |
push: | |
branches: | |
- main | |
- task_* | |
pull_request: | |
branches: | |
- main | |
- task_* | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
AWS_REGION: "eu-central-1" | |
jobs: | |
terraform-check: | |
defaults: | |
run: | |
working-directory: terraform | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git pull | |
uses: actions/checkout@v4 | |
- name: Configure AWS Credentials v1 | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
role-to-assume: ${{ secrets.AWS_GITHUB_ROLE_ARN }} | |
- name: Set up Terraform | |
uses: hashicorp/setup-terraform@v3 | |
- name: Terraform init | |
run: terraform init | |
- name: Create terraform cache | |
uses: actions/cache/save@v4 | |
with: | |
path: ./terraform/.terraform* | |
key: terraform-cache-${{ github.run_id }} | |
- name: Terraform Check | |
run: terraform fmt && terraform fmt -check | |
terraform-plan: | |
defaults: | |
run: | |
working-directory: terraform | |
needs: [ terraform-check ] | |
name: Terraform Plan | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git pull | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials v2 | |
id: aws_setup | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_GITHUB_ROLE_ARN }} | |
role-session-name: GitHub_to_AWS | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Restore terraform cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: ./terraform/.terraform* | |
key: terraform-cache-${{ github.run_id }} | |
fail-on-cache-miss: true | |
- name: Terraform Plan | |
run: terraform plan -input=false | |
# -input=false for noninteractive | |
terraform-apply: | |
defaults: | |
run: | |
working-directory: terraform | |
if: github.ref == 'refs/heads/task_2' | |
needs: [ terraform-check, terraform-plan ] | |
name: Terraform Apply | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git pull | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials v3 | |
id: aws_setup | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_GITHUB_ROLE_ARN }} | |
role-session-name: GitHub_to_AWS | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Restore terraform cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: ./terraform/.terraform* | |
key: terraform-cache-${{ github.run_id }} | |
fail-on-cache-miss: true | |
- name: Terraform Apply | |
run: terraform apply -auto-approve |