Set up a backend bucket as an origin for Cloud CDN
This quickstart shows you how to set up a backend bucket as an origin for Cloud CDN by using the Google Cloud console.
To follow step-by-step guidance for this task directly in the Google Cloud console, click Guide me:
Before you begin
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Make sure that billing is enabled for your Google Cloud project.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Make sure that billing is enabled for your Google Cloud project.
Create a Cloud Storage bucket
Buckets are the basic containers that hold your data in Cloud Storage.
To create a bucket, follow these steps:
-
In the Google Cloud console, go to the Cloud Storage Buckets page.
-
Click
Show me .
Create.
-
In the
Name your bucket section, enter a unique name for your bucket.Click Continue.
- In the
Choose where to store your data section, do the following:- For Location type, select Region, and then
select
us-east1 (South Carolina)
from the list. - Click Continue.
- For Location type, select Region, and then
select
- In the
Choose a storage class for your data section, do the following:- Select Set a default class, and then select Standard.
- Click Continue.
- In the
Choose how to control access to objects section, do the following:- Clear the Enforce public access prevention on this bucket checkbox.
- For Access control, select Uniform.
- Click Continue.
- In the
Choose how to protect object data section, keep the selected defaults, and then clickCreate .
Upload an object into the bucket
Save the following image on your device:
- On the Bucket details page, on the
Objects tab, clickUpload files . - In the file dialog, select the file that you downloaded.
Make your bucket public
- On the Bucket details page, click the
Permissions tab. -
Ensure that the view is set to
View by principals , and then clickGrant access .The Add principals pane is displayed.
- In the
New principals field, enterallUsers
. - In the
Select a role list, select Cloud Storage > Storage Object Viewer. - Click
Save . - On the Are you sure you want to make this resource public? page, click Allow public access.
-
To verify that the object has been shared publicly, click the
Objects tab to return to the list of objects. Your object'sPublic access column should read Public to internet. The Copy URL button provides a shareable URL similar to the following:https://storage.googleapis.com/YOUR_BUCKET_NAME/kitten.png
Create a backend bucket
To create a backend bucket and an external Application Load Balancer, do the following:
In the Google Cloud console, go to the Cloud CDN page.
Click
Add origin .On the New origin page, in the
Origin name section, enter a name for your origin.For
Origin type , select Backend bucket.For
Define your backend bucket , select New backend bucket.In the Cloud Storage bucket field, click Browse.
Select the Cloud Storage bucket that you created earlier, click Select, and then click Next.
In the
Attach a load balancer section, select Create new load balancer for me, enter a name for the load balancer, and then click Next.For Cache performance, keep the selected defaults, and then click
Done .The new origin appears in the list of origins. It might take a few minutes for the origin to be fully created. Proceed to the next step only after you see a notification indicating that the origin has been created.
Test Cloud CDN
-
In the Google Cloud console, go to the Load balancing page.
Click the
name of the load balancer that you created earlier.The Load balancer details page is displayed.
Note the IPv4 addresses displayed under
IP:Port .Test Cloud CDN by entering the following URL with the load balancer's IP address in a new browser tab:
http://IP_ADDRESS/kitten.png
Your browser should render a page with the uploaded image.
Refresh the page multiple times.
Return to the Load balancer details page, and then click Monitoring.
After a few minutes, observe the served traffic.
Traffic that is served directly from your backend bucket is labeled SERVED_FROM_BACKEND_BUCKET. Traffic that is served from Cloud CDN is labeled SERVED_FROM_CACHE. For more information, see Monitoring metrics.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
Delete the load balancer and the backend bucket:
-
In the Google Cloud console, go to the Load balancing page.
Select the check box next to the load balancer that you created, and then click Delete.
On the page that opens, select the check box next to the backend bucket that you created, and then confirm that you want to delete the load balancer and the selected resources.
-
Delete the Cloud Storage bucket:
-
In the Google Cloud console, go to the Cloud Storage Buckets page.
- Select the checkbox next to the bucket that you created, and then click Delete.
- In the Delete bucket dialog, confirm that you want to delete the bucket, and then click Delete.
-
In the Google Cloud console, go to the Cloud Storage Buckets page.
What's next
Here's what you can do next: