forked from Cloud-Schematics/Cloud-Foundry-App
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
76 lines (53 loc) · 2.03 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
########## __________ V A R I A B L E S __________ ##########
variable "ibm_cloud_apikey" {
description = "specify your IBM Cloud user apikey"
}
variable "ibm_cloud_organization" {
description = "specify your IBM Cloud organization name"
}
variable "ibm_cloud_space" {
description = "specify your IBM Cloud space name"
}
variable "application_hostname" {
description = "specify the hostname for the application's route. The specified hostname will then be extended by '.mybluemix.net'"
}
variable "application_version" {
description = "specify the version of the application. A change of this parameters is an indication for terraform that the application code has changed and needs redeployment."
default = "100"
}
variable "application_instances" {
description = "specify the number of cloud foundry application instances to be deployed"
default = "1"
}
########## __________ M A I N __________ ##########
# Configure the IBM Cloud Provider
provider "ibm" {
ibmcloud_api_key = "${var.ibm_cloud_apikey}"
}
data "ibm_space" "myspace" {
org = "${var.ibm_cloud_organization}"
space = "${var.ibm_cloud_space}"
}
# Create an Cloud Froundry application
resource "ibm_app" "cfapp" {
name = "cfgo-${var.application_hostname}"
space_guid = "${data.ibm_space.myspace.id}"
wait_time_minutes = 10
buildpack = "go_buildpack"
app_path = "${path.module}/appcode/goapp.zip"
app_version = "${var.application_version}"
route_guid = ["${ibm_app_route.myroute.id}"]
instances = "${var.application_instances}"
}
data "ibm_app_domain_shared" "mydomain" {
name = "mybluemix.net"
}
resource "ibm_app_route" "myroute" {
domain_guid = "${data.ibm_app_domain_shared.mydomain.id}"
space_guid = "${data.ibm_space.myspace.id}"
host = "${var.application_hostname}"
}
########## __________ O U T P U T S __________ ##########
output "final_output" {
value = "Access the application at https://${var.application_hostname}.${data.ibm_app_domain_shared.mydomain.name}"
}