Skip to content

Latest commit

 

History

History

challenge-2

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Challenge 2

In this challenge we will implement a simple LAMP stack using terraform and docker.

Utilize /root/code/terraform-challenges/challenge2 directory to store your Terraform configuration files.

We will create the resources in the order of their dependencies, thus you may run plan/apply at any stage, or wait till the end.

Note that these challenges do not use an embedded VSCode IDE, therefore we must use the venerable vi to create and edit files. Now you can put all the resources into a single file e.g. main.tf or as shown here in separate files. Terraform doesn't care!

  1. terraform-jump-host
    Install terraform binary version=1.1.5 on iac-server
    curl -L -o /tmp/terraform_1.1.5_linux_amd64.zip https://releases.hashicorp.com/terraform/1.1.5/terraform_1.1.5_linux_amd64.zip
    unzip -d /usr/local/bin /tmp/terraform_1.1.5_linux_amd64.zip
  2. docker
    Docker provider has already been configured using kreuzwerker/docker provider.
    Check out the provider.tf given at /root/code/terraform-challenges/challenge2
    cd /root/code/terraform-challenges/challenge2
    cat provider.tf

    Let's initialize the provider now.

    terraform init
    

    You should now refer to the documentation for this provider. Go to the Terraform Registry and paste kreuzwerker/docker into the search bar.

  3. php-httpd-image
    Create a terraform resource named php-httpd-image

    Refer to the provider documentation for docker-image

    Using vi, create php-httpd-image.tf

  4. mariadb-custom-image
    Create a terraform resource named mariadb-image

    Refer to the provider documentation for docker-image

    Using vi, create mariadb-custom-image.tf

  5. mariadb-volume
    Create a terraform resource named mariadb_volume

    Refer to the provider documentation for docker-volume

    Using vi, create mariadb-volume.tf

  6. private_network
    Create a terraform resource named private_network

    Refer to the provider documentation for docker-network

    Using vi, create private-network.tf

  7. db
    Define a terraform resource mariadb for creating docker container

    Refer to the provider documentation for docker-container

    Using vi, create db.tf

  8. webserver
    Define a terraform resource php-httpd for creating docker container

    Refer to the provider documentation for docker-container

    Using vi, create webserver.tf

  9. db_dashboard
    Define a terraform resource phpmyadmin for docker container

    Refer to the provider documentation for docker-container

    Using vi, create db-dashboard.tf

  10. DEPLOY!
    terraform plan
    terraform apply