Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Latest commit

 

History

History
116 lines (90 loc) · 5.16 KB

README.md

File metadata and controls

116 lines (90 loc) · 5.16 KB

GitHub Actions for hashicorp-aws

GitHub Actions Marketplace GitHub Workflow Status HashiCorp Packer Badge HashiCorp Terraform Badge Apache License

Immutable Infrastructure as Code via GitHub Action

Application Deployment on AWS through HashiCorp is an opinionated CI/CD GitHub Action that

  1. packages application into and registers AMI image on AWS, then
  2. deploys an EC2 instance of that AMI onto AWS

Error loading hashicorp-aws.png

How to Use HashiCrop AWS GitHub Actions

Step 1 - Setting up HashiCrop Packer & Terraform Template Files

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
    └── ...

Step 2 - Defining Action 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

License

The use and distribution terms for hashicorp-aws-github-actions are covered by the Apache License, Version 2.0.