Skip to content
package

GitHub Action

HashiCorp AWS

1.0.1 Latest version

HashiCorp AWS

package

HashiCorp AWS

Registers AMI and deploys AWS EC2 instance of it as immutable infrastructure through HashiCorp

Installation

Copy and paste the following snippet into your .yml file.

              

- name: HashiCorp AWS

uses: QubitPi/hashicorp-aws-github-actions@1.0.1

Learn more about this action in QubitPi/hashicorp-aws-github-actions

Choose a version

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.