-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement]: Lightsail add option to enable access to Amazon ECR private repositories #27201
Comments
Community NoteVoting for Prioritization
Volunteering to Work on This Issue
|
Hi @reikje, Thanks for taking your time to raise this request. I'll happily take a look at it. API for reference: https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_CreateContainerService.html I suspect that the schema will be as following (by quickly glancing over the API spec) resource "aws_lightsail_container_service" "my_container_service" {
name = "container-service-1"
power = "nano"
scale = 1
is_disabled = false
private_registry_access {
ecr_image_puller_role {
is_active = true
}
}
} |
PR is ready :) |
Hi @bschaatsbergen, thanks for picking this up so quickly. Scanned through the changes quickly but not very good with golang here. Does your PR include changing the policy permissions on the ECR repository or just enabling the puller role? Here is a bit of a poor man's workaround that I currently do on my end since the functionality wasn't there:
One problem I am having right now is that on the initial run, is that when Lightsail container service is created, it initially is in state
The |
Hi @reikje, The pull request introduces the ability to activate the ECR image puller role and outputs that respective principal ARN. resource "aws_lightsail_container_service" "default" {
name = "container-service-1"
power = "nano"
scale = 1
is_disabled = false
private_registry_access {
ecr_image_puller_role {
is_active = true
}
}
}
resource "aws_ecr_repository" "default" {
name = "bar"
image_tag_mutability = "MUTABLE"
image_scanning_configuration {
scan_on_push = true
}
}
resource "aws_ecr_repository_policy" "default" {
repository = aws_ecr_repository.default.name
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "allow-lightsail",
"Effect": "Allow",
"Principal": {
"AWS": "${aws_lightsail_container_service.default.private_registry_access[0].ecr_image_puller_role[0].principal_arn}"
},
"Action": [
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer"
]
}
]
}
EOF
} Quick feedback on why your code doesn't work the first run from a blank slate; it's because updating the lightsail container service takes about 30 seconds. Hopefully you can replace your logic soonish with what I've shared above :) |
@bschaatsbergen thanks and great - outputting the respective principal ARN will totally work. Cheers and great work! |
With pleasure @reikje, I suppose that this will be either part of the upcoming release or the one after that. |
This functionality has been released in v4.36.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Description
Lightsail Container Service can poll images from private ECR repositories. For this to work, two things need to happen:
see: https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-container-service-ecr-private-repo-access
While I can do (2) using the
aws_ecr_repository_policy
resource, I haven't found anything in theaws_lightsail_container_service
to accomplish (1).Affected Resource(s) and/or Data Source(s)
aws_lightsail_container_service
Potential Terraform Configuration
No response
References
No response
Would you like to implement a fix?
No
The text was updated successfully, but these errors were encountered: