Skip to content

Commit

Permalink
feat: ensure aws up creation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmirJNR committed Jun 12, 2023
1 parent dbde9b9 commit 23181be
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
20 changes: 2 additions & 18 deletions .assets/initaws/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
FROM amazon/aws-cli

RUN echo '{"Version": "2012-10-17", "Statement":[{"Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::*"}]}' >> policy.json
COPY ./init.sh .

RUN aws dynamodb create-table \
--table-name order \
--attribute-definitions AttributeName=id,AttributeType=S \
--key-schema AttributeName=id,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
--table-class STANDARD \
--endpoint-url ${NO_SQL_CONNECTION_STRING} \
--region ${AWS_REGION} || true

RUN aws s3api create-bucket \
--bucket ${AWS_S3_BUCKET_NAME} \
--endpoint-url ${AWS_S3_SERVICE_URL} || true

RUN aws s3api put-bucket-policy \
--bucket ${AWS_S3_BUCKET_NAME} \
--endpoint-url ${AWS_S3_SERVICE_URL} \
--policy file://policy.json || true
ENTRYPOINT ["/bin/sh", "init.sh"]
20 changes: 20 additions & 0 deletions .assets/initaws/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

echo '{"Version": "2012-10-17", "Statement":[{"Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::*"}]}' >> policy.json

aws dynamodb create-table \
--table-name order \
--attribute-definitions AttributeName=id,AttributeType=S \
--key-schema AttributeName=id,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
--table-class STANDARD \
--endpoint-url ${NO_SQL_CONNECTION_STRING} || true

aws s3api create-bucket \
--bucket ${AWS_S3_BUCKET_NAME} \
--endpoint-url ${AWS_S3_SERVICE_URL} || true

aws s3api put-bucket-policy \
--bucket ${AWS_S3_BUCKET_NAME} \
--endpoint-url ${AWS_S3_SERVICE_URL} \
--policy file://policy.json || true
6 changes: 3 additions & 3 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ services:
nimbleflow.aws.up:
container_name: nimbleflow.aws.up
build:
dockerfile: .assets/initaws/Dockerfile
context: .
context: ./.assets/initaws
dockerfile: Dockerfile
depends_on:
nimbleflow.nosql.db:
condition: service_started
Expand Down Expand Up @@ -84,7 +84,7 @@ services:
nimbleflow.sql.db:
condition: service_healthy
nimbleflow.aws.up:
condition: service_started
condition: service_completed_successfully
extra_hosts:
- "host.docker.internal:host-gateway"

Expand Down

0 comments on commit 23181be

Please sign in to comment.