Skip to content
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

chore: add ecr permission. update image name #8

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions .github/workflows/infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: infrastructure
env:
NODE_VERSION: 20
OIDC_ROLE_ARN: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/saas-github-oidc-provider-role
# ECR_URI: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com

permissions:
id-token: write
Expand Down Expand Up @@ -60,21 +59,13 @@ jobs:
if: ${{ steps.filter.outputs.images == 'true' }}
working-directory: ./infrastructure
run: |
# aws --version
# aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ env.ECR_URI }}
aws ecr describe-repositories --repository-names base || aws ecr create-repository --repository-name base

# REPOSITORY_URI=${{ env.ECR_URI }}/base

# docker build -t $REPOSITORY_URI:latest -f ./src/images/Dockerfile.base .
# docker tag base:latest $REPOSITORY_URI:latest
# docker push $REPOSITORY_URI:latest
aws ecr describe-repositories --repository-names $REPOSITORY || aws ecr create-repository --repository-name $REPOSITORY

docker build -t $REGISTRY/$REPOSITORY:latest -f ./src/images/Dockerfile.base .
docker push $REGISTRY/$REPOSITORY:latest
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: base
REPOSITORY: saas-base

- name: Synth
working-directory: ./infrastructure
Expand Down
3 changes: 2 additions & 1 deletion infrastructure/src/constructs/oidc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ export default class OIDCProvider extends Construct {
actions: [
'ecr:DescribeImages',
'ecr:DescribeRepositories',
'ecr:CreateRepository',
'ecr:CompleteLayerUpload',
'ecr:UploadLayerPart',
'ecr:InitiateLayerUpload',
'ecr:BatchCheckLayerAvailability',
'ecr:PutImage'
],
resources: [`arn:aws:ecr:::repository/${project}-dev-*`],
resources: [`arn:aws:ecr:::repository/${project}-*`],
effect: Effect.ALLOW
})
]
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/src/images/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM node:20-alpine3.19 AS setup
RUN apk add --no-cache python3 make g++
RUN apk add --no-cache jq
RUN apk add --no-cache git
RUN apk add --no-cache aws-cli
RUN apk add --no-cache aws-cli