Open nmcc1212 opened 3 months ago
TF v1.8.5, Provider version "~> 3.0.1"
docker_container
terraform { required_providers { docker = { source = "kreuzwerker/docker" version = "~> 3.0.1" } } } provider "docker" {} # Define the MongoDB image resource resource "docker_image" "mongo" { name = "mongo" keep_locally = false } # Define the icds-frontend image resource resource "docker_image" "icds_frontend" { name = "ghcr.io/nmcc1212/icds-frontend:v3" keep_locally = false } # Define the volume for MongoDB data resource "docker_volume" "mongo_data" { name = "mongo-data" } # Define the db container resource resource "docker_container" "db" { image = docker_image.mongo.image_id name = "db" hostname = "db" ports { internal = 27017 external = 27017 } volumes { volume_name = docker_volume.mongo_data.name container_path = "/data/db" } volumes { host_path = "${path.module}/mongo/init.sh" container_path = "/docker-entrypoint-initdb.d/init.sh" read_only = true } volumes { host_path = "${path.module}/mongo/socialAPI.posts.json" container_path = "/docker-entrypoint-initdb.d/socialAPI.posts.json" read_only = true } } # Define the icds-frontend container resource resource "docker_container" "icds_frontend" { image = docker_image.icds_frontend.image_id name = "icds-frontend" ports { internal = 3000 external = 3000 } env = file(".tf.env") }
and the .tf.env file (obvious redactions)
[ "AUTH0_SECRET=x", "AUTH0_BASE_URL=http://localhost:3000", "AUTH0_ISSUER_BASE_URL=x", "AUTH0_CLIENT_ID=x", "AUTH0_CLIENT_SECRET=x", "API_URL = x", "MONGO_URI = mongodb://db:27017/socialAPI" ]
Using the environment variables from the file
│ 68: env = file(".tf.env") │ │ Inappropriate value for attribute "env": set of string required.
Use provided tf code and create a .tf.env file with environment variables
terraform apply
Community Note
Terraform (and docker Provider) Version
TF v1.8.5, Provider version "~> 3.0.1"
Affected Resource(s)
docker_container
Terraform Configuration Files
and the .tf.env file (obvious redactions)
Debug Output
Panic Output
Expected Behaviour
Using the environment variables from the file
Actual Behaviour
│ 68: env = file(".tf.env") │ │ Inappropriate value for attribute "env": set of string required.
Steps to Reproduce
Use provided tf code and create a .tf.env file with environment variables
terraform apply
Important Factoids
References
0000