Giter Club home page Giter Club logo

tofu-remote-state's Introduction

tofu-remote-state action

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

Retrieves the root-level outputs from an OpenTofu remote state.

Inputs

  • backend_type

    The name of the OpenTofu plugin used for backend state

    • Type: string
    • Required
  • workspace

    OpenTofu workspace to get the outputs for

    • Type: string
    • Optional
    • Default: default
  • backend_config

    List of OpenTofu backend config values, one per line.

    with:
      backend_config: token=${{ secrets.BACKEND_TOKEN }}
    • Type: string
    • Optional
  • backend_config_file

    List of OpenTofu backend config files to use, one per line. Paths should be relative to the GitHub Actions workspace

    with:
      backend_config_file: prod.backend.tfvars
    • Type: string
    • Optional

Environment Variables

  • TERRAFORM_CLOUD_TOKENS

    API tokens for cloud hosts, of the form <host>=<token>. Multiple tokens may be specified, one per line. These tokens may be used with the remote backend.

    e.g:

    env:
      TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_CLOUD_TOKEN }}

    With other registries:

    env:
      TERRAFORM_CLOUD_TOKENS: |
        app.terraform.io=${{ secrets.TF_CLOUD_TOKEN }}
        tofu.example.com=${{ secrets.TF_REGISTRY_TOKEN }}
    • Type: string
    • Optional

Outputs

An output will be created for each root-level output in the OpenTofu 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 tofu-output for details.

Example usage

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

name: Send request

on:
  push:
    branches:
      - main

env:
  AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
  AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

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

      - name: Send request
        run: |
          curl "${{ steps.remote-state.outputs.url }}"

tofu-remote-state's People

Contributors

dflook avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.