Skip to content

A Terraform module to create a GitHub repository for a Terraform workspace from a template, and create the workspace in Terraform Cloud

License

Notifications You must be signed in to change notification settings

fabiendelpierre/terraform-github-tfc-workspace-module

Repository files navigation

terraform-github-tfc-workspace-module

Creates an empty GitHub repository (blank or from a specified template) and a corresponding workspace in Terraform Cloud.

Requirements

After setting up the GitHub repo + TFC workspace, you must set a secret in your GitHub repo called TFC_API_TOKEN and set its value to a personal token obtained from Terraform Cloud. This is required for the GitHub Action that runs Terraform on your behalf.

Inputs and outputs

Requirements

Name Version
terraform >= 1.0.0
github >= 4.1.0
tfe >= 0.26.1

Providers

Name Version
github 4.16.0
tfe 0.26.1

Modules

No modules.

Resources

Name Type
github_repository.blank resource
github_repository.templated resource
github_repository_file.blank_providers_tf resource
github_repository_file.templated_providers_tf resource
tfe_workspace.main resource

Inputs

Name Description Type Default Required
github_repo_description A description for the GitHub repo string "" no
github_repo_enable_issues value bool true no
github_repo_enable_projects value bool false no
github_repo_enable_wiki value bool false no
github_repo_gitignore_template A gitignore template to preinstall in the GitHub repo string "Terraform" no
github_repo_license_template The license to apply to the GitHub repository string "unlicense" no
github_repo_name The name of the GitHub repo string n/a yes
github_repo_template_owner_name The owner organization of the template repo to use to create this repo string "" no
github_repo_template_repo_name The name of the template repo to use to create this repo string "" no
github_repo_use_template Use a template to create the GitHub repo bool true no
github_repo_visibility The GitHub repo's visibility (public, private, or internal) string "public" no
tfc_organization_name The name of the Terraform Cloud organization to which the workspace belongs string n/a yes
tfc_workspace_name The name of the workspace in Terraform Cloud string n/a yes
tfc_workspace_tags A list of tags to assign to the workspace list(string) [] no
tfc_workspace_terraform_version The version of Terraform to use during the workspace's runs string n/a yes

Outputs

Name Description
github_repo_full_name n/a
github_templated_repo_full_name n/a
tfc_workspace_id n/a
tfc_workspace_name n/a

Code example

terraform {
  required_version = "~> 1.0"

  required_providers {
    github = {
      source  = "integrations/github"
      version = "~> 4.1"
    }
    tfe = {
      source  = "hashicorp/tfe"
      version = "~> 0.26"
    }
  }
}

provider "github" {
  token = "..."
}

provider "tfe" {
  token = "..."
}

module "test" {
  source = "github.com/fabiendelpierre/terraform-github-tfc-workspace-module"

  github_repo_name        = "foo"
  github_repo_description = "..."

  github_repo_use_template        = true
  github_repo_template_owner_name = "owner-org"
  github_repo_template_repo_name  = "template-repo-name"

  tfc_workspace_name    = "foo"
  tfc_organization_name = "tfc-org-name"

  tfc_workspace_terraform_version = "1.0.7"
}

About

A Terraform module to create a GitHub repository for a Terraform workspace from a template, and create the workspace in Terraform Cloud

Resources

License

Stars

Watchers

Forks

Packages

No packages published