In this section, you add a second S3 bucket in another Region and combine it with the existing bucket in an origin group. When the primary origin returns one of the failover status codes, CloudFront retries the request on the secondary origin.

s3bucket-secondary. Bucket names must be globally unique, so add a suffix if the name is taken.

secondary-index.html with the content below and save it with UTF-8 encoding.<html lang="en">
<body>
<h1>CloudFront Lab</h1>
<strong>Hi, this is a page from my secondary Origin! We now support Origin group and failover!</strong>
</body>
</html>




The secondary bucket is private. Unlike the distribution wizard in section 3, the Create origin page doesn’t update the bucket policy for you. Without this policy, S3 returns 403 Access Denied to CloudFront, and CloudFront serves the custom error page from section 5.
Open the Amazon S3 console, select the secondary bucket, open the Permissions tab, and choose Edit under Bucket policy.

Paste the policy you copied and choose Save changes. The policy should look like the one below, with your bucket name, account ID, and distribution ID:
{
"Version": "2008-10-17",
"Id": "PolicyForCloudFrontPrivateContent",
"Statement": [
{
"Sid": "AllowCloudFrontServicePrincipal",
"Effect": "Allow",
"Principal": {
"Service": "cloudfront.amazonaws.com"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<secondary-bucket-name>/*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::<account-id>:distribution/<distribution-id>"
}
}
}
]
}

Configure the origin group:
OriginGroup-CloudFrontLabS3 returns 403 instead of 404 for a missing object when CloudFront doesn’t have s3:ListBucket permission, so 403 is the code that triggers failover in this lab.





Wait until the distribution’s Last modified column shows a date instead of Deploying.
Open https://<your-distribution-domain>/secondary-index.html in the browser.
