· 7 years ago · Sep 05, 2018, 09:04 PM
1variable "github_org" {
2 type = "string"
3 description = "GitHub Organization"
4}
5
6variable "organization" {
7 type = "string"
8 description = "Terraform Enterprise Organization"
9}
10
11variable "create_instance_repo" {
12 type = "string"
13 description = "Repository for AWS Ec2 Instance Creation"
14}
15
16variable "oauth_token" {
17 type = "string"
18 description = "Terraform Enterprise Oauth Token"
19}
20
21variable "instance_name" {
22 type = "string"
23 description = "Name of the AWS Instance"
24}
25
26variable "team_name" {
27 type = "string"
28 description = "Name of TFE Team"
29}
30
31variable "members" {
32 type = "list"
33 description = "List of Team Mates for team"
34}
35
36variable "workspace_name" {
37 type = "string"
38 description = "Name of the newly created TFE Workspace"
39}
40
41variable "aws_access_key" {
42 type = "string"
43 description = "AWS Access Key Id"
44}
45
46variable "aws_secret_key" {
47 type = "string"
48 description = "AWS Secret Access Key"
49}
50
51resource "tfe_workspace" "CreateInstance" {
52 name = "${var.workspace_name}"
53 organization = "${var.organization}"
54 vcs_repo = {
55 identifier = "${var.github_org}/${var.create_instance_repo}"
56 branch = "master"
57 oauth_token_id = "${var.oauth_token}"
58 ingress_submodules = true
59 }
60}
61
62resource "tfe_variable" "InstanceName" {
63 key = "instance_name"
64 value = "${var.instance_name}"
65 category = "terraform"
66 workspace_id = "${tfe_workspace.CreateInstance.id}"
67}
68
69resource "tfe_variable" "aws_access_key" {
70 key = "AWS_ACCESS_KEY_ID"
71 value = "${var.aws_access_key}"
72 category = "env"
73 workspace_id = "${tfe_workspace.CreateInstance.id}"
74}
75
76resource "tfe_variable" "aws_secret_key" {
77 key = "AWS_SECRET_ACCESS_KEY"
78 value = "${var.aws_secret_key}"
79 category = "env"
80 workspace_id = "${tfe_workspace.CreateInstance.id}"
81 sensitive = true
82}
83
84resource "tfe_team" "team" {
85 name = "${var.team_name}"
86 organization = "${var.organization}"
87}
88
89resource "tfe_team_members" "member" {
90 team_id = "${tfe_team.team.id}"
91 usernames = "${var.members}"
92}
93
94resource "tfe_team_access" "access" {
95 access = "admin"
96 team_id = "${tfe_team.team.id}"
97 workspace_id = "${tfe_workspace.CreateInstance.id}"
98}