{"id":22226,"date":"2024-09-23T15:46:24","date_gmt":"2024-09-23T13:46:24","guid":{"rendered":"https:\/\/contabo.com\/blog\/kb\/103000282920-can-i-restrict-users-to-specific-buckets-in-contabo-s-object-storage\/"},"modified":"2025-04-10T18:05:19","modified_gmt":"2025-04-10T16:05:19","slug":"103000282920-can-i-restrict-users-to-specific-buckets-in-contabo-s-object-storage","status":"publish","type":"kb","link":"https:\/\/contabo.com\/blog\/kb\/103000282920-can-i-restrict-users-to-specific-buckets-in-contabo-s-object-storage\/","title":{"rendered":"Can I Restrict Users to Specific Buckets in Contabo&#8217;s Object Storage?"},"content":{"rendered":"<h4 data-identifyelement=\"481\" dir=\"ltr\"><strong data-identifyelement=\"482\" dir=\"ltr\">Can I restrict users to specific buckets in Contabo&#8217;s Object Storage?<\/strong><\/h4>\n<p data-identifyelement=\"483\" dir=\"ltr\">You can restrict users to specific buckets to allow a specific user to use one bucket while another bucket should only be accessible to another user.<\/p>\n<p data-identifyelement=\"486\" dir=\"ltr\">The following describes how to allow access to buckets to a limited number of users.<\/p>\n<p data-identifyelement=\"487\" dir=\"ltr\"><br data-identifyelement=\"488\"><\/p>\n<p data-identifyelement=\"489\" dir=\"ltr\">The following assumes that aws cli is installed and properly configured and that you have access to <u data-identifyelement=\"492\"><a data-identifyelement=\"493\" href=\"https:\/\/my.contabo.com\/object_storage\" rel=\"noopener noreferrer nofollow\" target=\"_blank\">Contabo&#8217;s Object Storage Panel<\/a><\/u> to create users.<\/p>\n<p data-identifyelement=\"494\" dir=\"ltr\"><br data-identifyelement=\"495\"><\/p>\n<h4 data-identifyelement=\"496\" dir=\"ltr\"><strong data-identifyelement=\"497\" dir=\"ltr\">How do I restrict users to specific buckets in Contabo&#8217;s Object Storage?<\/strong><\/h4>\n<p data-identifyelement=\"498\" dir=\"ltr\">You need to set up a bucket policy. A bucket policy allows or denies access to buckets in the form of specific actions, and is used to control which users have what access to a bucket.<\/p>\n<p data-identifyelement=\"499\" dir=\"ltr\"><br data-identifyelement=\"500\"><\/p>\n<p data-identifyelement=\"501\" dir=\"ltr\">Below is an example of how to set this up:<\/p>\n<ol data-identifyelement=\"502\">\n<li data-identifyelement=\"503\" dir=\"ltr\">This step denies user <a href=\"\/cdn-cgi\/l\/email-protection\" rel=\"nofollow\" class=\"__cf_email__\" data-cfemail=\"7d080e180f4f3d18051c100d1118531e1210\">[email&nbsp;protected]<\/a> any action on any resource in bucket-for-user-1.\n<p>With the given data, we can create a policy for bucket-for-user-1 and store it in the file bucket-for-user-1-policy.json with the following content<\/p>\n<pre data-identifyelement=\"506\" dir=\"ltr\">{<br data-identifyelement=\"508\">\"Version\": \"2012-10-17\",<br data-identifyelement=\"509\">\"Statement\": [<br data-identifyelement=\"510\">{<br data-identifyelement=\"511\">\"Action\": \"*\",<br data-identifyelement=\"512\">\"Effect\": \"Deny\",<br data-identifyelement=\"513\">\"Resource\": \"*\",<br data-identifyelement=\"514\">\"Principal\": {<br data-identifyelement=\"515\">\"AWS\": [<br data-identifyelement=\"516\">\"arn:aws:iam::5c37e60c3ee04f1eb116c436b1afadca:user\/12345:3368c22e-08da-446f-a470-1928e58457a2\"<br data-identifyelement=\"517\">]<br data-identifyelement=\"518\">}<br data-identifyelement=\"519\">}<br data-identifyelement=\"520\">]<br data-identifyelement=\"521\">}<\/pre>\n<p>Please note that in here s3TenantId=5c37e60c3ee04f1eb116c436b1afadca, customerId=12345 and userId=3368c22e-08da-446f-a470-1928e58457a2. Thus the format is arn:aws:iam::&lt;s3TenantId&gt;:user\/&lt;customerId&gt;:&lt;userId&gt;. To apply it, please run the following API:<br data-identifyelement=\"522\"><br data-identifyelement=\"523\"><\/p>\n<pre data-identifyelement=\"524\">aws --profile eu2 --endpoint-url https:\/\/eu2.contabostorage.com s3api put-bucket-policy --bucket bucket-for-user-1 --policy file:\/\/bucket-for-user-1-policy.json<\/pre>\n<\/li>\n<li data-identifyelement=\"526\" dir=\"ltr\">This step denies any action on any resource in bucket-for-user-2 for the user <a href=\"\/cdn-cgi\/l\/email-protection\" rel=\"nofollow\" class=\"__cf_email__\" data-cfemail=\"77020412054637120f161a071b125914181a\">[email&nbsp;protected]<\/a>.<br data-identifyelement=\"527\"><br data-identifyelement=\"528\">\n<pre data-identifyelement=\"529\">{<br data-identifyelement=\"531\">\"Version\": \"2012-10-17\",<br data-identifyelement=\"532\">\"Statement\": [<br data-identifyelement=\"533\">{<br data-identifyelement=\"534\">\"Action\": \"*\",<br data-identifyelement=\"535\">\"Effect\": \"Deny\",<br data-identifyelement=\"536\">\"Resource\": \"*\",<br data-identifyelement=\"537\">\"Principal\": {<br data-identifyelement=\"538\">\"AWS\": [<br data-identifyelement=\"539\">\"arn:aws:iam::5c37e60c3ee04f1eb116c436b1afadca:user\/12345:6299cbdd-ef72-486b-b088-c34181fc20f1\"<br data-identifyelement=\"540\">]<br data-identifyelement=\"541\">}<br data-identifyelement=\"542\">}<br data-identifyelement=\"543\">]<br data-identifyelement=\"544\">}<\/pre>\n<\/li>\n<li data-identifyelement=\"545\" dir=\"ltr\">Please note that in here s3TenantId=5c37e60c3ee04f1eb116c436b1afadca, customerId=12345 and userId=6299cbdd-ef72-486b-b088-c34181fc20f1, so the format is arn:aws:iam::&lt;s3TenantId&gt;:user\/&lt;customerId&gt;:&lt;userId&gt;. To apply it, please run the following API:<br data-identifyelement=\"546\"><br data-identifyelement=\"547\">\n<pre data-identifyelement=\"548\">aws --profile eu2 --endpoint-url https:\/\/eu2.contabostorage.com s3api put-bucket-policy --bucket bucket-for-user-2 --policy file:\/\/bucket-for-user-2-policy.json<\/pre>\n<\/li>\n<\/ol>\n<p data-identifyelement=\"550\" dir=\"ltr\">The example above is based on two buckets:<\/p>\n<ul data-identifyelement=\"551\">\n<li data-identifyelement=\"552\">bucket-for-user-1<\/li>\n<li data-identifyelement=\"553\" dir=\"ltr\">bucket-for-user-2<br data-identifyelement=\"554\"><br data-identifyelement=\"555\"><\/li>\n<\/ul>\n<p data-identifyelement=\"556\" dir=\"ltr\">Also two existing users who set their password to access Contabo&#8217;s Object Storage Panel:<\/p>\n<ul data-identifyelement=\"557\">\n<li data-identifyelement=\"558\"><a href=\"\/cdn-cgi\/l\/email-protection\" rel=\"nofollow\" class=\"__cf_email__\" data-cfemail=\"ee9b9d8b9cdfae8b968f839e828bc08d8183\">[email&nbsp;protected]<\/a> with S3 Read and Write role<\/li>\n<li data-identifyelement=\"559\"><a href=\"\/cdn-cgi\/l\/email-protection\" rel=\"nofollow\" class=\"__cf_email__\" data-cfemail=\"d7a2a4b2a5e597b2afb6baa7bbb2f9b4b8ba\">[email&nbsp;protected]<\/a> with S3 Read and Write role<br data-identifyelement=\"560\"><br data-identifyelement=\"561\"><\/li>\n<\/ul>\n<p data-identifyelement=\"562\" dir=\"ltr\">The usage should be restricted as follows:<\/p>\n<ul data-identifyelement=\"563\">\n<li dir=\"ltr\">only <a href=\"\/cdn-cgi\/l\/email-protection\" rel=\"nofollow\" class=\"__cf_email__\" data-cfemail=\"2c595f495e1d6c49544d415c4049024f4341\">[email&nbsp;protected]<\/a> has access to bucket for user-1<\/li>\n<li data-identifyelement=\"564\" dir=\"ltr\">only <a href=\"\/cdn-cgi\/l\/email-protection\" rel=\"nofollow\" class=\"__cf_email__\" data-cfemail=\"e693958394d4a6839e878b968a83c885898b\">[email&nbsp;protected]<\/a> can access bucket-for-user-2<\/li>\n<\/ul>\n<p data-identifyelement=\"568\" dir=\"ltr\">Of course, in your actual scenario, the bucket names and user names will be different. Please adjust them accordingly. You could have any number of buckets or users with different policies, and even more fine-grained control over actions. But that is not covered here.<\/p>\n<p data-identifyelement=\"569\" dir=\"ltr\"><br data-identifyelement=\"570\"><\/p>\n<p data-identifyelement=\"571\" dir=\"ltr\">Furthermore you will need the internal representation of the users in the S3 Object Storage. To get them please use the <a data-identifyelement=\"572\" href=\"https:\/\/api.contabo.com\/#operation\/retrieveUserList\" rel=\"noopener noreferrer nofollow\" target=\"_blank\"><u data-identifyelement=\"573\">Contabo API<\/u><\/a> or the <a data-identifyelement=\"574\" href=\"https:\/\/github.com\/contabo\/cntb\" rel=\"noopener noreferrer nofollow nofollow\" target=\"_blank\"><code data-identifyelement=\"575\"><u data-identifyelement=\"576\">cntb<\/u><\/code><u data-identifyelement=\"577\">&nbsp;cli<\/u><\/a> via cntb get users. Please use the value of the userId field.<br data-identifyelement=\"578\"><br data-identifyelement=\"579\"><\/p>\n<p data-identifyelement=\"580\" dir=\"ltr\">You will also need the so called s3TenantId for the given Object Storage. You can get it with cntb get objectStorages -o=json.<\/p>\n<p data-identifyelement=\"581\" dir=\"ltr\"><br data-identifyelement=\"582\"><\/p>\n<h4 data-identifyelement=\"583\" dir=\"ltr\"><strong data-identifyelement=\"584\">How do I remove restrictions for users from a bucket?<\/strong><\/h4>\n<p data-identifyelement=\"585\" dir=\"ltr\">By removing the policies, both users will have full access to the buckets again. Please follow these steps:<br data-identifyelement=\"586\"><br data-identifyelement=\"587\">aws &#8211;profile eu2 &#8211;endpoint-url https:\/\/eu2.contabostorage.com s3api delete-bucket-policy &#8211;bucket bucket-for-user-1<br data-identifyelement=\"588\">aws &#8211;profile eu2 &#8211;endpoint-url https:\/\/eu2.contabostorage.com s3api delete-bucket-policy &#8211;bucket bucket-for-user-2<\/p>\n<\/p>\n<p><span class=\"ast-load-more active\"><a href=\"https:\/\/help.contabo.com\/en\/support\/solutions\/articles\/103000282920-can-i-restrict-users-to-specific-buckets-in-contabo-s-object-storage-\" rel=\"nofollow\">Details&#8230;<\/a> <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Can I restrict users to specific buckets in Contabo&#8217;s Object Storage? You can restrict users to specific buckets to allow a specific user to use one bucket while another bucket should only be accessible to another user. The following describes how to allow access to buckets to a limited number of users. The following assumes [&hellip;]<\/p>\n","protected":false},"author":72,"featured_media":0,"template":"","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[2067],"tags":[],"class_list":["post-22226","kb","type-kb","status-publish","hentry","category-kb"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Contabo Web","author_link":"https:\/\/contabo.com\/blog\/author\/julius-nalivaiko\/"},"uagb_comment_info":0,"uagb_excerpt":"Can I restrict users to specific buckets in Contabo&#8217;s Object Storage? You can restrict users to specific buckets to allow a specific user to use one bucket while another bucket should only be accessible to another user. The following describes how to allow access to buckets to a limited number of users. The following assumes&hellip;","_links":{"self":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/users\/72"}],"version-history":[{"count":1,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22226\/revisions"}],"predecessor-version":[{"id":22917,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22226\/revisions\/22917"}],"wp:attachment":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/media?parent=22226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/categories?post=22226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/tags?post=22226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}