CloudFront

We are going to use CloudFormation to route the traffic to the relevant resources.

  • / will go to S3 to serve the React app static files, and

  • /api will go to the GraphQL API.

Creating a distribution

Go to CloudFront > Create Distribution:

Select Web as a delivery method and use the following configuration:

  • Origin Domain Name: The S3 bucket with resources

  • Viewer Protocol Policy: Redirect HTTP to HTTPS

  • Alternate Domain Names: The domain you bought (e.g daedalost.com)

  • SSL Certificate: Custom SSL Certificate and click "Request or Import a Certificate with ACM" then follow the wizard.

Once you distribution is created, click its ID to edit it.

  • Origins and Origin Groups > Create Origin, paste the API Gateway URL.

  • Paste the API Gateway URL

You can find the API Gateway URL in Stages
  • Once created, go to Behaviors > Create Behavior

  • Path Pattern: /api

  • Select the newly created origin

  • Allowed HTTP Methods: GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE

  • Object Caching: Customize0 everywhere.

Last updated

Was this helpful?