Skip to content

recarnot/terraform-github-workspace-setup-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

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 }}"