DEV Community

Cover image for Make Cloud Storage Objects Publicly Accessible
Dhruv Rajkotia
Dhruv Rajkotia

Posted on

Make Cloud Storage Objects Publicly Accessible

Recently, I'm working on the website development and I wanted to store some of my images in the cloud so that I can easily access those images using the public link.๐Ÿ˜„

So I thought๐Ÿค” to go with the google cloud services for the same, But by default the public access of the GCP storage objects is disabled in the Cloud Storage services. To access using the public URL we need to perform some steps. So today we are going to discuss about the same like how we can enabled the public access URL for cloud storage objects.

Step 1: Create GCP storage bucket

  • First of all go to https://console.cloud.google.com/
  • Search Cloud storage and select the service from suggestions
  • Click on the Create Bucket option Image description
  • Provide name of your bucket Image description
  • Click Continue and select the region and location based on your requirement. For me It's Multi-region & Asia
  • Then Click continue and select the default storage class for your data. I'll choose standard as I need the frequent access to my data.
  • For the next step we need to choose how to control access to objects option which is basically an access mechanism for the bucket's object.

We have 2 options:

  1. Uniform: Means that access mechanism will be at the bucket level so all the objects of the bucket will have a same access mechanism
  2. Fine-grained: Here we can manage access at the object level so if we have a requirements like some object can be accessible and some of them are not then we can select this one.

I'll choose the first option as I want the access management at the bucket level so I can easily manage of my all the objects access management.

  • Last step for the bucket creation is Choose how to protect object data. Let's keep it as a none for now as we don't have any specific requirement regarding the protect object data.
  • Click on the create button, So now your bucket will be created.

Step 2: Upload the objects/data that you want to access publicly
Now the next steps is to upload the objects/data. So that we can make it public and use it further in our applications/website based on our requirements.

Step 3: Check the object configurations
Now let's first check the object configuration and check how we can identify that the object is publicly available or not.

When you click on the object configuration then you may find the below screen.
Image description

Here if you check Public URL option, which has Not applicable as a value. So it means that this object can only be access by those users who has the access to the cloud bucket which you can check on IAM. So this object will not be publicly accessible. So Now let's move to the final step for how we can make that object publicly accessible.

Step 4: Make Object publicly accessible
Now let's go to the cloud bucket main page. Click on the browser in the left panel of the GCP console and select the bucket that you have created.

You probably on the below screen. (May be our bucket name and regions will be different ๐Ÿ˜€)
Image description

Now let's go to the Permission tab. Click on the Add permission button.
Image description

Provide New principals as a allUsers and Role as a "Storage Legacy Object Reader"
Image description

Click on the Save button which leads to open the new popup for confirmation. Select the Allow Public Access.

Congratulations, now you have enabled the public access to your buckets which means that all the objects in that bucket can be publicly accessible.

Step 5: Test the accessibility of the Object
Now let's go to the object configuration and check the public URL field. Now we have a link associate with the public URL field which is our publicly accessible link. Using that link we can able to access the object publicly. ๐ŸคŸ

Image description

That's it. Congratulations now you know that how to make cloud storage objects publicly accessible.

Hope you liked it ๐Ÿคž. Please Follow me on twitter for more updates regarding my blogs. Have a great day :)๐Ÿ˜‰.

Top comments (0)