-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.tf
50 lines (45 loc) · 1.7 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
#Terraform `provider` section is required since the `azurerm` provider update to 2.0+
provider "azurerm" {
features {}
}
#Extract the connection from the normal yaml file to pass to the app container
data "external" "yaml" {
program = [var.python_binary, "${path.module}/parseyaml.py"]
}
#Set up a personal resource group for the SE local to them
resource "azurerm_resource_group" "personal" {
name = "Sales-Engineer-${var.initials}"
location = var.location
}
#Set up a container group
resource "azurerm_container_group" "app" {
name = "${var.appname}-${var.initials}"
location = azurerm_resource_group.personal.location
resource_group_name = azurerm_resource_group.personal.name
ip_address_type = "Public"
dns_name_label = "${replace(var.appname, "/[^-0-9a-zA-Z]/", "-")}-${var.initials}"
os_type = "Linux"
container {
name = "web"
image = "contrastsecuritydemo/spring-petclinic:1.5.1"
cpu = "1"
memory = "1.5"
ports {
port = 8080
protocol = "TCP"
}
environment_variables = {
JAVA_TOOL_OPTIONS = "-javaagent:/opt/contrast/contrast.jar"
CONTRAST__API__API_KEY=data.external.yaml.result.api_key
CONTRAST__API__SERVICE_KEY=data.external.yaml.result.service_key
CONTRAST__API__USER_NAME=data.external.yaml.result.user_name
CONTRAST__API__URL=data.external.yaml.result.url
CONTRAST__APPLICATION__NAME=var.appname
CONTRAST__APPLICATION__SESSION_METADATA=var.session_metadata
CONTRAST__APPLICATION__TAGS=var.apptags
CONTRAST__SERVER__NAME=var.servername
CONTRAST__SERVER__ENVIRONMENT=var.environment
CONTRAST__SERVER__TAGS=var.servertags
}
}
}