i am trying to deploy the docker_network, using terraform, i was not able to label the network resource type.
the below is the block of code that i am using
resource "docker_network" "private_network" {
  name = "my_network"
  attachable = true
  labels = {
    challenge = "second"
  }
}
         
        
          
        
           
           
           
         
         
            
            
          
       
      
        
        
          Hi @gopicn45
That’s because you haven’t defined labels correctly. It is not an argument, it is a block.
To find the documentation for the docker provider, look in provider.tf to get the provider name which is kreuzwerker/docker
Then look it up at https://registry.terraform.io/ and you’ll find that the correct way to create a label is
resource "docker_network" "private_network" {
  name = "my_network"
  attachable = true
  labels {
    label = "challenge"
    value =  "second"
  }
}
         
        
        
           
           
           
         
         
            
            
          
       
      
        
        
          @Alistair_KodeKloud
i included the network in the db_dashboard container spec still the condition is not satisfied
can you please have a look at it.
below is the code that  i used to configure.
resource "docker_network" "private_network" {
  name = "my_network"
  attachable = true
  labels {
    label = "challenge"
    value = "second"
  }
}
==================================================
resource "docker_container" "phpmyadmin" {
  name  = "db_dashboard"
  image = "phpmyadmin/phpmyadmin"
  hostname = "phpmyadmin"
  networks = [docker_network.private_network.name]
  depends_on = [
    docker_container.mariadb
  ]
  links = [docker_container.mariadb.name]
  labels {
    label = "challenge"
    value = "second"
  }
  volumes {
    container_path  = "/var/lib/mysql"
    read_only = false
    volume_name = docker_volume.mariadb_volume.name
  }
  ports {
    internal = "80"
    external = "8081"
  }
}
         
        
        
           
           
           1 Like
         
         
            
            
          
       
      
        
        
          Yeah that doesn’t seem right. I’ll get it checked
         
        
        
           
           
           
         
         
            
            
          
       
      
        
        
          i appreciate it. thanks @Alistair_KodeKloud
         
        
        
           
           
           
         
         
            
            
          
       
      
        
        
          Please try it now. Should be fixed
         
        
        
           
           
           1 Like
         
         
            
            
          
       
      
        
        
          thank you it’s working now. @Alistair_KodeKloud
         
        
        
           
           
           
         
         
            
            
          
       
      
        
        
          hi, greetings for the day,  hope you are doing well.
below is the code i am using for the terraform challange-3 can you please tell me where i am going wrong
resource "aws_key_pair" "citadel-key" {
  key_name   = "citadel"
  public_key = file("/root/terraform-challenges/project-citadel/.ssh/ec2-connect-key.pub")
}
variable "region" {
     description = "using region "
     default = "eu-west-2"
}
resource "aws_eip" "master" {
  vpc      = true
  provisioner "local-exec" {
    command = "echo ${aws_eip.master.public_dns} > /root/citadel_public_dns.txt"
  }
}
data "template_file" "user_data" {
template = file("install-nginx.sh")
}
resource "aws_instance" "web" {
  ami           = "ami-06178cf087598769c"
  instance_type = "m5.large"
  user_data = data.template_file.user_data.rendered
  key_name = aws_key_pair.citadel-key.key_name
  tags = {
    Env = "dev"
  }
}
resource "aws_eip_association" "eip_assoc" {
  instance_id   = aws_instance.web.id
  allocation_id = aws_eip.master.id
}
i appriciate your help, thank you.
         
        
        
           
           
           
         
         
            
            
          
       
      
        
        
          Hi @gopicn45
There are a few issues with your configuration. We now have solutions for the challenges here: GitHub - kodekloudhub/terraform-challenges