DEV Community

Discussion on: Deploy Elixir + Phoenix to AWS ECS with GitLab CI and Terraform

Collapse
organicnz profile image
Tarlan Isaev • Edited on

Hi mate,
thanks for the great and educational article :)
Could you pls help with this issue by any chance? :)

terraform plan

Error: Reference to undeclared resource

on deploy_user.tf line 24, in resource "aws_iam_user_policy" "ci_ecr_access":
24: "Resource": "${aws_ecr_repository.myapp_repo.arn}"

A managed resource "aws_ecr_repository" "myapp_repo" has not been declared in
the root module.

Collapse
hlappa profile image
Aleksi Holappa Author

This basically means that the ECR repository you are referring to in the user policy does not exist. Check the naming of the ECR repository resource.

I fixed one typo from the article, there was unnecessary "_url" in the ECR naming, sorry about that!

Collapse
organicnz profile image
Tarlan Isaev

Thanks for getting back to me, mate :)

Sorry that asking such silly question. Could I fix it easily by adding that ECR repo onto AWS before runnig Terrafrom commands? Unfortunatelly, I haven't touched this ECR service, yet :)

Oh, that's tottaly fine, my typos are beond my understanding lol

Thread Thread
hlappa profile image
Aleksi Holappa Author

Well, you can add it manually through AWS console if you want to. Also, you can just rename the resource and Terraform will destroy the old one and create a new one with the new name. :)

Thread Thread
organicnz profile image
Tarlan Isaev

Thanks bro, sorry, I didn't correct that typo earlier, I thought it's gonna be a next iteration of the following article heh :)