Skip to content

Commit

Permalink
Configure AWS region from env #1564
Browse files Browse the repository at this point in the history
And define envs in Docker/CD action
  • Loading branch information
iamleeg committed Mar 7, 2022
1 parent 63226f0 commit 19ca793
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ingestion-error-reporter-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ jobs:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: gdh-ingestor-error-monitor
IMAGE_TAG: ${{ github.sha }}
# This is a webhook for a test channel: override it on job submission!
SLACK_WEBHOOK: https://hooks.slack.com/services/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
AWS_REGION: eu-central-1
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:stable -f Dockerfile .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
Expand Down
6 changes: 4 additions & 2 deletions ingestion/monitoring/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ COPY errorLogsToSlack.py poetry.lock pyproject.toml ./
# quicker install as runtime deps are already installed
RUN poetry install

# notice I haven't set the environment variables or args here.
# the slack webhook should be configured in the job definition,
# notice I haven't set the environment variable values or args here.
# the slack webhook and AWS region should be configured in the job definition,
# and the args should be configured at submission time
ENV AWS_REGION
ENV SLACK_WEBHOOK
CMD ["poetry", "run", "python3", "./errorLogsToSlack.py"]
2 changes: 1 addition & 1 deletion ingestion/monitoring/errorLogsToSlack.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def log_messages(cloudwatch_response, logger):
logger.info(f"Output from {logGroup}/{logStream}:")
hasMore = False
oldNext = ''
logClient = boto3.client('logs')
logClient = boto3.client('logs', region_name=os.getenv('AWS_REGION'))
response = logClient.get_log_events(
logGroupName=logGroup,
logStreamName=logStream,
Expand Down

0 comments on commit 19ca793

Please sign in to comment.