Skip to content

Commit

Permalink
🚧 Add gitops permissions policy
Browse files Browse the repository at this point in the history
  • Loading branch information
mdesouky committed Feb 14, 2024
1 parent 9e08b87 commit 0a49f25
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/apply_permissions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Lint
on:
push:
pull_request: ~

jobs:
update-policy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-southeast-2
- name: Run script to update ECR policy
run: |
bash ecr/apply_permissions.sh
8 changes: 8 additions & 0 deletions ecr/apply_permissions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash


ECR_REPO_NAME="gitops"
POLICY_FILE="ecr/permissions.json"

# Update ECR repository policy
aws ecr set-repository-policy --repository-name $ECR_REPO_NAME --policy-text file://$POLICY_FILE
20 changes: 20 additions & 0 deletions ecr/permissions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowOrganizationPull",
"Effect": "Allow",
"Principal": "*",
"Action": [
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability"
],
"Condition": {
"StringEquals": {
"aws:PrincipalOrgID": "o-4mi26lv5bn"
}
}
}
]
}

0 comments on commit 0a49f25

Please sign in to comment.