Skip to content
check-square

GitHub Action

Terraform Workspace setup

v1.0.12 Latest version

Terraform Workspace setup

check-square

Terraform Workspace setup

Setup a Terraform Cloud/Enterprise workspace

Installation

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

              

- name: Terraform Workspace setup

uses: recarnot/[email protected]

Learn more about this action in recarnot/terraform-github-workspace-setup-action

Choose a version

Terraform Cloud/Enterprise workspace setup

GitHub Action to set up Terraform Cloud/Enterprise workspace

Terraform version Release Continuous Integration

Inputs

name description required
organization Terraform Organization name true
workspace Terraform Workspace name true
token Terraform API token true
hostname Terraform Hostname false
vars Workspace variables definition false

Usage

Simple example :

on: [push]

jobs:
  setup-tf-workspace:
    runs-on: ubuntu-latest
    name: Setup Terraform workspace
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: setup workspace
        id: workspace
        uses: recarnot/terraform-github-workspace-setup-action@master
        with:
          organization: ${{ secrets.TF_ORGANIZATION }}
          workspace: "my-workspace-name"
          token: ${{ secrets.TF_API_TOKEN }}

      - name: Get the output time
        run: echo "The workspace ID is ${{ steps.workspace.outputs.workspace_id }}"

Now with variables :

on: [push]

jobs:
  setup-tf-workspace:
    runs-on: ubuntu-latest
    name: Setup Terraform workspace
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: setup workspace
        id: workspace
        uses: recarnot/terraform-github-workspace-setup-action@master
        with:
          organization: ${{ secrets.TF_ORGANIZATION }}
          workspace: "my-workspace-name"
          token: ${{ secrets.TF_API_TOKEN }}
          vars: '
            {
              "key": "region",
              "value": "eu-west-3",
              "sensitive": "false"
            },
            {
              "key": "access_key_id",
              "value": "${{ secrets.AWS_ACCESS_KEY_ID }}",
              "sensitive": "true"
            }
          '
          
      - name: Get the output time
        run: echo "The workspace ID is ${{ steps.workspace.outputs.workspace_id }}"