Application Deployment on AWS through HashiCorp is an opinionated CI/CD GitHub Action that
- packages application into and registers AMI image on AWS, then
- deploys an EC2 instance of that AMI onto AWS
HashiCorp AWS action follows HashiCrop's best practice by expecting a directory called hashicorp located at the root of the repository. An example structure looks like this:
.
└── my-app-repository/
├── hashicorp/
│ ├── images/
│ │ └── aws-my-app.pkr.hcl
│ ├── instances/
│ │ └── aws-my-app.tf
├── src
└── ...
- The aws-my-app.pkr.hcl is the standard HashiCorp Packer Template file
- The aws-my-app.tf is the standard HashiCorp Terraform Config File
Under regular .github/workflows
directory, create a .yml
file with a preferred name with the following example
contents:
---
name: My App CI/CD
"on":
pull_request:
push:
branches:
- master
jobs:
hashicorp:
name: Publish AMI Image and Deploy it to EC2 through HashiCorp
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
...
- name: Publish my-app AMI image and deploy it to EC2 through HashiCorp
uses: QubitPi/hashicorp-aws-github-actions@master
with:
packer-dir: hashicorp/images
terraform-dir: hashicorp/instances
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
Tip
The values of packer-dir
and terraform-dir
is in accordance with the
example directory structure above
Note that the following GitHub Action Secrets needs to be setup
The use and distribution terms for hashicorp-aws-github-actions are covered by the Apache License, Version 2.0.