-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
70 lines (63 loc) · 1.68 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
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "3.0.2"
}
}
}
provider "docker" {
host = "ssh://${var.ssh_user}@${var.remote_host}:${var.ssh_port}"
ssh_opts = ["-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null"]
}
resource "docker_image" "ejbca_img" {
name = var.image_name
keep_locally = true
}
resource "docker_image" "mariadb" {
name = var.mariadb_image
keep_locally = true
}
resource "docker_network" "ejbca_net" {
name = "ejbca_net"
attachable = false
check_duplicate = true
ipam_config {
subnet = var.network_subnet
}
}
resource "docker_container" "ejbca" {
name = var.container_name
image = docker_image.ejbca_img.name
env = [
"DATABASE_JDBC_URL=jdbc:mariadb://${var.db_host}:3306/${var.db_name}?characterEncoding=UTF-8",
"DATABASE_USER=ejbca",
"DATABASE_PASSWORD=${var.db_password}",
"LOG_LEVEL_APP=INFO",
"LOG_LEVEL_SERVER=INFO",
"TLS_SETUP_ENABLED=later",
"PASSWORD_ENCRYPTION_KEY=changeme",
"CA_KEYSTOREPASS=changeme",
"EJBCA_CLI_DEFAULTPASSWORD=ejbca",
"PROXY_HTTP_BIND=${var.container_ip}",
]
memory = 2000
networks_advanced {
name = docker_network.ejbca_net.name
ipv4_address = var.container_ip
}
}
resource "docker_container" "mariadb" {
name = var.db_container_name
image = docker_image.mariadb_image.name
env = [
"MARIADB_USER=ejbca",
"MARIADB_PASSWORD=${var.db_password}",
"MARIADB_ROOT_PASSWORD=${var.db_password}",
"MARIADB_DATABASE=ejbca"
]
networks_advanced {
name = docker_network.ejbca_net.name
ipv4_address = var.db_host
}
}