> For the complete documentation index, see [llms.txt](https://tutorial.specian.co.uk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tutorial.specian.co.uk/devops/aws/cloudformation.md).

# CloudFront

We are going to use [CloudFormation](https://aws.amazon.com/cloudfront/) 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.

![](/files/-LrFYHYRkX9DW4BnqB6w)

### Creating a distribution

Go to `CloudFront` > `Create Distribution`:

![](/files/-LrFZBi-GMxJGx5vclH2)

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](/files/-LrFawgBjvpY_HFcAKhX)

* 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: Customize`0` everywhere.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://tutorial.specian.co.uk/devops/aws/cloudformation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
