|
1 | 1 | ## Step 2: Create Amazon CloudFront Distribution |
2 | 2 |
|
3 | | -In this step we will create an Amazon CloudFront distribution with your Amazon S3 bucket created in Step 1 as source. We will also restrict access to the bucket by using an [Origin Access Identity (OAI)](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html). |
4 | | - |
5 | | -**Note**: Use an IAM user account in this step for security best practices. |
| 3 | +In this step you will create an Amazon CloudFront distribution with your Amazon S3 bucket created in Step 1 as source. You will also restrict access to the bucket by using an [Origin Access Identity (OAI)](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html). |
6 | 4 |
|
7 | 5 | ### Create Distribution |
8 | 6 | 1. Log into your AWS account and navigate to the [Amazon CloudFront Management Console](https://console.aws.amazon.com/cloudfront). |
9 | | -2. Select **Create Distribution**. |
10 | | -3. Under Web, select **Get Started**. |
11 | | -4. For **Origin Domain Name** select your Amazon S3 Bucket from Step 1. |
12 | | -5. For **Restrict Bucket Access** select **Yes**. |
13 | | -6. For **Origin Access Identity** select **Create a New Identity**. |
14 | | -7. For **Grant Read Permissions on Bucket** select **Yes, Update Bucket Policy**. This will automatically add an Amazon Bucket policy to the your bucket allowing only this CloudFront distribution to read from the bucket. |
15 | | -8. Leave everything else as default and select **Create Distribution**. |
| 7 | +2. Choose **Create Distribution**. |
| 8 | +3. Under Web, choose **Get Started**. |
| 9 | +4. For **Origin Domain Name** choose your Amazon S3 Bucket from Step 1. |
| 10 | +5. For **Restrict Bucket Access** choose **Yes**. |
| 11 | +6. For **Origin Access Identity** choose **Create a New Identity**. |
| 12 | +7. For **Grant Read Permissions on Bucket** choose **Yes, Update Bucket Policy**. This will automatically add an Amazon Bucket policy to the your bucket allowing only this CloudFront distribution to read from the bucket. |
| 13 | +8. Leave everything else as default and choose **Create Distribution**. |
16 | 14 | 9. In the distribution details screen, note the **Distribution Status**. Wait for the status to change from **In Progress** to **Deployed**. It can take upward of 5 minutes for the process to complete. |
17 | 15 | 10. Under **Domain Name** copy the FQDN, similar to `dxxxxxxxxxz.cloudfront.net`. |
18 | 16 |
|
19 | 17 | ### Test Public Distribution |
20 | | -We want to test to verify that the distribution is setup correctly and has access to the Amazon S3 contents. |
| 18 | +You want to test to verify that the distribution is setup correctly and has access to the Amazon S3 contents. |
21 | 19 |
|
22 | 20 | Use your browser and enter the URL https://dxxxxxxxxxz.cloudfront.net/sample.html. Remember to replace the domain name with your FQDN. Your sample webpage should come up correctly. However, anyone with your URL can access your Amazon S3 contents. |
23 | 21 |
|
24 | 22 | ### Secure Distribution |
25 | | -Next we want to secure the Amazon CloudFront distribution to restrict public access. |
26 | | -1. Select the **Distribution ID** to open the detail view. |
27 | | -2. Select the **Behaviors** tab. |
28 | | -3. Checkbox the default **Origin or Origin Group** and select **Edit**. |
29 | | -4. Under **Restrict Viewer Access (Use Signed URLs or Signed Cookies)** select **Yes** to expand the **Trusted Key Groups or Trusted Signer** option. |
30 | | -5. Under **Trusted Key Groups or Trusted Sign**, select **Trusted Signer**. |
31 | | -6. Under **Trusted Signers** select **Self** if you are using the same AWS Account for both the CloudFront distribution and the CloudFront key pair, which we will create in the next step. Select **Specify Accounts** and enter the account number of another AWS Account that you will be using to create the CloudFront key pair. |
32 | | -7. Select **Yes, Edit** to save the changes. |
| 23 | +Next you want to secure the Amazon CloudFront distribution to restrict public access. |
| 24 | +1. Choose the **Distribution ID** to open the detail view. |
| 25 | +2. Choose the **Behaviors** tab. |
| 26 | +3. Select the default **Origin or Origin Group** and choose **Edit**. |
| 27 | +4. Under **Restrict Viewer Access (Use Signed URLs or Signed Cookies)** choose **Yes** to expand the **Trusted Key Groups or Trusted Signer** option. |
| 28 | +5. Under **Trusted Key Groups or Trusted Signer**, select **Trusted Signer**. (Note: you will change this to **Trusted Key Groups** in later section.) |
| 29 | +6. Under **Trusted Signers** select **Self**. |
| 30 | +7. Choose **Yes, Edit** to save the changes. |
33 | 31 |
|
34 | 32 | ### Test Secured Distribution |
35 | | -Now we want to test to verify that the distribution is restricted. Refresh the webpage and you should see the error message: |
| 33 | +Now you want to test to verify that the distribution is restricted. Refresh the webpage and you should see the error message: |
36 | 34 | > Missing Key-Pair-Id query parameter or cookie value |
37 | 35 |
|
38 | | -In this step we created an Amazon CloudFront distribution to distribute your Amazon S3 private contents. We then secured the distribution by using the **Restrict Viewer Access** option. |
| 36 | +In this step you created an Amazon CloudFront distribution to distribute your Amazon S3 private contents. You then secured the distribution by using the **Restrict Viewer Access** option. |
39 | 37 |
|
40 | | -In [Step 3](../3-Create_CloudFront_Keypair/README.md), we will create the **CloudFront Key Pair** |
| 38 | +In [Step 3](../3-Create_CloudFront_Key_Groups/README.md), you will create the **CloudFront Key Groups** |
0 commit comments