EKS AutoMode Terraform Deployment #5
This file contains hidden or 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: EKS AutoMode Terraform Deployment | |
| on: | |
| #push: | |
| # branches: | |
| # - main | |
| # paths: | |
| # - 'terraform/automode/**' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'terraform/automode/**' | |
| workflow_dispatch: | |
| inputs: | |
| action: | |
| description: "Specify the Terraform action: apply or destroy" | |
| required: true | |
| default: "apply" | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_DEFAULT_REGION: us-east-1 | |
| jobs: | |
| terraform: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: terraform/automode | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Set up Terraform | |
| uses: hashicorp/setup-terraform@v1 | |
| with: | |
| terraform_wrapper: true | |
| - name: Initialize Terraform | |
| run: terraform init | |
| - name: Validate Terraform | |
| run: terraform validate | |
| - name: Terraform Plan | |
| run: terraform plan | |
| - name: Execute Terraform Action | |
| run: | | |
| if [ "${{ github.event.inputs.action }}" == "destroy" ]; then | |
| terraform destroy -auto-approve | |
| else | |
| terraform apply -auto-approve | |
| fi |