Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

Learn how to set up the Amazon CloudFront to work with Taskmonk, and how to configure Taskmonk to use the service.

Table of Contents

Overview

While working with cloud-based applications, the loading time for the application content depends on the geographical separation between the cloud storage and the location at which the images are being accessed. Storing the content close to the access point can significantly decrease the load times.

...

Amazon Web Services (AWS) provides a CDN layer called the Amazon CloudFront which provides cached access to S3 buckets. Learn how to set up the Amazon CloudFront to work with Taskmonk and how to configure Taskmonk to use the service.

Setting up the Amazon CloudFront

Info

The Amazon CloudFront uses a public-private key pair to provide safe access to URLs. The public key is uploaded to the AWS server and the private key is used by the client to generate the signed URL.

  1. Create a public-private key pair. The steps for the same are listed here and are beyond the scope of this document.

  2. Navigate to CloudFront > Public keys. Click Create public key. The Create Public Key modal appears.

  3. Enter a name to identify your public key and paste the public key created in step 1 in the fields provided. Click Create Public Key.

  4. Navigate to CloudFront > Key groups. Click Create key group. The Create Key Group modal appears.

  5. Enter a name to identify the key group and the appropriate public key in the fields provided.

  6. Go to the AWS console and click Services > CloudFront. The Distributions page appears.

  7. Click Create distribution. The Create Distribution modal appears.

  8. Click Origin and select the S3 bucket for which CDN needs to be set up.

  9. Leave Origin Path blank. This is used to serve files from a particular directory.

  10. Enter a name to identify the CDN in the field provided.

  11. Select S3 bucket access > yes use OAI (bucket can restrict access to only CloudFront). Click Create New OAI.
    Select Bucket Policy > Yes, update the bucket policy.

  12. Set the cache behavior as below:

    • Path pattern: Default (* ).

    • Compress objects automatically: Yes.

    • Viewer > Viewer protocol policy: HTTP and HTTPS.

    • Viewer > Allowed HTTP methods: GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE.

  13. Disallow public access to the cloud front for security:

    1. Set Restrict viewer access to Yes.

    2. Set Trusted authorization type to Trusted key groups (recommended).

  14. Set up header forwarding to prevent cors errors:

    1. Select Cache key and origin requests > Legacy cache settings.

    2. Set Headers as Include the following headers.

    3. Select the following headers from the dropdown provided:

      • Acess-Control-Request-Method.

      • Access-Control-Request-Headers.

      • Origin.

  15. Leave the rest of the settings as is and create the distribution.

Setting up Taskmonk for the Amazon CloudFront

You must configure the taskmonk project set up with S3 to use the Amazon CloudFront. To do this, you must create an automated processor to change the URL of the input file. This processor would be run on task allocation. To set up Taskmonk to work with the Amazon CloudFront:

...