-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
51 lines (37 loc) · 812 Bytes
/
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
provider "docker" {
host = "unix:///var/run/docker.sock"
}
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
}
}
}
resource "random_password" "random_pass" {
length = 12
}
variable "container_name" {
}
resource "docker_container" "mysql_container" {
name = var.container_name
image = "mysql:latest"
must_run = true
start = true
env = [
"MYSQL_ROOT_PASSWORD=${random_password.random_pass.result}"
]
ports { internal = 3306 }
}
output "container_name" {
value = docker_container.mysql_container.name
}
output "container_ip" {
value = docker_container.mysql_container.ip_address
}
output "container_port" {
value = docker_container.mysql_container.ports
}
output "image_name" {
value = docker_container.mysql_container.image
}