Coder Social home page Coder Social logo

scalr-action-otf's Introduction

scalr-action

The scalr-action action is an action written in JavaScript that sets up the Scalr and OpenTufu/Terraform CLI. The action does the following:

  • Downloads (and caching) the latest version of Scalr CLI and adds it to the PATH.
  • Dowloads (and caching) a specific (or autodetected) version of OpenTufu/Terraform CLI and adds it to the PATH.
  • Configures the Scalr CLI and Terraform CLI configuration file with a Scalr Hostname and Token.
  • Optionally: Installs a script to wrap following calls of the tofu/terraform binary. Exposes the STDOUT, STDERR, and exit code as outputs named stdout, stderr, and exitcode. Enabled by default
  • Optionally: Terraform output variables will be cached and converted to action variables. This is disabled by default.

After the action has been used, the following steps in the job can run the standard OpenTufu/Terraform commands using the GitHub Actions run command.

You will also have access to the Scalr CLI which communicates directly with the Scalr API and allows you to perform Scalr specific tasks, such as creating users, pull statistics, etc.

Usage

Supported on the following GitHub Actions runners:

  • ubuntu-latest
  • windows-latest (be sure to set the shell to Bash)
  • macos-latest

If manually specifying a OpenTufu/Terraform version, please remember to set the same version as set in your Scalr Workspace. You also need to generate a Scalr API Token and store it as a GitHub Secret.

The following steps can access OpenTufu/Terraform outputs:

steps:
  - uses: Scalr/scalr-action@v1
    with:
      scalr_hostname: "<your-account>.scalr.io"
      scalr_token: ${{ secrets.SCALR_TOKEN }}
      scalr_workspace: ws-abcdef123456
      binary_output: true

  - run: opentufu init

  - id: plan
    run: opentufu plan

  - run: echo "${{ steps.plan.outputs.stdout }}"
  - run: echo "${{ steps.plan.outputs.stderr }}"
  - run: echo "${{ steps.plan.outputs.exitcode }}"

  - id: apply
    run: opentufu apply -auto-approve

  - run: echo ${{ steps.apply.outputs.server_ip }}

OpenTufu/Terraform configuration

Make sure your OpenTufu/Terraform configuration includes the minimal parameters for Scalr. Here is an example for a minimal main.tf:

terraform {
  backend "remote" {
    hostname = "example.scalr.io"
    organization = "env-abcdef123456"

    workspaces {
      name = "helloworld"
    }
  }
}

Inputs

The action supports the following inputs:

  • scalr_hostname - The hostname of your Scalr account on scalr.io. Example: example.scalr.io.

  • scalr_token - The API token used to authenticate with the credentials block of the Terraform CLI config file.

  • scalr_workspace - The Scalr workspace ID you plan on working in. This is required if you want to auto-detect Terraform version.

  • iac_platform - Specifies if you want to use the tofu or terraform platform. Default is terraform.

  • binary_version - The version of OpenTufu/Terraform CLI. This must match the version set in your Scalr Workspace. It will be autodetected if left empty and workspace is set.

  • binary_wrapper - Whether or not to install a wrapper to wrap calls of the tofu/terraform binary and expose its STDOUT, STDERR, and exit code

  • binary_output - true/false. Export OpenTufu/Terraform output variables as Action output variables. The OpenTufu/Terraform wrapper needs to be enabled for this to work. Example: steps.<step-name>.outputs.<terraform_output_name> This is disabled by default.

Outputs

The following outputs are available for further steps that call the tofu/terraform binary if the wrapper has not been set to false.

  • stdout - The STDOUT of the call to the tofu/terraform binary.

  • stderr - The STDERR of the call to the tofu/terraform binary.

  • exitcode - The exit code of the call to the tofu/terraform binary.

  • <terraform_output_var_name> - Stores the Terraform output variables from last tofu/terraform apply run if binary_output=true

Scalr CLI

More information about how to use the Scalr CLI provided by this Action, please refer to the Scalr CLI repository.

Contributing

To contribute to this project, please see the contribution guidelines. Also please fill out the Contribution Agreement and send it to [email protected]

scalr-action-otf's People

Contributors

buzzy avatar rtfee 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.