# CloudFront

Requirements:

* AWS Account with basic write and read access to S3 and CloudFront. In CloudFront, make sure you are able to access invalidations tab.
* Public S3 bucket where you can freely delete, upload and read files from the console, where also each file can be publicly downloaded
* One CloudFront distribution connected to the S3 bucket. Note the distribution domain name (e.g. <https://d3nycf6vcruyvx.cloudfront.net/>)

1\) In Unity3D project go to Asset Management -> Addressables -> Profiles, create a new profile and name it as you wish (e.g. CloudFront). Then in use recommended values below:

<table><thead><tr><th width="194">Key</th><th>Value</th></tr></thead><tbody><tr><td>RemoteBuildPath</td><td>ServerData/CloudFront/addressables/[UnityEngine.Application.unityVersion]/[UnityEngine.Application.productName]/[BuildTarget]</td></tr><tr><td>RemoteLoadPath</td><td><a href="https://your_domain_name_of_cloudfront_distribution/addressables/[UnityEngine.Application.unityVersion]/[UnityEngine.Application.productName]/[BuildTarget]">https://your_domain_name_of_cloudfront_distribution/addressables/[UnityEngine.Application.unityVersion]/[UnityEngine.Application.productName]/[BuildTarget]</a></td></tr></tbody></table>

<figure><img src="https://4213294372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo4sRWPX77c58Cw1FjKCI%2Fuploads%2FDbDZvHG6iNaAOx0FAgyY%2F1%20(1).gif?alt=media&#x26;token=52ddcf5e-74cc-4a03-a56e-cd4a7b17b246" alt=""><figcaption><p>Profile &#x26; Name</p></figcaption></figure>

<figure><img src="https://4213294372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo4sRWPX77c58Cw1FjKCI%2Fuploads%2Fb8K7Iax1VLF70R7rq8YA%2F1%20(2).gif?alt=media&#x26;token=48808349-4356-42e2-a170-f6126542c75b" alt=""><figcaption><p>Values &#x26; domain name</p></figcaption></figure>

2\) If you use this values, then you are required to set properly a Product Name in Player Settings

<figure><img src="https://4213294372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo4sRWPX77c58Cw1FjKCI%2Fuploads%2FbCMkI2kUeY7QOwq6VyE7%2F2.gif?alt=media&#x26;token=7ec21621-fb79-4725-a46c-db66e0043654" alt=""><figcaption><p>Product Name in Player Settings</p></figcaption></figure>

3\) Then, assuming you added the addressable correctly already, it is okay to make first new build of addressables, which will be compiled to this directory: *PROJECT-ROOT-DIRECTORY/ServerData/CloudFront/addressables/\[UnityEngine.Application.unityVersion]/\[UnityEngine.Application.productName]/\[BuildTarget]*

<figure><img src="https://4213294372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo4sRWPX77c58Cw1FjKCI%2Fuploads%2F9sXbPV8SSj4koCQpUU6P%2F3.gif?alt=media&#x26;token=266e6bdf-35b3-499e-8c03-936cf586cfa9" alt=""><figcaption><p>1st new build</p></figcaption></figure>

4\) After that if you have updates, make sure you "Update Addressables" instead. Unless, you are using different Addressable Profile or the current one was changed somehow. In such cases Unity3D will throw an error that the paths are not matching.

<figure><img src="https://4213294372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo4sRWPX77c58Cw1FjKCI%2Fuploads%2FBvV0WYmHAuelA651hEGF%2F4.gif?alt=media&#x26;token=012273c3-ff9b-4732-810c-5088709ba27a" alt=""><figcaption><p>Update Addressables</p></figcaption></figure>

5\) Once the files are compiled, go to AWS Console -> S3 -> Your public bucket -> Addressables (Create a directory if it doesn't exist) -> and drag and drop content *PROJECT-ROOT-DIRECTORY/ServerData/CloudFront/addressables/* directory to there, which should be only one folder named 2021.3.1f1.

<figure><img src="https://4213294372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo4sRWPX77c58Cw1FjKCI%2Fuploads%2FAuBnCZJwJeZD4fnUlQGD%2F5_AdobeExpress.gif?alt=media&#x26;token=8fb3c33e-e0fa-4d6c-986e-5e1dd2510f76" alt=""><figcaption><p>Update AWS</p></figcaption></figure>

6\) Then in case if you are updating addressables, go to *AWS Console -> S3 -> Your public bucket -> Addressables -> 2021.3.1f1 ->Your product name that you specified in Unity3D Player Settings -> WebGL* and this is where you need uploaded updated files from you local folder where addressables have been compiled, i.e. from *PROJECT-ROOT-DIRECTORY/ServerData/CloudFront/addressables/2021.3.1f1/Your product name that you specified in Unity3D Player Settings/WebGL.*&#x20;

<figure><img src="https://4213294372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo4sRWPX77c58Cw1FjKCI%2Fuploads%2FM7age4FbvbBnQmuC3qeq%2F6_AdobeExpress.gif?alt=media&#x26;token=8e9bbd7b-18d8-43ec-956f-1c9a54c5b504" alt=""><figcaption><p>Update files in AWS</p></figcaption></figure>

7\) Also whenever updated, you will need to invalidate the files or folder which you updated. For this, please, see how to Invalidate files in AWS CloudFront.

<figure><img src="https://4213294372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo4sRWPX77c58Cw1FjKCI%2Fuploads%2FOrWBwIckX6ryhdNzBorY%2F7_AdobeExpress.gif?alt=media&#x26;token=a272f4a1-5ed2-4de9-b69a-8bc5e0c5093e" alt=""><figcaption><p>Invalidate the files</p></figcaption></figure>

8\) Now, the most important output of this process is **WebGL catalog json file of the addressable.** This file is located in *AWS Console -> S3 -> Your public bucket -> Addressables -> 2021.3.1f1 ->Your product name that you specified in Unity3D Player Settings -> WebGL -> catalog\_yyyy.mm.dd.hh.mm.ss.json.*&#x20;

<figure><img src="https://4213294372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo4sRWPX77c58Cw1FjKCI%2Fuploads%2FiFETdmf81wY7ACFvFEVY%2F8_Trim.gif?alt=media&#x26;token=e9140292-cf5d-4167-bf6c-ef8ecec01657" alt=""><figcaption><p><em>json file</em></p></figcaption></figure>

*9)* Copy the link from the S3 and make sure to replace domain name by your CloudFront distribution domain name. After that this url needs to be used when creating a private template in HoloFair system. See [Pubish & Test your Metaverse](https://docs.holofair.app/development/initial-setup/pubish-and-test-your-metaverse)

<figure><img src="https://4213294372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo4sRWPX77c58Cw1FjKCI%2Fuploads%2FrAqYwIw89l5oxss2jgVo%2F9_AdobeExpress.gif?alt=media&#x26;token=5339b0ad-c93e-48e9-a8cf-11bb53e61092" alt=""><figcaption><p>Upload to HoloFair</p></figcaption></figure>
