Skip to content

Commit c65d640

Browse files
wilbrdtkernicPanel
authored andcommitted
🔥(project) remove Cloudfront from the project
As Cloudfront is not used anymore on project Marsha, removing it totally.
1 parent 2a2a3f3 commit c65d640

File tree

15 files changed

+26
-418
lines changed

15 files changed

+26
-418
lines changed

.circleci/config.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ jobs:
268268
POSTGRES_PORT: 5432
269269
DJANGO_AWS_ACCESS_KEY_ID: aws-access-key-id
270270
DJANGO_AWS_SECRET_ACCESS_KEY: aws-secret-access-key
271-
DJANGO_CLOUDFRONT_DOMAIN: abc.cloudfront.net
272271
DJANGO_SCW_EDGE_SERVICE_DOMAIN: abc.svc.edge.scw.cloud
273272
DJANGO_UPDATE_STATE_SHARED_SECRETS: dummy,secret
274273
DJANGO_AWS_MEDIALIVE_ROLE_ARN: aws:medialive:arn:role
@@ -351,7 +350,6 @@ jobs:
351350
POSTGRES_PORT: 5432
352351
DJANGO_AWS_ACCESS_KEY_ID: aws-access-key-id
353352
DJANGO_AWS_SECRET_ACCESS_KEY: aws-secret-access-key
354-
DJANGO_CLOUDFRONT_DOMAIN: abc.cloudfront.net
355353
DJANGO_SCW_EDGE_SERVICE_DOMAIN: abc.svc.edge.scw.cloud
356354
DJANGO_UPDATE_STATE_SHARED_SECRETS: dummy,secret
357355
DJANGO_AWS_MEDIALIVE_ROLE_ARN: aws:medialive:arn:role
@@ -592,7 +590,6 @@ jobs:
592590
POSTGRES_PORT: 5432
593591
DJANGO_AWS_ACCESS_KEY_ID: aws-access-key-id
594592
DJANGO_AWS_SECRET_ACCESS_KEY: aws-secret-access-key
595-
DJANGO_CLOUDFRONT_DOMAIN: abc.cloudfront.net
596593
DJANGO_SCW_EDGE_SERVICE_DOMAIN: abc.svc.edge.scw.cloud
597594
DJANGO_UPDATE_STATE_SHARED_SECRETS: dummy,secret
598595
DJANGO_AWS_MEDIALIVE_ROLE_ARN: aws:medialive:arn:role

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11+
### Removed
12+
13+
- Remove all legacy Cloudfront code and mentions
14+
1115
## [5.11.1] - 2025-07-17
1216

1317
### Fixed

README.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,16 @@ Moreover, Marsha provides:
3838

3939
### The `Django` backend
4040

41-
The `Django` backend is tasked with serving the LTI pages that are integrated into the LMS. It also manages all the objects with their relationships, user accounts and all authentication concerns. It exposes a JSON API to communicate with the part of the infrastructure that operates on `AWS lambdas` and the `React` frontend.
41+
The `Django` backend is tasked with serving the LTI pages that are integrated into the LMS. It also manages all the objects with their relationships, user accounts and all authentication concerns. It exposes a JSON API to communicate with the `React` frontend.
4242

4343
It is defined using a [docker-compose file](../docker-compose.yml) for development, and can be deployed on any container environment (such as `Kubernetes`) for production.
4444

4545
### The storage & transcoding environment
4646

