Assets CDN Design

Assets CDN Design

How it works

There is an AWS S3 bucket that stores the files. This is connected to a AWS CloudFront distribution that performs the CDN. When a file is changed the distribution should be invalidated to flush the cache.


GitLab CI automation is used to deploy to S3 from the master branch. The project’s CI settings should be configured with the following environment variables:

  • DIST_ID - the CloudFront distribution ID
  • S3_BUCKET - the S3 bucket where data is stored
  • AWS_ACCESS_KEY_ID - AWS access key with permission to upload to S3 and invalidate CloudFront.
  • AWS_SECRET_ACCESS_KEY - AWS secret key.

The IAM user should have the following permissions, no more.

    "Version": "2012-10-17",
    "Statement": [
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
            "Resource": "*"
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": "s3:*",
            "Resource": [