-
Notifications
You must be signed in to change notification settings - Fork 0
feat: dynamic assume-role support, configurable placeholder image & install tofu consolidation #25
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
base: main
Are you sure you want to change the base?
Changes from all commits
085964a
d9ff61b
52cba87
d49d2b9
33842ec
14d3ad5
fc8bc76
3f89288
97121e4
684d9f7
b9e41d3
bd26af4
2dc0a3e
c04e9cc
bbd31a0
e186fa2
41ed944
779eef9
4ff57c4
5109c0e
23e2515
0b68476
51836a5
6752bee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,22 @@ if [ "$package_type" = "Image" ]; then | |
| fi | ||
| log debug " ✅ image_uri=$IMAGE_URI" | ||
|
|
||
| # Ensure the image's ECR repo lets the Lambda service pull it. Container-image | ||
| # Lambdas require a repository policy granting lambda.amazonaws.com; without it | ||
| # update-function-code fails with "Lambda does not have permission to access | ||
| # the ECR image". Idempotent and best-effort (cross-account repos may not be | ||
| # writable from here — Lambda would then need the policy set on the source side). | ||
| if [[ "$IMAGE_URI" == *.dkr.ecr.*.amazonaws.com/* ]]; then | ||
| ecr_region=$(echo "${IMAGE_URI%%/*}" | cut -d. -f4) | ||
| ecr_repo="${IMAGE_URI#*/}"; ecr_repo="${ecr_repo%%:*}"; ecr_repo="${ecr_repo%%@*}" | ||
| lambda_pull_policy='{"Version":"2008-10-17","Statement":[{"Sid":"LambdaECRImageRetrievalPolicy","Effect":"Allow","Principal":{"Service":"lambda.amazonaws.com"},"Action":["ecr:BatchGetImage","ecr:GetDownloadUrlForLayer"]}]}' | ||
| if aws ecr set-repository-policy --repository-name "$ecr_repo" --region "$ecr_region" --policy-text "$lambda_pull_policy" >/dev/null 2>&1; then | ||
| log debug " ✅ ensured Lambda pull policy on ECR repo $ecr_repo" | ||
| else | ||
| log warn " ⚠️ could not set Lambda pull policy on ECR repo $ecr_repo (continuing; pull may fail if not already allowed)" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esto está confirmado que puede llegar a funcionar? si es una certeza que va a fallar después, tiraría un error.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. esta con warning por esto: |
||
| fi | ||
| fi | ||
|
|
||
| update_output=$(aws lambda update-function-code \ | ||
| --function-name "$LAMBDA_FUNCTION_NAME" \ | ||
| --image-uri "$IMAGE_URI" \ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| include: | ||
| - "$SERVICE_PATH/values.yaml" | ||
| steps: | ||
| - name: assume_role | ||
| type: script | ||
| file: "$SERVICE_PATH/utils/assume_role_step" | ||
| output: | ||
| - name: AWS_ACCESS_KEY_ID | ||
| type: environment | ||
| - name: AWS_SECRET_ACCESS_KEY | ||
| type: environment | ||
| - name: AWS_SESSION_TOKEN | ||
| type: environment | ||
| - name: build_context | ||
| type: script | ||
| file: "$SERVICE_PATH/diagnose/build_context" | ||
| output: | ||
| - name: SCOPE_ID | ||
| type: environment | ||
| - name: SCOPE_NRN | ||
| type: environment | ||
| - name: LAMBDA_FUNCTION_NAME | ||
| type: environment | ||
| - name: LAMBDA_FUNCTION_ARN | ||
| type: environment | ||
| - name: LAMBDA_ROLE_ARN | ||
| type: environment | ||
| - name: SCOPE_DOMAIN | ||
| type: environment | ||
| - name: diagnose | ||
| type: executor | ||
| before_each: | ||
| name: notify_check_running | ||
| type: script | ||
| file: "$SERVICE_PATH/diagnose/notify_check_running" | ||
| after_each: | ||
| name: notify_check_results | ||
| type: script | ||
| file: "$SERVICE_PATH/diagnose/notify_results" | ||
| folders: | ||
| - "$SERVICE_PATH/diagnose/checks" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,16 @@ | ||
| include: | ||
| - "$SERVICE_PATH/values.yaml" | ||
| steps: | ||
| - name: assume_role | ||
| type: script | ||
| file: "$SERVICE_PATH/utils/assume_role_step" | ||
| output: | ||
| - name: AWS_ACCESS_KEY_ID | ||
| type: environment | ||
| - name: AWS_SECRET_ACCESS_KEY | ||
| type: environment | ||
| - name: AWS_SESSION_TOKEN | ||
| type: environment | ||
| - name: list_metrics | ||
| type: script | ||
| file: "$SERVICE_PATH/metric/list_metrics" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,14 +38,15 @@ log info "🔍 Resolving placeholder image URI..." | |
| placeholder_image_base="${PLACEHOLDER_IMAGE_URI:-public.ecr.aws/nullplatform/aws-lambda/nullplatform-lambda-placeholder:latest}" | ||
| architecture="${ARCHITECTURE:-arm64}" | ||
|
|
||
| # Lambda uses "x86_64" but images are tagged with Docker convention "amd64" | ||
| arch_tag="${architecture}" | ||
| [ "$architecture" = "x86_64" ] && arch_tag="amd64" | ||
| log debug " 📋 architecture=$architecture" | ||
|
|
||
| # Use the image URI as-is. If PLACEHOLDER_IMAGE_URI is not set, the default | ||
| # :latest tag is used without any architecture suffix — publish arch-specific | ||
| # tags and set PLACEHOLDER_IMAGE_URI explicitly if needed. | ||
|
Comment on lines
+43
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Saquemos este comment |
||
| if [[ "$placeholder_image_base" == *":"* ]]; then | ||
| placeholder_image_uri="${placeholder_image_base}-${arch_tag}" | ||
| placeholder_image_uri="$placeholder_image_base" | ||
| else | ||
| placeholder_image_uri="${placeholder_image_base}:latest-${arch_tag}" | ||
| placeholder_image_uri="${placeholder_image_base}:latest" | ||
| fi | ||
|
|
||
| log debug " 📋 architecture=$architecture" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No entiendo porque necesitamos esto?
Que pasa si la uri no es de amazonaws.com?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lambda con docker, solo fucniona con imagenes de ecr https://docs.aws.amazon.com/es_es/lambda/latest/dg/images-create.html