Skip to content

Commit

Permalink
chore(api): move session domain to env var
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-h1 committed Aug 28, 2024
1 parent edaf731 commit 0f97cfa
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ env:
TF_VAR_s3_assets_access_key_id: ${{ secrets.ASSETS_KEY }}
TF_VAR_s3_assets_secret_access_key: ${{ secrets.ASSETS_SECRET }}
TF_VAR_git_sha: ${{ github.sha }}
TF_VAR_session_domain: pets-staging.lhowsam.com
# needed for tests
S3_ASSETS_BUCKET: pets-api-staging-assets
S3_ASSETS_REGION: eu-west-2
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/e2e-render.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: e2e-render
on:
workflow_dispatch:
schedule:
- cron: '0 */7 * * *'
env:
DATABASE_URL: postgres://pets:pets@localhost:5432/pets
REDIS_URL: redis://localhost:6379
API_BASE_URL: http://localhost:8000
S3_ASSETS_BUCKET: pets-api-staging-assets
S3_ASSETS_REGION: eu-west-2
S3_ASSETS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
S3_ASSETS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

jobs:
e2e-render:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
name: e2e-render
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Install dependencies
uses: ./.github/actions/install

- name: generate prisma client
run: pnpm db:generate

- name: e2e render
uses: ./.github/actions/e2e
with:
target: e2e-staging-render
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ e2e-local:
.PHONY: e2e-staging
e2e-staging:
API_BASE_URL=https://pets-staging.lhowsam.com ./node_modules/.bin/playwright test --config=playwright-stg.config.ts ${tests}


.PHONY: e2e-staging-render
e2e-staging-render:
API_BASE_URL=https://pets-api-staging.onrender.com ./node_modules/.bin/playwright test --config=playwright-render.config.ts ${tests}
12 changes: 12 additions & 0 deletions playwright-render.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import baseConfig from './playwright-base.config';

const stagingConfig: PlaywrightTestConfig = {
...baseConfig,
use: {
baseURL: 'https://pets-api-staging.onrender.com',
},
retries: process.env.CI ? 2 : 0,
};

export default stagingConfig;
2 changes: 1 addition & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class CreateServer {
secure: this.isProduction(),
httpOnly: true, // prevent client side js from reading the cookie
maxAge: 7 * 24 * 60 * 60 * 1000, // 7 days
domain: this.isProduction() ? 'pets-staging.lhowsam.com' : undefined,
domain: this.isProduction() ? process.env.SESSION_DOMAIN : undefined,
path: '/',
signed: this.isProduction(),
sameSite: 'lax',
Expand Down
4 changes: 4 additions & 0 deletions terraform/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ resource "aws_ecs_task_definition" "app_task" {
{
"name": "GIT_SHA",
"value": "${var.git_sha}"
},
{
"name": "SESSION_DOMAIN",
"value": "${var.session_domain}"
}
],
"portMappings": [
Expand Down
4 changes: 0 additions & 4 deletions terraform/lb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ resource "aws_default_subnet" "app_subnet_c" {
resource "aws_alb" "app_load_balancer" {
name = "${var.project_name}-${var.env}-lb"
load_balancer_type = "application"
connection {
timeout = "30"
}
subnets = [
aws_default_subnet.application_subnet_a.id,
aws_default_subnet.application_subnet_b.id,
Expand Down Expand Up @@ -103,7 +100,6 @@ resource "aws_lb_listener" "web_http" {
}
}


resource "aws_default_subnet" "application_subnet_a" {
availability_zone = "eu-west-2a"
}
Expand Down
2 changes: 1 addition & 1 deletion terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ variable "database_url" {
variable "session_domain" {
type = string
description = "The domain to use for the session cookie. This should not start with https://"
default = "pets-api.lhowsam.com"
default = "pets-staging.lhowsam.com"
}

variable "s3_assets_bucket" {
Expand Down

0 comments on commit 0f97cfa

Please sign in to comment.