Skip to content

benoitblais-hashicorp-demo/HCPTerraform-ModulesFactory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HCP Terraform Modules Registry Factory

Code which manages configuration and life-cycle of all the HCP Terraform private registry factory. It is designed to be used from a dedicated API-Driven HCP Terraform workspace that would provision and manage the configuration using Terraform code (IaC).

Module publication to the private registry is facilitated through a no-code module. Each no-code module must be provisioned within the dedicated project to ensure proper variable input configuration and management.

Permissions

HCP Terraform Permissions

To manage the resources, provide a user token from an account with appropriate permissions. This user should have the Manage Modules, Manage Projects, Manage Workspaces, Manage Teams, Manage Membership, and Manage Organization Access permission. Alternatively, you can use a token from a team instead of a user token.

GitHub Permissions

To manage the GitHub resources, provide a token from an account or a GitHub App with appropriate permissions. It should have:

  • Read access to metadata
  • Read and write access to administration, code, secrets, and members.

Authentication

HCP Terraform Authentication

The HCP Terraform provider requires a HCP Terraform/Terraform Enterprise API token in order to manage resources.

There are several ways to provide the required token:

  • Set the token argument in the provider configuration. You can set the token argument in the provider configuration. Use an input variable for the token.
  • Set the TFE_TOKEN environment variable. The provider can read the TFE\_TOKEN environment variable and the token stored there to authenticate.

GitHub Authentication

The GitHub provider requires a GitHub token or GitHub App installation in order to manage resources.

There are several ways to provide the required token:

  • Set the token argument in the provider configuration. You can set the token argument in the provider configuration. Use an input variable for the token.
  • Set the GITHUB_TOKEN environment variable. The provider can read the GITHUB_TOKEN environment variable and the token stored there to authenticate.

There are several ways to provide the required GitHub App installation:

  • Set the app_auth argument in the provider configuration. You can set the app\_auth argument with the id, installation\_id and pem\_file in the provider configuration. The owner parameter is also required in this situation.
  • Set the GITHUB_APP_ID, GITHUB_APP_INSTALLATION_ID and GITHUB_APP_PEM_FILE environment variables. The provider can read the GITHUB\_APP\_ID, GITHUB\_APP\_INSTALLATION\_ID and GITHUB\_APP\_PEM\_FILE environment variables to authenticate.

Because strings with new lines is not support:
use "\\n" within the pem_file argument to replace new line
use "\n" within the GITHUB_APP_PEM_FILE environment variables to replace new line

Features

  • Manages configuration and life-cycle of GitHub resources for Terraform no-code module repository:
    • Repository
    • Branch protection
    • Teams
    • Secret
  • Manages configuration and life-cycle of HCP Terraform resources:
    • Project
    • Variable Set
      • Variables
    • Teams
      • Team token
    • Private module registry
      • No-code feature
    • Private module registry test environment variable

Documentation

Requirements

The following requirements are needed by this module:

Modules

The following Modules are called:

Source: ./modules/git_repository

Version:

Source: ./modules/tfe_team

Version:

Source: ./modules/tfe_team

Version:

Source: ./modules/git_team

Version:

Required Inputs

The following input variables are required:

Description: (Required) ID of the GitHub App used to authenticate.

Type: string

Description: (Required) ID of the GitHub App installation used to authenticate.

Type: string

Description: (Required) Content of the GitHub App private key PEM file used to authenticate.

Type: string

Description: (Required) The target GitHub organization or individual user account to manage.

Type: string

Description: (Required) Name of the organization.

Type: string

Optional Inputs

The following input variables are optional (have default values):

Description: (Optional) The github_teams block supports the following:
name : (Required) The name of the team.
description : (Optional) A description of the team.
permission : (Optional) The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation.

Type:

list(object({
    name        = string
    description = optional(string)
    permission  = optional(string, "pull")
  }))

Default:

[
  {
    "description": "This group grant admin access to the Terraform Modules repository.",
    "name": "Terraform-Modules-Owners",
    "permission": "admin"
  },
  {
    "description": "This group grant write access to the Terraform Modules repository.",
    "name": "Terraform-Modules-Contributors",
    "permission": "push"
  }
]

Description: (Optional) The GitHub repository to use as a template when creating new repositories. The repository must be a template repository. If not provided, the default template provided by the module will be used.

Type: string

Default: null

Description: (Optional) Name of the terraform module used by the modules factory.

Type: string

Default: "terraform-tfe-modulesfactory"

Description: (Optional) Name of the OAuth client.

Type: string

Default: "GitHub"

Description: (Optional) A description for the project.

Type: string

Default: null

Description: (Optional) Name of the project.

Type: string

Default: "Terraform Modules Factory"

Description: (Optional) A map of key-value tags to add to the project.

Type: map(string)

Default: null

Resources

The following resources are used by this module:

Outputs

No outputs.

About

Code to provision and manage HCP Terraform modules using Terraform code (IaC).

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 5

Languages