Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
git-pull-request

GitHub Action

DWP Kitchen Terraform

0.14.7

DWP Kitchen Terraform

git-pull-request

DWP Kitchen Terraform

Run kitchen terraform commands: github.com/newcontext-oss/kitchen-terraform

Installation

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

              

- name: DWP Kitchen Terraform

uses: dwp/[email protected]

Learn more about this action in dwp/github-action-kitchen-terraform

Choose a version

github-action-kitchen-terraform

GitHub Action to run Kitchen Terraform. Release versions match the Terraform version in use.

After cloning this repo, please run:
make bootstrap

This action runs kitchen-terraform to test Terraform modules.

Inputs

kitchen-command

Required. the command to follow the kitchen entrypoint e.g. "test" or "test my-scenario"

Example usage

on: [pull_request]
jobs:
  test:
    name: test
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repo
        uses: actions/checkout@v2
      - name: Kitchen Test A
        uses: dwp/[email protected]
        with:
          kitchen-command: "test scenario-a"
          aws-account-number: ${{ secrets.AWS_ACCOUNT }}
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.ACTIONS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.ACTIONS_SECRET_ACCESS_KEY }}
          GITLAB_USER: ${{ secrets.GITLAB_USER }}
          GITLAB_PAT: ${{ secrets.GITLAB_PAT }}
      - name: Kitchen Test B
        uses: dwp/[email protected]
        with:
          kitchen-command: "test scenario-b"
          aws-account-number: ${{ secrets.AWS_ACCOUNT }}
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.ACTIONS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.ACTIONS_SECRET_ACCESS_KEY }}
          GITLAB_USER: ${{ secrets.GITLAB_USER }}
          GITLAB_PAT: ${{ secrets.GITLAB_PAT }}

Docker Repo

The image repository can be found here.

Use the Docker image to run an equivalent locally using the example commands below:

Standard Kitchen command

docker run --rm -e AWS_PROFILE=default -v $(pwd):/usr/action -v ~/.aws:/root/.aws quay.io/dwp/kitchen-terraform:0.14.7 "test scenario-a"

Kitchen command with GitLab user and GitLab Personal Access Token. Used when Terraform contains references to external modules that require Git credentials.

docker run --rm -e AWS_PROFILE=default -e GITLAB_USER=user.name -e GITLAB_PAT=token -v $(pwd):/usr/action -v ~/.aws:/root/.aws quay.io/dwp/kitchen-terraform:0.14.7 "test scenario-a"

Kitchen command with redacted output - output is piped to sed and the second argument is used to find/replace, this can be a string or regex

docker run --rm -e AWS_PROFILE=default -v $(pwd):/usr/action -v ~/.aws:/root/.aws quay.io/dwp/kitchen-terraform:0.14.7 "test scenario-a" "0123456789"

Kitchen command with custom certificate trusts - mounts a local directory of certificates to trust

docker run --rm -e AWS_PROFILE=default -v /etc/ssl/certs/:/usr/local/share/ca-certificates/ -v $(pwd):/usr/action -v ~/.aws:/root/.aws quay.io/dwp/kitchen-terraform:0.14.7 "test scenario-a"