I have a private ECR repo in AWS Acc #1.
Multiple Terraform projects deploy to major cloud providers. ( AWS Acc #2, GCP Acc #1, etc).
How do I refer to the images stored in the private ECR repo when defining resources for other Terraform projects?
A use case can be:-
Suppose there is an Image Image #1 in AWS Acc #1,
Now I need to use it for a lambda function in AWS Acc #2
So I'll define the resource as
resource "aws_lambda_function" "my_func" {
function_name = "my-func"
role = aws_iam_role.iam_for_lambda.arn
environment {
variables = {
UNIQUE_KEY = var.env_name
}
}
package_type = "Image"
image_uri = "{ACC_ID}.dkr.ecr.{REGION}.amazonaws.com/{IMAGE_NAME}:{TAG}"
memory_size = 4096
ephemeral_storage {
size = 4096
}
timeout = 900
}
This does not work as the Image URI {ACC_ID}.dkr.ecr.{REGION}.amazonaws.com/{IMAGE_NAME}:{TAG} is not accessible.
It works fine if Image is in AWS Acc #1 and is being used in a lambda defined in AWS Acc #2.