Skip to content

variable added for ssh-key #9

variable added for ssh-key

variable added for ssh-key #9

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