Last active
September 5, 2018 21:01
-
-
Save djaboxx/e4a615acded0b71e2c6fb79f20d8579c to your computer and use it in GitHub Desktop.
Simple Terraform Config to create a workspace with one variable and enabling admin access for one team
This file contains 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
variable "github_org" { | |
type = "string" | |
description = "GitHub Organization" | |
} | |
variable "organization" { | |
type = "string" | |
description = "Terraform Enterprise Organization" | |
} | |
variable "create_instance_repo" { | |
type = "string" | |
description = "Repository for AWS Ec2 Instance Creation" | |
} | |
variable "oauth_token" { | |
type = "string" | |
description = "Terraform Enterprise Oauth Token" | |
} | |
variable "instance_name" { | |
type = "string" | |
description = "Name of the AWS Instance" | |
} | |
variable "team_name" { | |
type = "string" | |
description = "Name of TFE Team" | |
} | |
variable "members" { | |
type = "list" | |
description = "List of Team Mates for team" | |
} | |
variable "workspace_name" { | |
type = "string" | |
description = "Name of the newly created TFE Workspace" | |
} | |
variable "aws_access_key" { | |
type = "string" | |
description = "AWS Access Key Id" | |
} | |
variable "aws_secret_key" { | |
type = "string" | |
description = "AWS Secret Access Key" | |
} | |
resource "tfe_workspace" "CreateInstance" { | |
name = "${var.workspace_name}" | |
organization = "${var.organization}" | |
vcs_repo = { | |
identifier = "${var.github_org}/${var.create_instance_repo}" | |
branch = "master" | |
oauth_token_id = "${var.oauth_token}" | |
ingress_submodules = true | |
} | |
} | |
resource "tfe_variable" "InstanceName" { | |
key = "instance_name" | |
value = "${var.instance_name}" | |
category = "terraform" | |
workspace_id = "${tfe_workspace.CreateInstance.id}" | |
} | |
resource "tfe_variable" "aws_access_key" { | |
key = "AWS_ACCESS_KEY_ID" | |
value = "${var.aws_access_key}" | |
category = "env" | |
workspace_id = "${tfe_workspace.CreateInstance.id}" | |
} | |
resource "tfe_variable" "aws_secret_key" { | |
key = "AWS_SECRET_ACCESS_KEY" | |
value = "${var.aws_secret_key}" | |
category = "env" | |
workspace_id = "${tfe_workspace.CreateInstance.id}" | |
sensitive = true | |
} | |
resource "tfe_team" "team" { | |
name = "${var.team_name}" | |
organization = "${var.organization}" | |
} | |
resource "tfe_team_members" "member" { | |
team_id = "${tfe_team.team.id}" | |
usernames = "${var.members}" | |
} | |
resource "tfe_team_access" "access" { | |
access = "admin" | |
team_id = "${tfe_team.team.id}" | |
workspace_id = "${tfe_workspace.CreateInstance.id}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment