Skip to content

Commit 02bb1be

Browse files
authored
Merge pull request #67 from KwiatkowskiML/kryczkal/final-deploy
Final deploy
2 parents 27de278 + 16abac8 commit 02bb1be

9 files changed

Lines changed: 73 additions & 51 deletions

File tree

.env.template

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
# Database Configuration
2-
DB_URL=postgres
1+
# Shared Database Configuration
2+
DB_URL=localhost
33
DB_PORT=5432
4-
DB_NAME=authdb
5-
DB_USER=resellio
6-
DB_PASSWORD=localpassword
4+
DB_NAME=resellio_db
5+
DB_USER=root
6+
DB_PASSWORD=my_password
77

8-
# Auth Service JWT Configuration
9-
SECRET_KEY=a-very-secret-key-for-local-development-change-me
8+
# JWT & Security Configuration
9+
SECRET_KEY=a-very-secure-secret-key-for-jwt-256-bit
1010
ACCESS_TOKEN_EXPIRE_MINUTES=30
11-
ADMIN_SECRET_KEY=local-admin-secret-key
12-
INITIAL_ADMIN_EMAIL=admin@resellio.com
13-
INITIAL_ADMIN_PASSWORD=AdminPassword123!
11+
ADMIN_SECRET_KEY=change-in-production
1412

15-
# SendGrid Email Configuration
16-
EMAIL_API_KEY="api-key-placeholder"
17-
EMAIL_FROM_EMAIL="sender-email-placeholder"
13+
# Email (SendGrid) Configuration
14+
EMAIL_API_KEY=YOUR_SENDGRID_API_KEY
15+
# The email address that will appear in the "From" field
16+
EMAIL_FROM_EMAIL=noreply@resellio.com
17+
# The base URL of the application, used for constructing verification links
18+
# For local testing, this points to the API Gateway
19+
APP_BASE_URL=http://localhost:8080

backend/event_ticketing_service/.env.template

Lines changed: 0 additions & 5 deletions
This file was deleted.

backend/event_ticketing_service/app/services/email.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
SENDGRID_API_KEY = os.getenv("EMAIL_API_KEY")
1212
FROM_EMAIL = os.getenv("EMAIL_FROM_EMAIL", "tickets@resellio.com")
13+
APP_BASE_URL = os.getenv("APP_BASE_URL", "http://localhost:8080")
1314

1415
logger = logging.getLogger(__name__)
1516

@@ -52,23 +53,16 @@ def send_ticket_email(
5253
):
5354
"""
5455
Send beautifully designed ticket confirmation email using SendGrid.
55-
56-
Args:
57-
to_email: Recipient's email address
58-
user_name: Recipient's name
59-
event_name: Name of the event
60-
ticket_id: Ticket ID
61-
event_date: Event date (formatted string)
62-
event_time: Event time (formatted string)
63-
venue: Venue name
64-
seat: Seat number/code
65-
66-
Returns:
67-
bool: True if email was sent successfully, False otherwise
6856
"""
6957
if not SENDGRID_API_KEY:
7058
logger.error("SendGrid API key not set - cannot send emails")
7159
return False
60+
if not APP_BASE_URL:
61+
logger.error("APP_BASE_URL not set - cannot construct email links")
62+
# Fallback to a generic domain if not set, but log an error
63+
base_url = "http://resellio.com"
64+
else:
65+
base_url = APP_BASE_URL.replace('/api', '') # Ensure we have the root URL
7266

