Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
10 changes: 10 additions & 0 deletions examples/docker/multiple-container-in-one-resource/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "docker_container" "containers" {
for_each = var.containers
name = each.key
memory = each.value.memory
image = each.value.image
restart = each.value.restart
env = each.value.env
}

#### this is generic template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "docker" {
host = "unix:///var/run/docker.sock"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = ">= 2.16"
}
}
}

28 changes: 28 additions & 0 deletions examples/docker/multiple-container-in-one-resource/variable.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
variable "containers" {
type = map
default = {
"nginx" = {
"image" : "nginx:alpine"
"memory" : "1024"
"env" : []
"restart" : "always"
},
"redis" = {
"image" : "redis:latest"
"memory" : "512"
"env" : []
"restart" : "unless-stopped"
}
"mysql" = {
"image" : "mysql:8"
"memory" : "1024"
"env" : [
"MYSQL_ROOT_PASSWORD = root",
"MYSQL_DATABASE = test"
]
"restart" : "no"
}
}
}

### this varriable trigger the generic template for docker containers