47-
Source files (video, documents, subtitles,...) are directly uploaded to an `S3` bucket by instructors. Depending the uploaded resource a lambda will be triggered to do different jobs:
48-
- Launch `MediaConvert` to generate all necessary video files (various formats and fragments & manifests for adaptive-bitrate streaming) into a destination `S3` bucket. Those files are then served through the `CloudFront` CDN.
47+
Source files (video, documents, subtitles,...) are directly uploaded to an `S3` bucket by instructors. Depending the uploaded resource, Celery tasks will be triggered to do different jobs:
48+
- Transcode videos using Peertube runners to generate all necessary video files (various formats and fragments & manifests for adaptive-bitrate streaming) into a destination `S3` bucket. Those files are then served through the `Scaleway Edge service` CDN.
4949
- Convert any kind of subtitles (also captions and transcripts) in [WebVTT](https://www.w3.org/TR/webvtt1/) format and encode them properly.
5050
- Resize thumbnails in many formats.
51-
- Copy documents from a source to a destination `S3` Bucket accessible through the `CloudFront` CDN.
52-
53-
Lambdas are used to manage and monitor the process and report back to the `Django` backend.
54-
55-
This storage & transcoding environment requires `AWS` as it heavily relies on `AWS MediaConvert` to do the heavy lifting when it comes to transcoding. All the services it relies on are configured through `Terraform` and can be deployed effortlessly through a `make` command.
56-
57-
⚠️ **Privacy concerns**
58-
59-
Please note that the only objects we handle in `AWS` are the actual video, documents or subtitles files, from the upload to the distribution through transcoding and storage. It is not required to deploy any database or application backend to `AWS` or send any user's personal information there.
6051

6152
### The `React` frontend
6253

UPGRADE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ not skip minor/major releases while upgrading (fix releases can be skipped).
77
The format is inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
99

10+
### 5.10.0 to 5.11.0
11+
12+
Cloudfront signed URLs are not used anymore in the project, make sure to remove the following environment variables:
13+
- CLOUDFRONT_PRIVATE_KEY_PATH
14+
- CLOUDFRONT_SIGNED_URLS_ACTIVE
15+
- CLOUDFRONT_SIGNED_URLS_VALIDITY
16+
- CLOUDFRONT_SIGNED_URL_CACHE_DURATION
17+
- CLOUDFRONT_SIGNED_PUBLIC_KEY_ID
18+
- CLOUDFRONT_DOMAIN = values.Value(None)
19+
1020
### 5.7.x to 5.8.0
1121

1222
Environment variables previously prefixed with `DJANGO_VIDEOS_STORAGE_` are now prefixed with `DJANGO_STORAGE_`. Make sure to update your configuration accordingly.

docs/env.md

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -247,50 +247,6 @@ versions of the app can run in parallel without interfering with each other.
247247
- Required: No
248248
- Default: `staticfiles.json`
249249

250-
#### DJANGO_CLOUDFRONT_SIGNED_PUBLIC_KEY_ID
251-
252-
The public key id saved in AWS cloudfront public keys management. This public key is created by terraform and you can pick
253-
the id using `terraform output cloudfront_publick_key_id`
254-
255-
- Type: string
256-
- Required:
257-
- Yes when `DJANGO_CLOUDFRONT_SIGNED_URLS_ACTIVE` is `True`;
258-
- No otherwise.
259-
- Default: None;
260-
261-
#### DJANGO_CLOUDFRONT_PRIVATE_KEY_PATH
262-
263-
Path to a private key corresponding to the public key ID in `DJANGO_CLOUDFRONT_SIGNED_PUBLIC_KEY_ID`. Also used to sign Cloudfront URLs.
264-
The private key can be retrieve from the terraform output `terraform output cloudfront_ssh_private_key`
265-
266-
- Type: string
267-
- Required:
268-
- Yes when `DJANGO_CLOUDFRONT_SIGNED_URLS_ACTIVE` is `True` and the key is not located in the default path;
269-
- No otherwise.
270-
- Default: `src/backend/.ssh/cloudfront_private_key`
271-
272-
#### DJANGO_CLOUDFRONT_SIGNED_URLS_ACTIVE
273-
274-
Whether Cloudfront URLs for MP4 files and timed text tracks should be cryptographically signed.
275-
276-
Note: Preview images are never signed as a matter of policy; adaptive streaming formats pose technical challenges when it comes to signed URLs, so we're not doing any signing there for now.
277-
278-
- Type: Boolean
279-
- Required: No
280-
- Default: Varies depending on the environment:
281-
- `False` in development and test;
282-
- `True` in all other environments.
283-
- Choices: `True` or `False`
284-
285-
#### DJANGO_CLOUDFRONT_DOMAIN
286-
287-
The domain for the AWS Cloudfront distribution for the relevant AWS deployment. This is the domain
288-
that will be used to distribute processed files to end users.
289-
290-
- Type: string
291-
- Required: Yes
292-
- Default: None
293-
294250
#### DJANGO_SCW_EDGE_SERVICE_DOMAIN
295251

296252
The domain for the Scaleway Edge Service.

src/backend/marsha/bbb/tests/bbb_utils/test_create.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,7 @@ def test_bbb_create_existing_classroom(self):
609609
self.assertEqual(classroom.started, False)
610610

611611
@responses.activate
612-
@override_settings(
613-
MEDIA_URL="https://abc.cloudfront.net/",
614-
)
612+
@override_settings(MEDIA_URL="https://abc.svc.edge.scw.cloud/")
615613
def test_bbb_create_new_classroom_with_document(self):
616614
"""Create a classroom with one document."""
617615
now = datetime(2018, 8, 8, tzinfo=timezone.utc)
@@ -706,7 +704,7 @@ def test_bbb_create_new_classroom_with_document(self):
706704
responses.calls[0].request.body,
707705
b'<modules><module name="presentation">'
708706
b"<document "
709-
b'url="https://abc.cloudfront.net/classroom/9b3df0bd-240c-49fe-85e0-caa47420f3eb/'
707+
b'url="https://abc.svc.edge.scw.cloud/classroom/9b3df0bd-240c-49fe-85e0-caa47420f3eb/'
710708
b'classroomdocument/c5c84f7b-7f1a-4689-8da8-28fae7c7e8d9/file.pdf" '
711709
b'filename="file.pdf" '
712710
b'current="true" '
@@ -737,9 +735,7 @@ def test_bbb_create_new_classroom_with_document(self):
737735
self.assertEqual(classroom.started, True)
738736
self.assertEqual(classroom.ended, False)
739737

740-
@override_settings(
741-
MEDIA_URL="https://abc.cloudfront.net/",
742-
)
738+
@override_settings(MEDIA_URL="https://abc.svc.edge.scw.cloud/")
743739
@responses.activate
744740
def test_bbb_create_new_classroom_with_documents(self):
745741
"""Create a classroom with multiple documents."""
@@ -843,13 +839,13 @@ def test_bbb_create_new_classroom_with_documents(self):
843839
responses.calls[0].request.body,
844840
b'<modules><module name="presentation">'
845841
b"<document "
846-
b'url="https://abc.cloudfront.net/classroom/9b3df0bd-240c-49fe-85e0-caa47420f3eb/'
842+
b'url="https://abc.svc.edge.scw.cloud/classroom/9b3df0bd-240c-49fe-85e0-caa47420f3eb/'
847843
b'classroomdocument/a753faf5-5d6a-4091-856b-71d2c600e1cd/file2.pdf" '
848844
b'filename="file2.pdf" '
849845
b'current="false" '
850846
b"/>"
851847
b"<document "
852-
b'url="https://abc.cloudfront.net/classroom/9b3df0bd-240c-49fe-85e0-caa47420f3eb/'
848+
b'url="https://abc.svc.edge.scw.cloud/classroom/9b3df0bd-240c-49fe-85e0-caa47420f3eb/'
853849
b'classroomdocument/c5c84f7b-7f1a-4689-8da8-28fae7c7e8d9/file.pdf" '
854850
b'filename="file.pdf" '
855851
b'current="true" '

src/backend/marsha/core/serializers/base.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
"""This module holds serializers and constants used across the Marsha project."""
22

3-
from datetime import timedelta
43
import re
54

6-
from django.conf import settings
7-
from django.core.cache import cache
85
from django.core.exceptions import ValidationError
9-
from django.utils import timezone
106
from django.utils.text import slugify
117

128
from rest_framework import serializers
@@ -23,7 +19,7 @@
2319
STATE_CHOICES,
2420
)
2521
from marsha.core.models import TimedTextTrack
26-
from marsha.core.utils import cloudfront_utils, time_utils
22+
from marsha.core.utils import time_utils
2723
from marsha.core.utils.api_utils import get_uploadable_models_s3_mapping
2824

