If you get X-Registry-Auth error, make sure that the address property inside the registry_auth block inside the provider is set properly and points to ECR. The format is usually ".dkr.ecr..amazonaws.com"
I have the same issue X-Registry-Auth: EOF... I double checked anything (username, password, image name, address) and I still get the same error. Here is my code: provider "docker" { registry_auth { address = module.ecr.repository_url username = data.aws_ecr_authorization_token.token.user_name password = data.aws_ecr_authorization_token.token.password } } resource "docker_registry_image" "backend" { name = "${module.ecr.repository_url}:latest" build { context = "blabla/bla" dockerfile = "Dockerfile" auth_config { auth = "123" host_name = module.ecr.repository_url } } } I find "auth_config" block in the internet, but i don't know what should i pass into the host_name variable...
Hi @@ZergStylexDD , Firstly, i would verify what module.ecr.repository_url points to and make sure this is an ECR repository url. You dont need the auth_config block inside build. The registry_auth will take care of the connection to ECR.
May i know why you are using a module for this property? I would normally build the value of this as a string like "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com"
Hi! Thank you for video! I have tried to repeat but I receiver error: Error: Error pushing docker image: Error response from daemon: Bad parameters and missing X-Registry-Auth: EOF..... looks like I have to login with docker? shouldn't be registry_auth parameters already enough?? thank you!
Hello. Thank you for your question. When you run terraform, it will take care of the login to AWS ECR using the credentials and address provided inside the registry_auth inside the docker provider block (3:33). Could you check if this is set especially the address property? Also check if the name property inside docker_registry_name is set properly (4:54). Hope this helps.
Thats right. I find it very easy to manage images this way - I can easily correlate an image tag with a git commit. So if a particular image is faulty, i know which commit has the changes that may have caused it to break.
how would you do outputs for each docker_registry_image which then can be used in another module? 🤔i'm trying to use the same example to refactor a bit of my code but I need the outputs of those images in another module and I keep having issues
You can output the entire object (maybe jsonencode the object so the output becomes a map). Or interpolate on the object to select only the fields you want to output. Ill try to create a quick video on this today hopefully ready by tomorrow. We’ll see :)
@@pablosspot Yeah i tried to do this-> jsonencode(docker_registry_image.images) and the plan ran but then it failed in the apply with "ECS Task Definition container_definitions is invalid: Error decoding JSON: invalid character '{' after object key:value pair" so I think the issue is that i need to pass a specific element but this is a bit beyond my knowledge. let me know if you ever make that video! thanks George
New episode on handling outputs coming up. It should become available tomorrow. Not sure if I managed to answer your question or if it even helps. Hopefully it does.
Thank you! I updated the description with this link to the source code. github.com/dyordsabuzo/infrastructure-for-event-driven-system/tree/95df283caabfc767e0364b190f2c5fed5f2176c5/infrastructure
Thanks for the video :) I'm getting this error "Error pushing docker image: Error response from daemon: Bad parameters and missing X-Registry-Auth: EOF", any ideas on how to solve it? (I'm setting all the auth parameters)
@@pablosspot It was my mistake, I was using "name" instead of "repository_url" in the docker_registry_image resource name. Thanks for your answer, keep up the good work
Yep. I was hoping this is something i could set from the terraform CLI but I have not figured out how to do it if it is possible, I ended up creating an adhoc shell script that makes an API call to update this property in terraform cloud OR the old fashion manual way like what i did here.
Thanks for the video Pablo!
Thanks man! very nice explanation
Thanks! You explained it well!
Amazing!!! Thanks for the video!!
If you get X-Registry-Auth error, make sure that the address property inside the registry_auth block inside the provider is set properly and points to ECR. The format is usually ".dkr.ecr..amazonaws.com"
Thanks Pablo!
Thank you man!
Thank you!!
I have the same issue X-Registry-Auth: EOF...
I double checked anything (username, password, image name, address) and I still get the same error. Here is my code:
provider "docker" {
registry_auth {
address = module.ecr.repository_url
username = data.aws_ecr_authorization_token.token.user_name
password = data.aws_ecr_authorization_token.token.password
}
}
resource "docker_registry_image" "backend" {
name = "${module.ecr.repository_url}:latest"
build {
context = "blabla/bla"
dockerfile = "Dockerfile"
auth_config {
auth = "123"
host_name = module.ecr.repository_url
}
}
}
I find "auth_config" block in the internet, but i don't know what should i pass into the host_name variable...
please, help me if you can :)
Hi @@ZergStylexDD ,
Firstly, i would verify what module.ecr.repository_url points to and make sure this is an ECR repository url.
You dont need the auth_config block inside build. The registry_auth will take care of the connection to ECR.
May i know why you are using a module for this property? I would normally build the value of this as a string like "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com"
@@pablosspot I fix this, thank you. I don't know why my 2 previous message was deleted, but thank you :)
Thanks!
Hi! Thank you for video! I have tried to repeat but I receiver error: Error: Error pushing docker image: Error response from daemon: Bad parameters and missing X-Registry-Auth: EOF.....
looks like I have to login with docker? shouldn't be registry_auth parameters already enough?? thank you!
Hello.
Thank you for your question.
When you run terraform, it will take care of the login to AWS ECR using the credentials and address provided inside the registry_auth inside the docker provider block (3:33). Could you check if this is set especially the address property?
Also check if the name property inside docker_registry_name is set properly (4:54).
Hope this helps.
@@pablosspot it was a problem with the image name 🙄 thank you for the quick reply!
You are most welcome :)
nice. but when the source code changes and run terraform apply the new image will not be pushed to the registry with same tag.
Thats right. I find it very easy to manage images this way - I can easily correlate an image tag with a git commit. So if a particular image is faulty, i know which commit has the changes that may have caused it to break.
how would you do outputs for each docker_registry_image which then can be used in another module? 🤔i'm trying to use the same example to refactor a bit of my code but I need the outputs of those images in another module and I keep having issues
You can output the entire object (maybe jsonencode the object so the output becomes a map). Or interpolate on the object to select only the fields you want to output. Ill try to create a quick video on this today hopefully ready by tomorrow. We’ll see :)
@@pablosspot Yeah i tried to do this-> jsonencode(docker_registry_image.images) and the plan ran but then it failed in the apply with "ECS Task Definition container_definitions is invalid: Error decoding JSON: invalid character '{' after object key:value pair" so I think the issue is that i need to pass a specific element but this is a bit beyond my knowledge. let me know if you ever make that video! thanks George
New episode on handling outputs coming up. It should become available tomorrow. Not sure if I managed to answer your question or if it even helps. Hopefully it does.
So once your image is in ecr, how do you move it to your EC2 ?
Hello. You will need docker installed on your ec2. And then you can run docker pull to pull the image on the EC2.
@@pablosspot Thanks
Thanks for the video. Can i get this complete code pls
Thank you! I updated the description with this link to the source code.
github.com/dyordsabuzo/infrastructure-for-event-driven-system/tree/95df283caabfc767e0364b190f2c5fed5f2176c5/infrastructure
Thanks for the video :) I'm getting this error "Error pushing docker image: Error response from daemon: Bad parameters and missing X-Registry-Auth: EOF", any ideas on how to solve it? (I'm setting all the auth parameters)
Looks like an authorization error to me.
Try manually running a docker login on a terminal and see if it works.
docker login -u -p
@@pablosspot I got a Login Suceeded when running that command in the cli
@@pablosspot It was my mistake, I was using "name" instead of "repository_url" in the docker_registry_image resource name. Thanks for your answer, keep up the good work
9:30
Wtf? Really?
Yep. I was hoping this is something i could set from the terraform CLI but I have not figured out how to do it if it is possible, I ended up creating an adhoc shell script that makes an API call to update this property in terraform cloud OR the old fashion manual way like what i did here.
its not working, I guess its not working anymore because it is an old version
I will have a look when I get the chance. Currently away for a break and don’t have access to a machine. Thank you for pointing this out
Mate your gun :)