Skip to content

Commit

Permalink
Merge pull request #23 from martijnvdp/concurrency
Browse files Browse the repository at this point in the history
add concurrent param to set max concurrent sync req v1.0.5
  • Loading branch information
martijnvdp committed Mar 18, 2023
2 parents 3c3cc04 + a6cc7cd commit b9e3e4f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Terraform module for AWS to create a lambda for syncing images <br>
between private aws/ecr and public ecrs like dockerhub/ghcr.io/quay.io
## Docker images lambda function

- `docker pull ghcr.io/martijnvdp/lambda-ecr-image-sync:v1.0.3`
- `docker pull ghcr.io/martijnvdp/lambda-ecr-image-sync:v1.0.5`

see the source repo https://github.com/martijnvdp/lambda-ecr-image-sync

Expand All @@ -23,8 +23,8 @@ module "ecrImageSync" {
ecr_repository_prefixes = distinct([for repo, tags in local.ecr_repositories : regex("^(\\w+)/.*$", repo)[0] if try(tags.source, "") != ""])
// source container image: docker pull ghcr.io/martijnvdp/ecr-image-sync:latest
lambda = {
container_uri = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/images/ecr-image-sync:v1.0.2"
lambda_function_settings = {
container_uri = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/images/ecr-image-sync:v1.0.5"
event_rules = {
Expand All @@ -33,10 +33,10 @@ module "ecrImageSync" {
}
}
settings = {
check_digest = true
ecr_repo_prefix = ""
max_results = 5
sync_settings = {
check_digest = true // wether or not to compare image digest when same tag is found on ecr and public repo
concurrent = 10 // max concurrent syncs
max_results = 5 // max tag search result
slack_errors_only = true // only errors to slack
slack_channel_id = "" // optional slack channel id
}
Expand All @@ -63,7 +63,7 @@ No requirements.
| docker\_hub\_credentials | Dockerhub credentials: {"username":"docker\_username","password":"docker\_password"} | `string` | `null` | no |
| docker\_hub\_credentials\_sm\_item\_name | AWS Secretsmanager item name for dockerhub credentials | `string` | `"docker-hub-ecr-image-sync"` | no |
| ecr\_repository\_prefixes | List of ECR repository prefixes to give the lambda function access for pushing images to | `list(string)` | `null` | no |
| lambda\_function\_settings | Lambda function options | <pre>object({<br> name = optional(string, "ecr-image-sync")<br> container_uri = optional(string, null)<br> timeout = optional(number, 900)<br> zip_file_folder = optional(string, "dist")<br> event_rules = optional(object({<br> payload_updated = optional(object({<br> description = optional(string, "Capture all updated input JSON events: ECRImageSyncScheduledEvent")<br> is_enabled = optional(bool, false)<br> }), {}),<br> repository_tags = optional(object({<br> description = optional(string, "Capture each ECR repository tag changed event")<br> is_enabled = optional(bool, true)<br> }), {})<br> scheduled_event = optional(object({<br> description = optional(string, "CloudWatch schedule for synchronization of the public Docker images.")<br> is_enabled = optional(bool, true)<br> schedule_expression = optional(string, "cron(0 6 * * ? *)")<br> }), {})<br> }), {})<br> sync_settings = optional(object({<br> check_digest = optional(bool, true)<br> max_results = optional(number, 100)<br> }), {})<br> })</pre> | `{}` | no |
| lambda\_function\_settings | Lambda function options | <pre>object({<br> name = optional(string, "ecr-image-sync")<br> container_uri = optional(string, null)<br> timeout = optional(number, 900)<br> zip_file_folder = optional(string, "dist")<br> event_rules = optional(object({<br> payload_updated = optional(object({<br> description = optional(string, "Capture all updated input JSON events: ECRImageSyncScheduledEvent")<br> is_enabled = optional(bool, false)<br> }), {}),<br> repository_tags = optional(object({<br> description = optional(string, "Capture each ECR repository tag changed event")<br> is_enabled = optional(bool, true)<br> }), {})<br> scheduled_event = optional(object({<br> description = optional(string, "CloudWatch schedule for synchronization of the public Docker images.")<br> is_enabled = optional(bool, true)<br> schedule_expression = optional(string, "cron(0 6 * * ? *)")<br> }), {})<br> }), {})<br> sync_settings = optional(object({<br> check_digest = optional(bool, true)<br> concurrent = optional(number, 5)<br> max_results = optional(number, 100)<br> }), {})<br> })</pre> | `{}` | no |
| s3\_workflow | S3 bucket workflow options | <pre>object({<br> bucket = optional(string, "ecr-image-sync")<br> codebuild_project_name = optional(string, "ecr-image-sync")<br> codepipeline_name = optional(string, "ecr-image-sync")<br> crane_version = optional(string, "v0.11.0")<br> create_bucket = optional(bool, false)<br> debug = optional(bool, false)<br> enabled = optional(bool, false)<br> })</pre> | `{}` | no |
| tags | A mapping of tags assigned to the resources | `map(string)` | `null` | no |

Expand Down
1 change: 1 addition & 0 deletions eventbridge.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ locals {
input_template = <<EOF
{
"check_digest": ${local.sync_settings.check_digest},
"concurrent": ${local.sync_settings.concurrent},
"max_results": ${local.sync_settings.max_results},
"repositories": <resources>
}
Expand Down
3 changes: 2 additions & 1 deletion examples/full.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module "ecrImageSync" {

// source container image: docker pull ghcr.io/martijnvdp/lambda-ecr-image-sync:v1.0.3
lambda_function_settings = {
container_uri = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/martijnvdp/lambda-ecr-image-sync:v1.0.3"
container_uri = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/martijnvdp/lambda-ecr-image-sync:v1.0.5"

event_rules = {

Expand All @@ -80,6 +80,7 @@ module "ecrImageSync" {

sync_settings = {
check_digest = true
concurrent = 10
max_results = 5
}
}
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ locals {

sync_settings = {
check_digest = var.lambda_function_settings.sync_settings.check_digest
concurrent = var.lambda_function_settings.sync_settings.concurrent
max_results = var.lambda_function_settings.sync_settings.max_results
}
}
Expand Down
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ variable "lambda_function_settings" {
}), {})
sync_settings = optional(object({
check_digest = optional(bool, true)
concurrent = optional(number, 5)
max_results = optional(number, 100)
}), {})
})
Expand Down

0 comments on commit b9e3e4f

Please sign in to comment.