terraform-github-actions

terraform-remote-state action

This is one of a suite of Terraform related actions - find them at dflook/terraform-github-actions.

Retrieves the root-level outputs from a Terraform remote state.

Inputs

Environment Variables

Outputs

An output will be created for each root-level output in the Terraform remote state.

For example, with a remote state that has an output created using:

output "service_hostname" {
  value = "example.com"
}

Running this action will produce a service_hostname output with the same value. See terraform-output for details.

Example usage

This example sends a request to a url that has previously been provisioned by Terraform, by fetching the url from the remote state in S3.

name: Send request

on:
  push:
    branches:
      - main

env:
  AWS_ACCESS_KEY_ID: $
  AWS_SECRET_ACCESS_KEY: $

jobs:
  get_remote_state:
    runs-on: ubuntu-latest
    name: Run Test
    steps:
      - name: Get remote state
        uses: dflook/terraform-remote-state@v1
        id: remote-state
        with:
          backend_type: s3
          backend_config: |
            bucket=terraform-github-actions
            key=terraform-remote-state
            region=eu-west-2

      - name: Send request
        run: |
          curl "$"