-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (58 loc) · 1.67 KB
/
packer_terraform_provision.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Packer and Terraform Provision
on:
push:
branches:
- main
workflow_dispatch:
jobs:
provision-packer:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_key }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Packer
id: setup
uses: hashicorp/setup-packer@main
- name: Initialize Packer
id: initpacker
run: packer init ./image-builder/
- name: Format Packer
id: fmtpacker
run: packer fmt ./image-builder/
- name: Validate Packer
id: validate
run: packer validate ./image-builder/
- name: Build Image
id: build
run: packer build ./image-builder/
provision-terraform:
runs-on: ubuntu-latest
needs: provision-packer
env:
TF_VAR_awskey01: ${{ secrets.ssh_private_key }}
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_key }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
id: setupterraform
- name: Terraform Init
id: initailizeterraform
run: terraform init -migrate-state
- name: Format Terraform
id: formatterraform
run: terraform fmt
- name: Validate Terraform
id: validateterraform
run: terraform validate
- name: Terraform Plan
id: plan
run: terraform plan -input=false
- name: Terraform Apply
id: apply
run: terraform apply --auto-approve