Skip to content

Commit

Permalink
Merge pull request #45 from hashicorp/TF-11430/rebrand
Browse files Browse the repository at this point in the history
docs: rebrand to HCP Terraform
  • Loading branch information
mjyocca authored May 22, 2024
2 parents 34866d2 + a396786 commit 9d17c9c
Show file tree
Hide file tree
Showing 22 changed files with 98 additions and 98 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Terraform Cloud Workflows for GitHub
# HCP Terraform Workflows for GitHub

This repo includes prescriptive workflows that implement best practices when interacting with Terraform Cloud. These starter workflow templates provide a entrypoint to integrate your CI/CD pipelines with Terraform Cloud.
This repo includes prescriptive workflows that implement best practices when interacting with HCP Terraform. These starter workflow templates provide a entrypoint to integrate your CI/CD pipelines with HCP Terraform.

## Related Projects
* [tfc-workflows-tooling](https://github.com/hashicorp/tfc-workflows-tooling)

## About

These templates use individual custom Docker GitHub Actions that interact with Terraform Cloud API's rather than the traditional Terraform CLI.
These templates use individual custom Docker GitHub Actions that interact with HCP Terraform API's rather than the traditional Terraform CLI.

The core tooling is a containerized go application, designed to work with GitHub Actions, GitLab Pipelines, and more in the future.

## Starter Workflow Templates

* [Terraform Speculative Run (Pull Request Open/Edit Workflow)](https://github.com/hashicorp/tfc-workflows-github/blob/main/workflow-templates/terraform-cloud.speculative-run.workflow.yml): Workflow to run non-applyable speculative runs in Terraform Cloud when a pull request has been opened/modified.
* [Terraform Speculative Run (Pull Request Open/Edit Workflow)](https://github.com/hashicorp/tfc-workflows-github/blob/main/workflow-templates/terraform-cloud.speculative-run.workflow.yml): Workflow to run non-applyable speculative runs in HCP Terraform when a pull request has been opened/modified.
* [Terraform Apply Run (Push to main branch/PR Merge to main Workflow)](https://github.com/hashicorp/tfc-workflows-github/blob/main/workflow-templates/terraform-cloud.apply-run.workflow.yml): Workflow to perform an apply run for a given workspace.


Expand All @@ -26,8 +26,8 @@ See [`workflow/README.md`](https://github.com/hashicorp/tfc-workflows-github/blo
See [`actions/README.md`](https://github.com/hashicorp/tfc-workflows-github/blob/main/actions/README.md)

Supported Actions:
* [upload-configuration](https://github.com/hashicorp/tfc-workflows-github/blob/main/actions/upload-configuration/action.yml): Creates and uploads configuration files for a given Terraform Cloud workspace.
* [create-run](https://github.com/hashicorp/tfc-workflows-github/blob/main/actions/create-run/action.yml): Performs a new plan run in Terraform Cloud, using a configuration version and the workspace’s current variables.
* [upload-configuration](https://github.com/hashicorp/tfc-workflows-github/blob/main/actions/upload-configuration/action.yml): Creates and uploads configuration files for a given HCP Terraform workspace.
* [create-run](https://github.com/hashicorp/tfc-workflows-github/blob/main/actions/create-run/action.yml): Performs a new plan run in HCP Terraform, using a configuration version and the workspace’s current variables.
* [apply-run](https://github.com/hashicorp/tfc-workflows-github/blob/main/actions/apply-run/action.yml): Applies a run that is paused waiting for confirmation after a plan.
* [discard-run](https://github.com/hashicorp/tfc-workflows-github/blob/main/actions/discard-run/action.yml): Skips any remaining work on runs that are paused waiting for confirmation or priority.
* [cancel-run](https://github.com/hashicorp/tfc-workflows-github/blob/main/actions/cancel-run/action.yml): Interrupts a run that is currently planning or applying.
Expand Down
20 changes: 10 additions & 10 deletions actions/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Terraform Cloud Workflow Actions
# HCP Terraform Workflow Actions

All of these actions assume Terraform Cloud resources such as Organization, Workspace, etc. already exist.
All of these actions assume HCP Terraform resources such as Organization, Workspace, etc. already exist.

They do not create these resources for you. If you are looking for this type of functionality, look to the [`Terraform Cloud/Enterprise Provider`](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs).
They do not create these resources for you. If you are looking for this type of functionality, look to the [`HCP Terraform/Enterprise Provider`](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs).

## Shared Inputs

Expand All @@ -12,23 +12,23 @@ For convenience, you are also able to specify these values within the GitHub Act

### `hostname`

**Optional** The hostname of a Terraform Enterprise installation, if using Terraform Enterprise. Defaults to Terraform Cloud (`app.terraform.io`) if `TF_HOSTNAME` environment variable is not set.
**Optional** The hostname of a Terraform Enterprise installation, if using Terraform Enterprise. Defaults to HCP Terraform (`app.terraform.io`) if `TF_HOSTNAME` environment variable is not set.

### `token`

**Optional** The token used to authenticate with Terraform Cloud. Defaults to reading `TF_API_TOKEN` environment variable. [Terraform Cloud API Token Docs](https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/api-tokens).
**Optional** The token used to authenticate with HCP Terraform. Defaults to reading `TF_API_TOKEN` environment variable. [HCP Terraform API Token Docs](https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/api-tokens).

### `organization`

**Optional** The name of the organization in Terraform Cloud. Defaults to reading `TF_CLOUD_ORGANIZATION` environment variable.
**Optional** The name of the organization in HCP Terraform. Defaults to reading `TF_CLOUD_ORGANIZATION` environment variable.

## Environment Variables

| Variable Name | Default | Description |
| ----------------- |--------------------| ---------------------------------------------------------------------------------------------------------------- |
| `TF_HOSTNAME` | `app.terraform.io` | The hostname of a Terraform Enterprise installation, if using Terraform Enterprise. Defaults to Terraform Cloud. |
| `TF_API_TOKEN` | `n/a` | The token used to authenticate with Terraform Cloud. [API Token Docs](https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/api-tokens) |
| `TF_CLOUD_ORGANIZATION` | `n/a` | The name of the organization in Terraform Cloud. |
| `TF_HOSTNAME` | `app.terraform.io` | The hostname of a Terraform Enterprise installation, if using Terraform Enterprise. Defaults to HCP Terraform. |
| `TF_API_TOKEN` | `n/a` | The token used to authenticate with HCP Terraform. [API Token Docs](https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/api-tokens) |
| `TF_CLOUD_ORGANIZATION` | `n/a` | The name of the organization in HCP Terraform. |
| `TF_MAX_TIMEOUT` | `1h` | Max wait timeout to wait for actions to reach desired or errored state. ex: `1h30`, `30m` |
| `TF_VAR_*` | `n/a` | Only applicable for create-run action. Note: strings must be escaped. ex: `TF_VAR_image_id="\"ami-abc123\""`. All values must be expressed as an HCL literal in the same syntax you would use when writing Terraform code. [Create Run API Docs](https://developer.hashicorp.com/terraform/cloud-docs/api-docs/run#create-a-run) |
| `TF_LOG` | `OFF` | Debugging log level options: `OFF`, `ERROR`, `INFO`, `DEBUG` |
Expand All @@ -47,7 +47,7 @@ For convenience, you are also able to specify these values within the GitHub Act
run: ${{ steps.create-run.outputs.run_id }}
comment: "Confirmed from GitHub Actions CI"
## Can specify hostname,token,organization as direct inputs
hostname: "my.tfe.instance.io" # if using Terraform Cloud Enterprise
hostname: "my.tfe.instance.io" # if using HCP Terraform Enterprise
organization: ${{ vars.TF_CLOUD_ORGANIZATION }} # Configured as GitHub configuration variable
token: ${{ secrets.TF_API_TOKEN }} # Configured as GitHub Secret
## OR can specify as environment variables per step, job, or entire workflow file.
Expand Down
4 changes: 2 additions & 2 deletions actions/apply-run/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Apply Run Action

Applies a run that is paused waiting for confirmation after a plan. Requires a valid Terraform Cloud Run ID.
Applies a run that is paused waiting for confirmation after a plan. Requires a valid HCP Terraform Run ID.

This action will wait until the apply has been successful or has failed/timeout.

Expand All @@ -23,7 +23,7 @@ See `./action.yml` file for all available inputs and outputs.
# if want to and handle automation if apply fails
continue-on-error: true
with:
hostname: "my.tfe.instance.io" # if using Terraform Cloud Enterprise
hostname: "my.tfe.instance.io" # if using HCP Terraform Enterprise
token: ${{ secrets.TF_API_TOKEN }} # recommend to store as repository secret
run: ${{ steps.create-run.outputs.run_id }}
comment: "Confirmed from GitHub Actions CI"
Expand Down
8 changes: 4 additions & 4 deletions actions/apply-run/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ inputs:
# global flags
hostname:
required: false
description: "The hostname of a Terraform Enterprise installation, if using Terraform Enterprise. Defaults to Terraform Cloud (app.terraform.io) if `TF_HOSTNAME` environment variable is not set."
description: "The hostname of a Terraform Enterprise installation, if using Terraform Enterprise. Defaults to HCP Terraform (app.terraform.io) if `TF_HOSTNAME` environment variable is not set."
default: ""
token:
required: false
description: "The token used to authenticate with Terraform Cloud. Defaults to reading `TF_API_TOKEN` environment variable."
description: "The token used to authenticate with HCP Terraform. Defaults to reading `TF_API_TOKEN` environment variable."
default: ""
organization:
required: false
description: "The name of the organization in Terraform Cloud. Defaults to reading `TF_CLOUD_ORGANIZATION` environment variable."
description: "The name of the organization in HCP Terraform. Defaults to reading `TF_CLOUD_ORGANIZATION` environment variable."
default: ""
# required
run:
Expand All @@ -34,7 +34,7 @@ outputs:
run_id:
description: "The provided run ID."
run_status:
description: "The current status of the Terraform Cloud run."
description: "The current status of the HCP Terraform run."

runs:
using: docker
Expand Down
4 changes: 2 additions & 2 deletions actions/cancel-run/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Interrupts a run that is currently planning or applying.

Requires a valid Terraform Cloud Run ID.
Requires a valid HCP Terraform Run ID.

## Action Inputs / Outputs

Expand All @@ -14,7 +14,7 @@ See `./action.yml` file for all available inputs and outputs.
- uses: hashicorp/tfc-workflows-github/actions/cancel-run@v1.3.0
id: cancel
with:
hostname: "my.tfe.instance.io" # if using Terraform Cloud Enterprise
hostname: "my.tfe.instance.io" # if using HCP Terraform Enterprise
token: ${{ secrets.TF_API_TOKEN }} # recommend to store as repository secret
run: ${{ steps.show-run.outputs.run_id }}
comment: "Cancelled from GitHub Actions CI"
Expand Down
8 changes: 4 additions & 4 deletions actions/cancel-run/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ inputs:
# global flags
hostname:
required: false
description: "The hostname of a Terraform Enterprise installation, if using Terraform Enterprise. Defaults to Terraform Cloud (app.terraform.io) if `TF_HOSTNAME` environment variable is not set."
description: "The hostname of a Terraform Enterprise installation, if using Terraform Enterprise. Defaults to HCP Terraform (app.terraform.io) if `TF_HOSTNAME` environment variable is not set."
default: ""
token:
required: false
description: "The token used to authenticate with Terraform Cloud. Defaults to reading `TF_API_TOKEN` environment variable."
description: "The token used to authenticate with HCP Terraform. Defaults to reading `TF_API_TOKEN` environment variable."
default: ""
organization:
required: false
description: "The name of the organization in Terraform Cloud. Defaults to reading `TF_CLOUD_ORGANIZATION` environment variable."
description: "The name of the organization in HCP Terraform. Defaults to reading `TF_CLOUD_ORGANIZATION` environment variable."
default: ""
run:
required: true
Expand All @@ -32,7 +32,7 @@ outputs:
run_id:
description: "The provided run ID."
run_status:
description: "The current status of the Terraform Cloud run."
description: "The current status of the HCP Terraform run."

runs:
using: docker
Expand Down
10 changes: 5 additions & 5 deletions actions/create-run/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Create Run Action

*Requires that the workspace already exists within Terraform Cloud.*
*Requires that the workspace already exists within HCP Terraform.*

Performs an API driven run in Terraform Cloud, using a configuration version and the workspace's current variables. If a configuration version is not provided, will default to the workspace's most recently used version. [Terraform Cloud Create-Run API](https://developer.hashicorp.com/terraform/cloud-docs/api-docs/run#create-a-run).
Performs an API driven run in HCP Terraform, using a configuration version and the workspace's current variables. If a configuration version is not provided, will default to the workspace's most recently used version. [HCP Terraform Create-Run API](https://developer.hashicorp.com/terraform/cloud-docs/api-docs/run#create-a-run).

This action will wait until the run status has reached a terminal/final state.

[Terraform Cloud API-driven Run Workflow](https://developer.hashicorp.com/terraform/cloud-docs/run/api)
[HCP Terraform API-driven Run Workflow](https://developer.hashicorp.com/terraform/cloud-docs/run/api)

## Behaviors / Expected Outcomes
* If the Plan reaches a failured state, will return `Error` status and status code of `1`.
Expand All @@ -21,7 +21,7 @@ To view all available inputs and outputs, see `./action.yml` [file](./action.yml
### Variables

#### `TF_VAR_*` Environment variable(s)
Terraform Cloud API runs allow you to specify a list of variables using key and value attributes. These variables can be configured using environment variables with the `TF_VAR_*` naming convention. These variables take precedence over variables with the same key applied to the workspace(e.g., variable sets). For greater flexibility and features, it's recommended to use Terraform Cloud [workspace variables and variable sets](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/variables).
HCP Terraform API runs allow you to specify a list of variables using key and value attributes. These variables can be configured using environment variables with the `TF_VAR_*` naming convention. These variables take precedence over variables with the same key applied to the workspace(e.g., variable sets). For greater flexibility and features, it's recommended to use HCP Terraform [workspace variables and variable sets](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/variables).

> [!Note]
All values must be expressed as an HCL literal in the same syntax you would use when writing Terraform code. Variables expressed as `string` will need to be escaped to include double quotations like, `TF_VAR_image_id="\"ami-my-custom-image\""` or `TF_VAR_image_id='"ami-my-custom-image'"`. [Read more on Terraform complex typed values](https://developer.hashicorp.com/terraform/language/values/variables#complex-typed-values)
Expand Down Expand Up @@ -62,7 +62,7 @@ All values must be expressed as an HCL literal in the same syntax you would use

Like with the other actions, you can specify hostname, token, and organization as inputs OR as environment variables.

This specific example does not pass a configuraiton version id, so the run defaults to the workspace's most recently used version. [Read more about create run behavior in the Terraform Cloud API](https://developer.hashicorp.com/terraform/cloud-docs/api-docs/run#create-a-run)
This specific example does not pass a configuraiton version id, so the run defaults to the workspace's most recently used version. [Read more about create run behavior in the HCP Terraform API](https://developer.hashicorp.com/terraform/cloud-docs/api-docs/run#create-a-run)

```yml
- uses: hashicorp/tfc-workflows-github/actions/create-run@v1.3.0
Expand Down
14 changes: 7 additions & 7 deletions actions/create-run/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
# SPDX-License-Identifier: MPL-2.0

name: 'TFC - Create Run'
description: "Performs a new plan run in Terraform Cloud, using a configuration version and the workspace`s current variables"
description: "Performs a new plan run in HCP Terraform, using a configuration version and the workspace`s current variables"

inputs:
# global flags
hostname:
required: false
description: "The hostname of a Terraform Enterprise installation, if using Terraform Enterprise. Defaults to Terraform Cloud (app.terraform.io) if `TF_HOSTNAME` environment variable is not set."
description: "The hostname of a Terraform Enterprise installation, if using Terraform Enterprise. Defaults to HCP Terraform (app.terraform.io) if `TF_HOSTNAME` environment variable is not set."
default: ""
token:
required: false
description: "The token used to authenticate with Terraform Cloud. Defaults to reading `TF_API_TOKEN` environment variable"
description: "The token used to authenticate with HCP Terraform. Defaults to reading `TF_API_TOKEN` environment variable"
default: ""
organization:
required: false
description: "The name of the organization in Terraform Cloud. Defaults to reading `TF_CLOUD_ORGANIZATION` environment variable"
description: "The name of the organization in HCP Terraform. Defaults to reading `TF_CLOUD_ORGANIZATION` environment variable"
default: ""
## required
workspace:
Expand Down Expand Up @@ -52,15 +52,15 @@ outputs:
status:
description: "The result of the operation. Possible values are `Success`, `Error` or `Timeout`"
payload:
description: "JSON response of a Terraform Cloud run."
description: "JSON response of a HCP Terraform run."
run_id:
description: "The ID of the created run."
run_status:
description: "The current status of the Terraform Cloud run."
description: "The current status of the HCP Terraform run."
run_message:
description: "The message attribute of the shown run."
run_link:
description: "Link to view the run in Terraform Cloud."
description: "Link to view the run in HCP Terraform."
plan_id:
description: "The ID of the plan, associated to the created run."
plan_status:
Expand Down
4 changes: 2 additions & 2 deletions actions/discard-run/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Skips any remaining work on runs that are paused waiting for confirmation or priority.

Requires a valid Terraform Cloud Run ID.
Requires a valid HCP Terraform Run ID.

## Action Inputs / Outputs

Expand All @@ -14,7 +14,7 @@ See `./action.yml` file for all available inputs and outputs.
- uses: hashicorp/tfc-workflows-github/actions/discard-run@v1.3.0
id: discard
with:
hostname: "my.tfe.instance.io" # if using Terraform Cloud Enterprise
hostname: "my.tfe.instance.io" # if using HCP Terraform Enterprise
token: ${{ secrets.TF_API_TOKEN }} # recommend to store as repository secret
run: ${{ steps.create-run.outputs.run_id }}
comment: "Discarded from GitHub Actions CI"
Expand Down
Loading

0 comments on commit 9d17c9c

Please sign in to comment.