Skip to content

Commit c8c111c

Browse files
committed
Set region when granting ECR access - better way?
1 parent dbc39f8 commit c8c111c

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

.github/workflows/build-runtime.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,19 @@ jobs:
6262
- name: Grant Lambda access to ECR repository
6363
run: |
6464
set -euo pipefail
65-
runtime="${{ env.RUNTIME_NAME }}"
66-
repo=$(aws ecr describe-repositories \
67-
--query 'repositories[].repositoryName' \
68-
--output text | tr '\t' '\n' | grep "$runtime" | head -1)
65+
region="${{ steps.config.outputs.region }}"
66+
repo=$(python3 -c "
67+
import yaml, os, lithops
68+
with open(os.path.expanduser('~/.lithops/config')) as f:
69+
c = yaml.safe_load(f)
70+
user_id = c['aws_lambda']['user_id']
71+
user_key = user_id[-4:].lower()
72+
v = lithops.__version__.replace('.', '')
73+
print(f'lithops_v{v}_{user_key}/${{ env.RUNTIME_NAME }}')
74+
")
6975
echo "Setting ECR policy on: $repo"
7076
aws ecr set-repository-policy \
77+
--region "$region" \
7178
--repository-name "$repo" \
7279
--policy-text '{
7380
"Version": "2012-10-17",

0 commit comments

Comments
 (0)