Skip to content

Commit 373c276

Browse files
committed
changes
1 parent 4b1dbfb commit 373c276

File tree

7 files changed

+125
-8
lines changed

7 files changed

+125
-8
lines changed

.github/workflows/deploy.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,15 @@ jobs:
299299
id: buildx
300300
if: ${{ steps.image.outputs.image_exists == 0 }}
301301
uses: docker/setup-buildx-action@v3
302+
- name: Get vars
303+
id: vars
304+
if: ${{ steps.image.outputs.image_exists == 0 }}
305+
run: |
306+
cms_hostname="${aws ssm get-parameter --output text --query Parameter.Value --with-decryption --name /pythonit/${{ env.TF_WORKSPACE }}/pycon-frontend/cms-hostname}"
307+
echo "CMS_HOSTNAME=$cms_hostname" >> "$GITHUB_OUTPUT"
308+
309+
conference_code="${aws ssm get-parameter --output text --query Parameter.Value --with-decryption --name /pythonit/${{ env.TF_WORKSPACE }}/pycon-frontend/conference-code}"
310+
echo "CONFERENCE_CODE=$conference_code" >> "$GITHUB_OUTPUT"
302311
- name: Build and push
303312
if: ${{ steps.image.outputs.image_exists == 0 }}
304313
uses: docker/build-push-action@v6
@@ -314,8 +323,8 @@ jobs:
314323
platforms: linux/arm64
315324
build-args: |
316325
API_URL_SERVER=https://${{ fromJSON('["pastaporto-", ""]')[github.ref == 'refs/heads/main'] }}admin.pycon.it
317-
CMS_HOSTNAME=${{ vars.CMS_HOSTNAME }}
318-
CONFERENCE_CODE=${{ vars.CONFERENCE_CODE }}
326+
CMS_HOSTNAME=${{ steps.vars.outputs.cms_hostname }}
327+
CONFERENCE_CODE=${{ steps.vars.outputs.conference_code }}
319328
320329
deploy-fe:
321330
runs-on: ubuntu-latest

infrastructure/applications/applications.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ module "pycon_backend" {
3434
}
3535
}
3636

37+
module "pycon_frontend" {
38+
source = "./pycon_frontend"
39+
cluster_id = module.cluster.cluster_id
40+
logs_group_name = module.cluster.logs_group_name
41+
42+
providers = {
43+
aws = aws
44+
aws.us = aws.us
45+
}
46+
}
47+
3748
module "clamav" {
3849
source = "./clamav"
3950
cluster_id = module.cluster.cluster_id

infrastructure/applications/cluster/cloudfront.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
locals {
2-
pycon_web_domain = local.is_prod ? "admin.pycon.it" : "${terraform.workspace}-admin.pycon.it"
2+
pycon_admin_domain = local.is_prod ? "admin.pycon.it" : "${terraform.workspace}-admin.pycon.it"
3+
pycon_frontend_domain = local.is_prod ? "frontend.pycon.it" : "${terraform.workspace}-frontend.pycon.it"
34
pretix_web_domain = local.is_prod ? "tickets.pycon.it" : "${terraform.workspace}-tickets.pycon.it"
45
}
56

@@ -23,8 +24,9 @@ resource "aws_cloudfront_distribution" "application" {
2324
comment = "${terraform.workspace} server"
2425
wait_for_deployment = false
2526
aliases = [
26-
local.pycon_web_domain,
27-
local.pretix_web_domain
27+
local.pycon_admin_domain,
28+
local.pretix_web_domain,
29+
local.pycon_frontend_domain
2830
]
2931

3032
origin {

infrastructure/applications/cluster/domains.tf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ data "aws_route53_zone" "zone" {
44

55
resource "aws_route53_record" "web_pycon" {
66
zone_id = data.aws_route53_zone.zone.zone_id
7-
name = local.pycon_web_domain
7+
name = local.pycon_admin_domain
8+
type = "A"
9+
10+
alias {
11+
name = aws_cloudfront_distribution.application.domain_name
12+
zone_id = aws_cloudfront_distribution.application.hosted_zone_id
13+
evaluate_target_health = false
14+
}
15+
}
16+
17+
resource "aws_route53_record" "web_frontend" {
18+
zone_id = data.aws_route53_zone.zone.zone_id
19+
name = local.pycon_frontend_domain
820
type = "A"
921

1022
alias {

infrastructure/applications/pycon_frontend/repo.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
resource "aws_ecr_repository" "repo" {
1+
data "aws_ecr_repository" "repo" {
22
name = "pythonit/pycon-frontend"
33
}
44

55
data "aws_ecr_image" "image" {
6-
repository_name = data.aws_ecr_repository.be_repo.name
6+
repository_name = data.aws_ecr_repository.repo.name
77
image_tag = data.external.githash.result.githash
88
}
99

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module "secrets" {
2+
source = "../../components/secrets"
3+
service = "pycon-frontend"
4+
}
5+
6+
module "common_secrets" {
7+
source = "../../components/secrets"
8+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
locals {
2+
is_prod = terraform.workspace == "production"
3+
alias = local.is_prod ? "frontend.pycon.it" : "${terraform.workspace}-frontend.pycon.it"
4+
}
5+
6+
resource "aws_ecs_task_definition" "pycon_frontend" {
7+
family = "pythonit-${terraform.workspace}-pycon-frontend"
8+
9+
container_definitions = jsonencode([
10+
{
11+
name = "frontend"
12+
image = "${data.aws_ecr_repository.repo.repository_url}@${data.aws_ecr_image.image.image_digest}"
13+
memoryReservation = 400
14+
essential = true
15+
16+
dockerLabels = {
17+
"traefik.enable" = "true"
18+
"traefik.http.routers.frontend.rule" = "Host(`${local.alias}`)"
19+
}
20+
21+
environment = [
22+
{
23+
name = "CMS_HOSTNAME"
24+
value = module.secrets.value.cms_hostname
25+
},
26+
{
27+
name = "CONFERENCE_CODE"
28+
value = module.secrets.value.conference_code
29+
},
30+
]
31+
32+
portMappings = [
33+
{
34+
containerPort = 3000
35+
hostPort = 0
36+
},
37+
]
38+
39+
mountPoints = []
40+
41+
logConfiguration = {
42+
logDriver = "awslogs"
43+
options = {
44+
"awslogs-group" = var.logs_group_name
45+
"awslogs-region" = "eu-central-1"
46+
"awslogs-stream-prefix" = "frontend"
47+
}
48+
}
49+
50+
healthCheck = {
51+
retries = 3
52+
command = [
53+
"CMD-SHELL",
54+
"echo 1"
55+
]
56+
timeout = 3
57+
interval = 10
58+
}
59+
60+
stopTimeout = 300
61+
}
62+
])
63+
64+
requires_compatibilities = []
65+
tags = {}
66+
}
67+
68+
resource "aws_ecs_service" "frontend" {
69+
name = "frontend"
70+
cluster = var.cluster_id
71+
task_definition = aws_ecs_task_definition.pycon_frontend.arn
72+
desired_count = 1
73+
deployment_minimum_healthy_percent = 100
74+
deployment_maximum_percent = 200
75+
}

0 commit comments

Comments
 (0)