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

Versions/aeolus #360

Merged
merged 22 commits into from
Jul 26, 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
86 changes: 86 additions & 0 deletions .github/workflows/deploy-aeolus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Deploy aeolus

on:
push:
branches:
- versions/aeolus

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@master
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_PROD }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_PROD }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Get envionmental values
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
AEOLUS, openaq-env/aeolus
name-transformation: uppercase
parse-json-secrets: true

- uses: actions/setup-node@v3
with:
node-version: "18"

- name: build pages
working-directory: ./pages
run: |
yarn install
yarn run deploy

- name: Install CDK
run: |
npm install -g [email protected]

- uses: actions/setup-python@v3
with:
python-version: '3.11'

- name: Deploy stack
env:
ENV: "aeolus"
PROJECT: "openaq"
DATABASE_READ_USER: ${{ env.AEOLUS_DATABASE_READ_USER }}
DATABASE_READ_PASSWORD: ${{ env.AEOLUS_DATABASE_READ_PASSWORD }}
DATABASE_WRITE_USER: ${{ env.AEOLUS_DATABASE_WRITE_USER }}
DATABASE_WRITE_PASSWORD: ${{ env.AEOLUS_DATABASE_WRITE_PASSWORD }}
DATABASE_DB: ${{ env.AEOLUS_DATABASE_DB }}
DATABASE_HOST: ${{ env.AEOLUS_DATABASE_HOST }}
DATABASE_PORT: ${{ env.AEOLUS_DATABASE_PORT }}
API_LAMBDA_MEMORY_SIZE: ${{ env.AEOLUS_API_LAMBDA_MEMORY_SIZE }}

CDK_ACCOUNT: ${{ secrets.CDK_ACCOUNT }}
CDK_REGION: ${{ secrets.CDK_REGION }}

VPC_ID: ${{ env.AEOLUS_VPC_ID }}

RATE_LIMITING: True
RATE_AMOUNT: 10
RATE_AMOUNT_KEY: 10
RATE_TIME: 1
USER_AGENT: ${{ env.AEOLUS_USER_AGENT }}
ORIGIN: ${{ env.AEOLUS_ORIGIN }}
REDIS_HOST: ${{ env.AEOLUS_REDIS_HOST }}
REDIS_PORT: ${{ env.AEOLUS_REDIS_PORT }}
REDIS_SECURITY_GROUP_ID: ${{ env.AEOLUS_REDIS_SECURITY_GROUP_ID }}

EMAIL_SENDER: ${{ env.AEOLUS_EMAIL_SENDER }}
SMTP_EMAIL_HOST: ${{ env.AEOLUS_SMTP_EMAIL_HOST }}
SMTP_EMAIL_USER: ${{ env.AEOLUS_SMTP_EMAIL_USER }}
SMTP_EMAIL_PASSWORD: ${{ env.AEOLUS_SMTP_EMAIL_PASSWORD }}

EXPLORER_API_KEY: ${{ env.AEOLUS_EXPLORER_API_KEY }}

working-directory: ./cdk
run: |
pip install -r requirements.txt
cdk deploy openaq-api-aeolus --require-approval never
16 changes: 5 additions & 11 deletions cdk/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
sys.path.insert(1, p)
from openaq_api.settings import settings as lambda_env

p = os.path.abspath("../cloudfront_logs")
sys.path.insert(1, p)
from cloudfront_logs.settings import settings as cloudfront_logs_lambda_env
#p = os.path.abspath("../cloudfront_logs")
#sys.path.insert(1, p)
#from cloudfront_logs.settings import settings as cloudfront_logs_lambda_env

app = aws_cdk.App()

Expand All @@ -31,17 +31,11 @@
f"openaq-api-{settings.ENV}",
env_name=settings.ENV,
lambda_env=lambda_env,
cloudfront_logs_lambda_env=cloudfront_logs_lambda_env,
vpc_id=settings.VPC_ID,
hosted_zone_name=settings.HOSTED_ZONE_NAME,
hosted_zone_id=settings.HOSTED_ZONE_ID,
redis_security_group_id=settings.REDIS_SECURITY_GROUP_ID,
redis_port=settings.REDIS_PORT,
api_lambda_timeout=settings.API_LAMBDA_TIMEOUT,
api_lambda_memory_size=settings.API_LAMBDA_MEMORY_SIZE,
cf_logs_lambda_timeout=settings.CF_LOG_LAMBDA_TIMEOUT,
cf_logs_lambda_memory_size=settings.CF_LOGS_LAMBDA_MEMORY_SIZE,
domain_name=settings.DOMAIN_NAME,
cert_arn=settings.CERTIFICATE_ARN,
web_acl_id=settings.WEB_ACL_ID,
env=env,
)

Expand Down
12 changes: 2 additions & 10 deletions cdk/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,11 @@ class Settings(BaseSettings):
ENV: str = "staging"
PROJECT: str = "openaq"
API_CACHE_TIMEOUT: int = 900
ROLLUP_LAMBDA_TIMEOUT: int = 900
ROLLUP_LAMBDA_MEMORY_SIZE: int = 1536
LOG_LEVEL: str = "INFO"
HOSTED_ZONE_ID: str | None = None
HOSTED_ZONE_NAME: str | None = None
WEB_ACL_ID: str | None = None
DOMAIN_NAME: str | None = None
LOG_BUCKET: str | None = None
CERTIFICATE_ARN: str | None = None
REDIS_PORT: int | None = 6379
REDIS_SECURITY_GROUP_ID: str | None = None
API_LAMBDA_MEMORY_SIZE: int = 1536
API_LAMBDA_TIMEOUT: int = 15 # lambda timeout in seconds
CF_LOGS_LAMBDA_MEMORY_SIZE: int = 1792
CF_LOG_LAMBDA_TIMEOUT: int = 15 * 60 # lambda timeout in seconds

model_config = SettingsConfigDict(
extra="ignore",
Expand Down
Loading
Loading