I have a Docker image pushed already on ECR. I have also used it to create lambda function from a container image through AWS console, and it worked successfully.
Now, I want to create the function through AWS CDK.
Inside the __init__ function of the lambda stack class, I have added:
repo = aws_ecr.Repository.from_repository_name(scope, "Repository", repository_name="my-repo-name")
lambdaFn = aws_lambda.DockerImageFunction(
self, "Test Function",
code=aws_lambda.DockerImageCode.from_ecr(repo),
timeout=core.Duration.seconds(600),
memory_size=8192,
environment=dict(PATH="/opt"),
role = role
)
I have an issue with defining repo variable from an existing repo on ECR.