Terraform Challenge 2

Hi all,

I have one small issue with each of the three containers for the second challenge. Could you check what I did wrong? I’ve included my resource blocks.

(1) webserver
[x] Bind hostPath /root/code/terraform-challenges/challenge2/lamp_stack/website_content/ to /var/www/html within webserver container.

resource "docker_container" "php-httpd" {
  name     = "webserver"
  image    = "php-httpd:challenge"
  hostname = "php-httpd"

  networks_advanced {
    name = "my_network"
  }
  ports {
    internal = 80
    external = 80
    ip       = "0.0.0.0"
  }
  mounts {
    source = "/root/code/terraform-challenges/challenge2/lamp_stack/website_content/"
    target = "/var/www/html"
    type   = "bind"
  }
  labels {
    label = "challenge"
    value = "second"
  }
}

(2) db_dashboard
[x] Explicitly specify a dependency on mariadb terraform resource

resource "docker_container" "phpmyadmin" {
  name     = "db_dashboard"
  image    = "phpmyadmin/phpmyadmin"
  hostname = "phpmyadmin"

  networks_advanced {
    name = "my_network"
  }
  ports {
    internal  = 80
    external = 8081
    ip        = "0.0.0.0"
  }
  labels {
    label = "challenge"
    value = "second"
  }
  links = ["db"]
  
  depends_on = [
    docker_container.mariadb
  ]
}

(3) db
[x] Define environment variables:
MYSQL_ROOT_PASSWORD=1234
MYSQL_DATABASE=simple-website

iac-server $ cd /root/code/terraform-challenges/challenge2
iac-server $ export TF_VAR_MYSQL_DATABASE="simple-website"
iac-server $ export TF_VAR_MYSQL_ROOT_PASSWORD="1234"

Hi @jimmysmits ,

Thanks for the feedback. We made a few tweaks to the questions for more clarification. Could you please give it one more shot?

Kind Regards,
Kodekloud Team

Thanks Dinesh, the clarifications have resolved the issue!

I wonder what is the issue. Maybe someone can help.
image

My code:

resource "docker_image" "php-httpd-image" {
  name = "php-httpd-image"
  build {
    path = "./lamp_stack/php_httpd"
    tag  = ["php-httpd:challenge"]
    label = {
      challenge : "second"
    }
  }
}

hi @flissek change image name to php-httpd:challenge not php-httpd-image…

Curious if this challenge is still managed/supported… I am using terraform version 1.1.5 as suggested in the challenge…

Yes.

Please check docker repository login status

The given solution still works. I have just tested it again.