2925

@@ -48,41 +44,6 @@
4844
KEY_REGEX = re.compile(KEY_PATTERN)
4945

5046

51-
def get_resource_cloudfront_url_params(resource_kind, resource_id):
52-
"""
53-
Generate the policy and sign it to allow accessing to all sub resources
54-
for a given resource id.
55-
Parameters
56-
----------
57-
resource_kind: str
58-
Only used to define the cache key.
59-
resource_id: str
60-
The "parent" resource ID
61-
"""
62-
resource = (
63-
f"{settings.AWS_S3_URL_PROTOCOL}://{settings.CLOUDFRONT_DOMAIN}/{resource_id}/*"
64-
)
65-
cache_key = f"cloudfront_signed_url:{resource_kind}:{resource_id}:{resource}"
66-
date_less_than = timezone.now() + timedelta(
67-
seconds=settings.CLOUDFRONT_SIGNED_URLS_VALIDITY
68-
)
69-
if (params := cache.get(cache_key)) is None:
70-
params = cloudfront_utils.generate_cloudfront_urls_signed_parameters(
71-
resource,
72-
date_less_than=date_less_than,
73-
)
74-
cache.set(cache_key, params, settings.CLOUDFRONT_SIGNED_URL_CACHE_DURATION)
75-
76-
return params
77-
78-
79-
def get_video_cloudfront_url_params(video_id):
80-
"""
81-
Generate the policy and sign it to allow accessing to all resources for a given video id.
82-
"""
83-
return get_resource_cloudfront_url_params("video", video_id)
84-
85-
8647
class ReadOnlyModelSerializer(serializers.ModelSerializer):
8748
"""A base serializer whose fields are all readonly."""
8849

src/backend/marsha/core/serializers/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def get_url(self, obj):
100100
Returns
101101
-------
102102
String or None
103-
the url to fetch the document on CloudFront
103+
the url to fetch the document on storage
104104
None if the document is still not uploaded to S3 with success
105105
106106
"""

src/backend/marsha/core/storage/s3.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
MARKDOWN_DOCUMENT_STORAGE_BASE_DIRECTORY,
1212
TMP_STORAGE_BASE_DIRECTORY,
1313
)
14-
from marsha.core.utils.cloudfront_utils import get_cloudfront_private_key
1514
from marsha.core.utils.s3_utils import create_presigned_post
1615
from marsha.core.utils.time_utils import to_timestamp
1716

@@ -37,11 +36,6 @@ class S3FileStorage(S3Storage):
3736
custom_domain = settings.SCW_EDGE_SERVICE_DOMAIN
3837
url_protocol = "https:"
3938

40-
if settings.CLOUDFRONT_SIGNED_URLS_ACTIVE:
41-
cloudfront_key_id = settings.CLOUDFRONT_SIGNED_PUBLIC_KEY_ID
42-
cloudfront_key = get_cloudfront_private_key()
43-
querystring_expire = settings.CLOUDFRONT_SIGNED_URLS_VALIDITY
44-
4539
def url(self, name, parameters=None, expire=None, http_method=None):
4640
"""
4741
Override the url method to remove signature part of the url if the resource

0 commit comments

Comments
 (0)