Skip to content

tamu-edu/it-cloud-actions-terraform-pr-apply

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

it-ae-actions-terraform-pr-apply

A GitHub Composite action for applying terraform state changes when a pull request is merged.

This action requires a pull request to be associated with the run. If a pull request id is not passed as an input, the action will attempt to find the pull request ID with a matching merge commit hash. If not pull request id is found, the action will fail.

The terraform apply output will be posted to the pull request as a comment, trimmed to 65535 characters. The full output log will also be uploaded to s3 and a link to the log will be posted to the pull request as a comment.

Usage

Set up AWS access credentials using an action such as aws-actions/configure-aws-credentials@v2, then use the action in your workflow:

steps:
  - name: Terraform Apply Composite Action
    uses: tamu-edu/it-ae-actions-terraform-pr-apply@main
    with:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      terraform-workspace: ${{ env.environment }}
      working-directory: terraform
      terraform-version: ~1.4.0

Limitations

Currently, this action only supports terraform whose state is stored in s3. The IAM role used to run this action must have access to the s3 bucket where the terraform state is stored and be able to create new objects at the backend's key prefix, or to the provided s3 bucket and key override inputs.

Inputs

INPUT TYPE REQUIRED DEFAULT DESCRIPTION
GITHUB_TOKEN string true GitHub token for access to the
pull request
debug string false "false" Debug workflow with tmate if an
error occurs
pr-id string false Associate the run with a specific
pull request id. Defaults to finding
the ID from the merge commit.
s3-bucket string false Override s3 bucket to upload output
to. Defaults to the same as
the state backend.
s3-key string false Override s3 object key to upload
output to. Defaults to a subdirectory
of the statefile key.
terraform-init-flags string false CLI flags to use with terraform
init
terraform-version string false "latest" Version of terraform to install
terraform-workspace string false "default" Terraform workspace to select. Must already
exist
working-directory string false Working directory for the run actions

Outputs

OUTPUT TYPE DESCRIPTION
apply_output string The terraform apply output
s3_path string The S3 URL of the uploaded
log file

About

A GitHub Composite action for applying terraform state changes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published