7367
# Generate QR code containing ticket info
7468
qr_data = f"TICKET:{ticket_id}|EVENT:{event_name}|DATE:{event_date}|TIME:{event_time}|VENUE:{venue}|SEAT:{seat}"
@@ -208,20 +202,18 @@ def send_ticket_email(
208202
209203
<p>Please save this email and bring it with you to the event. You can also access your tickets anytime from your account.</p>
210204
211-
<p>We hope you enjoy the event!</p>
212-
213205
<div style="text-align: center;">
214-
<a href="https://resellio.com/my-tickets" class="button">View My Tickets</a>
206+
<a href="{base_url}/home/customer" class="button">View My Tickets</a>
215207
</div>
216208
</div>
217209
218210
<div class="footer">
219211
<p>© 2025 Resellio. All rights reserved.</p>
220212
<p>This is an automated message. Please do not reply to this email.</p>
221213
<p>
222-
<a href="https://resellio.com/terms">Terms of Service</a> |
223-
<a href="https://resellio.com/privacy">Privacy Policy</a> |
224-
<a href="https://resellio.com/contact">Contact Us</a>
214+
<a href="{base_url}/terms">Terms of Service</a> |
215+
<a href="{base_url}/privacy">Privacy Policy</a> |
216+
<a href="{base_url}/contact">Contact Us</a>
225217
</p>
226218
</div>
227219
</body>

backend/user_auth_service/.env.template

Lines changed: 0 additions & 9 deletions
This file was deleted.

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ services:
4747
- ADMIN_SECRET_KEY=${ADMIN_SECRET_KEY}
4848
- EMAIL_API_KEY=${EMAIL_API_KEY}
4949
- EMAIL_FROM_EMAIL=${EMAIL_FROM_EMAIL}
50+
- APP_BASE_URL=${APP_BASE_URL}
5051
depends_on:
5152
db-init:
5253
condition: service_completed_successfully
@@ -66,6 +67,7 @@ services:
6667
- SECRET_KEY=${SECRET_KEY}
6768
- EMAIL_API_KEY=${EMAIL_API_KEY}
6869
- EMAIL_FROM_EMAIL=${EMAIL_FROM_EMAIL}
70+
- APP_BASE_URL=${APP_BASE_URL}
6971
depends_on:
7072
db-init:
7173
condition: service_completed_successfully

terraform/main/main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ resource "aws_secretsmanager_secret_version" "admin_secret_key" {
3838
secret_string = random_string.admin_secret_key.result
3939
}
4040

41+
resource "aws_secretsmanager_secret" "sendgrid_api_key" {
42+
name = "${var.project_name}-sendgrid-api-key"
43+
}
44+
45+
resource "aws_secretsmanager_secret_version" "sendgrid_api_key" {
46+
secret_id = aws_secretsmanager_secret.sendgrid_api_key.id
47+
secret_string = var.sendgrid_api_key
48+
}
49+
4150

4251
# Database
4352
module "db" {
@@ -76,6 +85,9 @@ module "ecs_cluster" {
7685
db_endpoint = module.db.endpoint
7786
db_password_secret_arn = aws_secretsmanager_secret.db_master_password.arn
7887
admin_secret_key_arn = aws_secretsmanager_secret.admin_secret_key.arn
88+
sendgrid_api_key_arn = aws_secretsmanager_secret.sendgrid_api_key.arn
89+
email_from_address = var.email_from_address
90+
app_base_url = "http://${module.ecs_cluster.alb_dns_name}"
7991
auth_image = "${data.aws_ecr_repository.auth.repository_url}:latest"
8092
ticket_image = "${data.aws_ecr_repository.tickets.repository_url}:latest"
8193
db_init_image = "${data.aws_ecr_repository.db_init.repository_url}:latest"

terraform/main/variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ variable "force_db_reset" {
3737
description = "If true, forces the db-init task to wipe the public schema before initializing. Use with caution."
3838
default = false
3939
}
40+
variable "sendgrid_api_key" {
41+
type = string
42+
description = "The SendGrid API key for sending emails."
43+
sensitive = true
44+
}
45+
variable "email_from_address" {
46+
type = string
47+
description = "The email address to use as the sender."
48+
}

terraform/modules/ecs_cluster/main.tf

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ data "aws_iam_policy_document" "task_secrets_access" {
2727
]
2828
resources = [
2929
var.db_password_secret_arn,
30-
var.admin_secret_key_arn
30+
var.admin_secret_key_arn,
31+
var.sendgrid_api_key_arn
3132
]
3233
}
3334
}
@@ -199,11 +200,14 @@ resource "aws_ecs_task_definition" "auth" {
199200
{ name = "DB_USER", value = var.db_user },
200201
{ name = "DB_NAME", value = var.db_name },
201202
{ name = "DB_PORT", value = tostring(var.db_port) },
202-
{ name = "AWS_REGION", value = var.aws_region }
203+
{ name = "AWS_REGION", value = var.aws_region },
204+
{ name = "EMAIL_FROM_EMAIL", value = var.email_from_address },
205+
{ name = "APP_BASE_URL", value = var.app_base_url }
203206
]
204207
secrets = [
205208
{ name = "DB_PASSWORD", valueFrom = var.db_password_secret_arn },
206-
{ name = "ADMIN_SECRET_KEY", valueFrom = var.admin_secret_key_arn }
209+
{ name = "ADMIN_SECRET_KEY", valueFrom = var.admin_secret_key_arn },
210+
{ name = "EMAIL_API_KEY", valueFrom = var.sendgrid_api_key_arn }
207211
]
208212
logConfiguration = {
209213
logDriver = "awslogs"
@@ -241,10 +245,13 @@ resource "aws_ecs_task_definition" "tickets" {
241245
{ name = "DB_USER", value = var.db_user },
242246
{ name = "DB_NAME", value = var.db_name },
243247
{ name = "DB_PORT", value = tostring(var.db_port) },
244-
{ name = "AWS_REGION", value = var.aws_region }
248+
{ name = "AWS_REGION", value = var.aws_region },
249+
{ name = "EMAIL_FROM_EMAIL", value = var.email_from_address },
250+
{ name = "APP_BASE_URL", value = var.app_base_url }
245251
]
246252
secrets = [
247-
{ name = "DB_PASSWORD", valueFrom = var.db_password_secret_arn }
253+
{ name = "DB_PASSWORD", valueFrom = var.db_password_secret_arn },
254+
{ name = "EMAIL_API_KEY", valueFrom = var.sendgrid_api_key_arn }
248255
]
249256
logConfiguration = {
250257
logDriver = "awslogs"

terraform/modules/ecs_cluster/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ variable "admin_secret_key_arn" {
2020
type = string
2121
description = "ARN for the admin secret key"
2222
}
23+
variable "sendgrid_api_key_arn" {
24+
type = string
25+
description = "ARN for the SendGrid API key secret"
26+
}
27+
variable "email_from_address" {
28+
type = string
29+
description = "The email address to use as the sender"
30+
}
31+
variable "app_base_url" {
32+
type = string
33+
description = "The base URL of the application, for constructing links in emails"
34+
}
2335
variable "db_user" { type = string }
2436
variable "db_name" { type = string }
2537
variable "db_port" {

0 commit comments

Comments
 (0)