-
Notifications
You must be signed in to change notification settings - Fork 7
53 lines (44 loc) · 1.53 KB
/
aws_create_deployment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Create HydroServer AWS Cloud Deployment
on:
workflow_dispatch:
inputs:
environment:
description: 'Enter a deployment environment name.'
required: true
permissions:
id-token: write
contents: read
jobs:
setup-deployment:
runs-on: ubuntu-20.04
environment: ${{ github.event.inputs.environment }}
defaults:
run:
working-directory: ./terraform/aws
env:
AWS_DEFAULT_REGION: "us-east-1"
steps:
- name: configureawscredentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/${{ vars.AWS_IAM_ROLE }}
role-session-name: create-hydroserver-resources
aws-region: ${{env.AWS_DEFAULT_REGION}}
- name: Checkout Repo
uses: actions/checkout@v3
with:
ref: main
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
- name: Terraform Init
id: init
run: terraform init -backend-config="key=state/aws_application_${{ github.event.inputs.environment }}"
- name: Terraform Plan
id: plan
run: terraform plan -no-color -var instance="${{ github.event.inputs.environment }}"
continue-on-error: true
- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1
- name: Terraform Apply
run: terraform apply -auto-approve -var instance="${{ github.event.inputs.environment }}"