This commit is contained in:
41666 2020-10-09 10:54:55 -04:00
parent a5e2fdc7a7
commit ec505739c8
31 changed files with 1394 additions and 0 deletions

View file

@ -0,0 +1,57 @@
locals {
dependentModulesPathed = formatlist("terraform/modules/%s", var.dependent_modules)
variableDescription = "Terraform-owned variable"
}
resource "tfe_workspace" "ws" {
name = var.workspace-name
organization = var.tfc_org
auto_apply = var.auto_apply
trigger_prefixes = concat([var.directory], local.dependentModulesPathed)
working_directory = var.directory
vcs_repo {
identifier = var.repo
branch = var.branch
oauth_token_id = var.tfc_oauth_token_id
}
}
resource "tfe_notification_configuration" "webhook" {
name = "${var.workspace-name}-webhook"
enabled = true
destination_type = "slack"
triggers = ["run:created", "run:planning", "run:needs_attention", "run:applying", "run:completed", "run:errored"]
url = var.tfc_webhook_url
workspace_id = tfe_workspace.ws.id
}
resource "tfe_variable" "vars" {
for_each = var.vars
key = each.key
value = each.value
category = "terraform"
workspace_id = tfe_workspace.ws.id
sensitive = false
}
resource "tfe_variable" "sensitive" {
for_each = var.secret-vars
key = each.key
value = each.value
category = "terraform"
workspace_id = tfe_workspace.ws.id
sensitive = true
}
resource "tfe_variable" "env" {
for_each = var.env-vars
key = each.key
value = each.value
category = "env"
workspace_id = tfe_workspace.ws.id
sensitive = true
}

View file

@ -0,0 +1,3 @@
output "workspace" {
value = tfe_workspace.ws[*]
}

View file

@ -0,0 +1,54 @@
variable "workspace-name" {
type = string
}
variable "secret-vars" {
type = map(string)
default = {}
}
variable "vars" {
type = map(string)
default = {}
}
variable "env-vars" {
type = map(string)
default = {}
}
variable "repo" {
type = string
}
variable "directory" {
type = string
default = "/"
}
variable "branch" {
type = string
default = "master"
}
variable "auto_apply" {
type = bool
default = false
}
variable "dependent_modules" {
type = list(string)
default = []
}
variable "tfc_oauth_token_id" {
type = string
}
variable "tfc_org" {
type = string
}
variable "tfc_webhook_url" {
type = string
}

View file

@ -0,0 +1,7 @@
terraform {
required_version = ">=0.12.6"
}
provider "tfe" {
version = ">=0.15.0"
}