Created
May 4, 2022 13:28
-
-
Save devops-adeel/3adf4395a91d45cbccbc89aecafb3cd4 to your computer and use it in GitHub Desktop.
series of code to automate tf-module-setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Usage: | |
* | |
* ```hcl | |
* | |
* module "github_repo" { | |
* source = "hashicorp/github_terraform_module" | |
* application_name = "foo" | |
* tfc_token = vault_terraform_cloud_secret_creds.default.token | |
* } | |
* ``` | |
*/ | |
resource "github_repository" "default" { | |
name = var.application_name | |
description = format("Terraform Module for %s", var.application_name) | |
visibility = "private" | |
template { | |
owner = "github_org" | |
repository = "terraform-module-template" | |
} | |
resource "github_branch_default" "default" { | |
repository = github_repository.default.name | |
branch = "main" | |
} | |
resource "github_actions_secret" "default" { | |
repository = github_repository.default.name | |
secret_name = "tfc_token" | |
plaintext_value = var.tfc_token | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module "github" { | |
source = "hashicorp/github_repo" | |
application_name = var.application_name | |
tfc_token = module.tfc.token | |
} | |
module "tfc" { | |
source = "hashicorp/terraform_workspace" | |
application_name = var.application_name | |
email = var.email | |
username = var.username | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment