‫So, let's go ahead and make a bucket policy
‫so that we can access this coffee file from the public URL.
‫So to do so, let's go under the Permissions tabs.
‫And the first thing we have to do is to allow public access
‫from the bucket setting
‫because right now, everything is blocked.
‫So we edit this, and we're going to untick this,
‫and therefore, we will allow public access.
‫But again, this is something you would disable only
‫and only if you know you want to set a public bucket policy.
‫So this is dangerous action.
‫So we say yes because, of course,
‫if you sets data, real data of your company
‫on an S3 bucket and you make this public,
‫you have data leaks, and that can never be good.
‫So now, under permissions
‫or review, the access that objects can be public.
‫So that's the first step.
‫Next, we scroll down, and we look at Bucket policy.
‫So currently, we have none, and we wanna create one
‫so that we make our entire buckets public.
‫So the first thing you can do is look
‫at the policies example, and this is the documentation.
‫And it will show you a lot of use cases
‫on the right hand side that will show you
‫what's the appropriate and corresponding Bucket policy.
‫But for us, we're going to use the Policy Generator.
‫So here is the AWS Policy Generator,
‫and we're going to create an S3 bucket policy.
‫So let's select the right type.
‫We'll allow, and then the Principal is going to be a start
‫because we want to allow anyone
‫on the Amazon S3 Service to perform.
‫And because we read the objects on our bucket
‫we want to perform a GetObject.
‫So here it is. We want to allow, GetObject
‫and the Amazon Resource Name must be the bucket name
‫with a "/", and then with a "*".
‫So let's have a look first.
‫So back into our S3 buckets, we have the buckets ARN here,
‫the Amazon Resource Name here.
‫So we copy it, we paste it into the Amazon Resource Name
‫and this is not over.
‫We add a "/", and then we add a "*".
‫And the reason why we do this is
‫that this action the GetObject action right here applies
‫to objects within your buckets and therefore objects within
‫your buckets are after "/" and their "*"
‫to represent these objects.
‫So let's add this statements,
‫and then let's generate this policy.
‫And this policy is what we copy into here.
‫And this is a public S3 policy.
‫So that means that GetObjects are allowed from anyone
‫on any objects of this buckets.
‫Okay, that's good.
‫So let's save these changes.
‫And there is a space here. So let's remove this.
‫Perfect. Save these changes. Now that works.
‫And now, as you can see under permissions
‫of review the access is now set to public,
‫and we get a little warning that unless you want this
‫to be really accessible from the internet,
‫then don't do this.
‫Okay, so now it's publicly accessible.
‫We can see it really from everywhere.
‫So if we go back into our coffee.jpg file,
‫this is the public URL, okay? The full public URL.
‫And I'm going to refresh this page.
‫And now, as you can see, the coffee.jpg file appears
‫before my screen, and therefore, that object is now public.
‫And any objects uploaded
‫onto our Amazon S3 buckets is now going to
‫be accessible using the public URL.
‫Okay. So that's it for this lecture.
‫We've had an overview of Bucket policies,
‫and as well as a sneak peek into the Policy Generator.
‫I hope you liked it, and I will see you in the next lecture.