<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="https://publishpress.com/"
	>

<channel>
	<title>storage bucket gcp binding Archives - Anuj Varma, Hands-On Technology Architect, Clean Air Activist</title>
	<atom:link href="https://www.anujvarma.com/tag/storage-bucket-gcp-binding/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.anujvarma.com/tag/storage-bucket-gcp-binding/</link>
	<description>Production Grade Technical Solutions &#124; Data Encryption and Public Cloud Expert</description>
	<lastBuildDate>Wed, 17 Jun 2020 16:50:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://www.anujvarma.com/wp-content/uploads/anujtech.png</url>
	<title>storage bucket gcp binding Archives - Anuj Varma, Hands-On Technology Architect, Clean Air Activist</title>
	<link>https://www.anujvarma.com/tag/storage-bucket-gcp-binding/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>GCP Service Accounts and IAM Bindings</title>
		<link>https://www.anujvarma.com/gcp-service-accounts-and-iam-bindings/</link>
					<comments>https://www.anujvarma.com/gcp-service-accounts-and-iam-bindings/#comments</comments>
		
		<dc:creator><![CDATA[Anuj Varma]]></dc:creator>
		<pubDate>Wed, 17 Jun 2020 16:50:59 +0000</pubDate>
				<category><![CDATA[GCP IAM]]></category>
		<category><![CDATA[gcp iam bindings]]></category>
		<category><![CDATA[iam binding google cloud]]></category>
		<category><![CDATA[project iam binding]]></category>
		<category><![CDATA[storage bucket gcp binding]]></category>
		<guid isPermaLink="false">https://googlearchitect.com/?p=70</guid>

					<description><![CDATA[<p>It took me a while to get a handle on these&#8230;This post will hopefully clear up some initial teething issues around creating iam bindings. (Also, read &#8216;Service Accounts in GCP&#8217;) [&#8230;]</p>
<p>The post <a href="https://www.anujvarma.com/gcp-service-accounts-and-iam-bindings/">GCP Service Accounts and IAM Bindings</a> appeared first on <a href="https://www.anujvarma.com">Anuj Varma, Hands-On Technology Architect, Clean Air Activist</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>It took me a while to get a handle on these&#8230;This post will hopefully clear up some initial teething issues around creating iam bindings. (Also, read <a href="https://googlearchitect.com/2020/06/16/service-accounts-in-gcp/">&#8216;Service Accounts in GCP&#8217;</a>)</p>
<p>IAM bindings are used to answer the question &#8211; here is a SPECIFIC bucket (or instance). How do I allow (or block) access to THIS PARTICULAR resource?</p>
<p>The answer is to create an IAM Binding &#8211; between the USER (IAM identity) and the RESOURCE.  The way you do this is using the gCloud tool (or gsUtil for a lot of storage specific IAM bindings)</p>
<p>A couple of examples should help clarify the use of gCloud and gsUtil</p>
<h4 class="graf graf--pre">Storage bucket binding to IAM user</h4>
<pre class="graf graf--pre">gsutil iam ch user:john.doe@example.com:storageAdmin gs://ex-bucket</pre>
<h4 class="graf graf--pre">Storage bucket binding to a Service Account</h4>
<pre><code>gsutil iam ch serviceAccount:test-sa@&lt;PROJECT&gt;.iam.gserviceaccount.com:admin gs://ex-bucket</code></pre>
<h4 class="graf graf--pre">Compute Engine binding to IAM user (grant compute.admin ON a specific VM to a specific user)</h4>
<pre dir="ltr" translate="no">gcloud beta compute instances add-iam-policy-binding my-instance \
      --zone=ZONE --member='user:test-user@gmail.com' \
      --role='roles/compute.admin'</pre>
<h3>Instead of an IAM User, what if we want to bind a service account to a resource?</h3>
<p>Yes &#8211; you can create the same IAM binding between a Service Account and a  GCP Resource. The beauty of this technique is that service accounts, being super powerful entities, can get access to all contained resources.</p>
<p>For example, if you were to BIND the service account at the PROJECT level (say, you granted it roles/StorageAdmin), that would allow this service account to manage ALL storage buckets inside the project.</p>
<p><strong>Example 1 &#8211; Service Account bound to itself?</strong></p>
<p>The operative words here are &#8216;gcloud iam&#8217; &#8211; This shows that the binding is occurring between an IAM resource and another IAM resource.</p>
<pre class="clear-for-copy"><code class="devsite-terminal" dir="ltr"><span class="pln">gcloud iam service</span><span class="pun">-</span><span class="pln">accounts add</span><span class="pun">-</span><span class="pln">iam</span><span class="pun">-</span><span class="pln">policy</span><span class="pun">-</span><span class="pln">binding test</span><span class="pun">-</span><span class="pln">proj1@example</span><span class="pun">.</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com </span><span class="pun">--</span><span class="pln">member</span><span class="pun">=</span><span class="str">'serviceAccount:test-proj1@example.domain.com'</span> <span class="pun">--</span><span class="pln">role</span><span class="pun">=</span><span class="str">'roles/editor'</span></code></pre>
<p><strong>Example 2 &#8211; Service Account (as an identity) bound to a project</strong></p>
<p>The operative word here is &#8216;gcloud projects&#8217; &#8211; This says that the binding is occurring at a PROJECT level.</p>
<p><code class="devsite-terminal" dir="ltr"><span class="pln">gcloud projects add</span><span class="pun">-</span><span class="pln">iam</span><span class="pun">-</span><span class="pln">policy</span><span class="pun">-</span><span class="pln">binding test</span><span class="pun">-</span><span class="pln">proj1@example</span><span class="pun">.</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com </span><span class="pun">--</span><span class="pln">member</span><span class="pun">=</span><span class="str">'serviceAccount:test-proj1@example.domain.com'</span> <span class="pun">--</span><span class="pln">role</span><span class="pun">=</span><span class="str">'roles/editor'</span></code></p>
<h3 class="graf graf--h4">Okay &#8211; so an IAM user can be bound to a resource. And a service account can be bound to a resource. What about an IAM user being bound to a service account?</h3>
<p>Yes &#8211; service accounts are RESOURCES as well.  You can bind a user (IAM user) to a service account (resource) as shown below. Again, the operative words are &#8216;gcloud iam&#8217;</p>
<pre class="clear-for-copy"><code class="devsite-terminal" dir="ltr"><span class="pln">gcloud iam service</span><span class="pun">-</span><span class="pln">accounts add</span><span class="pun">-</span><span class="pln">iam</span><span class="pun">-</span><span class="pln">policy</span><span class="pun">-</span><span class="pln">binding my</span><span class="pun">-</span><span class="pln">iam</span><span class="pun">-</span><span class="pln">account@somedomain</span><span class="pun">.</span><span class="pln">com </span><span class="pun">--</span><span class="pln">member</span><span class="pun">=</span><span class="str">'user:test-user@gmail.com'</span> <span class="pun">--</span><span class="pln">role</span><span class="pun">=</span><span class="str">'roles/editor'</span></code></pre>
<h3 class="graf graf--h4">Service Accounts are Identities as well as Resources</h3>
<p class="graf graf--p">As shown above, a service account can be used as an IAM Identity to create specific IAM Bindings to resources.</p>
<p class="graf graf--p">At times, you would use the SA as an identity (to authenticate to GCP resources). For example, if you have a Compute Engine Virtual Machine (VM) running as a service account, you can grant the editor role to the service account (the identity) for a project (the resource).</p>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong">Service Account <em>As a Resource</em>  — ‘the identity USES the service account as a resource’ </strong></p>
<p class="graf graf--p">   At times, you would need another IAM identity to USE an existing service account. In that case, the service account is nothing more than a resource. As an example, you may want to control who can start a compute instance (for which there is an existing service account). All you would do is GRANT the IAM user (the identity) the <code class="markup--code markup--p-code"><a class="markup--anchor markup--p-anchor" href="https://cloud.google.com/iam/docs/service-accounts#the_service_account_user_role" target="_blank" rel="noopener noreferrer" data-href="https://cloud.google.com/iam/docs/service-accounts#the_service_account_user_role">serviceAccountUser</a></code> role for the compute engine service account (the resource).</p>
<h4 class="graf graf--h4">More GCP IAM Bindings &#8211; Deeper Dive</h4>
<p class="graf graf--p">An IAM binding has three components — a set of users, a resource and a set of ROLES (permissions) for those users on that resource. The ‘resource’ can sometimes be an identity (e.g. a service account).</p>
<p class="graf graf--p">So — take the following two examples:</p>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong">Example 1 — IAM Binding of IAM Users to a PROJECT (resource)</strong></p>
<p class="graf graf--p">Assign ‘roles/editor’ for all authenticated users on a project with identifier ‘example-project-id-1’</p>
<pre class="graf graf--pre">gcloud projects add-iam-policy-binding example-project-id-1 \
      --member='allAuthenticatedUsers' --role='roles/editor'</pre>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong">Example 2— IAM Binding of IAM Users to a Service Account (used as a resource)</strong></p>
<pre class="clear-for-copy"><code class="devsite-terminal" dir="ltr"><span class="pln">gcloud iam service</span><span class="pun">-</span><span class="pln">accounts add</span><span class="pun">-</span><span class="pln">iam</span><span class="pun">-</span><span class="pln">policy</span><span class="pun">-</span><span class="pln">binding my</span><span class="pun">-</span><span class="pln">iam</span><span class="pun">-</span><span class="pln">account@somedomain</span><span class="pun">.</span><span class="pln">com </span><span class="pun">--</span><span class="pln">member</span><span class="pun">=</span><span class="str">'user:test-user@gmail.com'</span> <span class="pun">--</span><span class="pln">role</span><span class="pun">=</span><span class="str">'roles/editor'</span></code></pre>
<h3>Summary</h3>
<p>That&#8217;s it. GCP IAM bindings sound more convoluted than they actually are. Essentially, if your question is:</p>
<p>&#8216;I have this resource (say a storage bucket).. How do I allow a particular user (say iam@xyz.com) access to JUST THIS BUCKET, and NOT ALL BUCKETS?&#8217;</p>
<p>You would use an IAM Binding to do this.</p>
<p>How about if you wanted to grant access to ALL storage buckets inside a project? You would still create an IAM Binding &#8211; but you would define it at the Project Level (StorageAdmin at the Project Level).</p>
<p><a href="https://calendly.com/anujvarma/private-1-on-1-conversation">Set up a 1 on 1 appointment with Anuj to assist with your cloud journey.</a></p>
<p>The post <a href="https://www.anujvarma.com/gcp-service-accounts-and-iam-bindings/">GCP Service Accounts and IAM Bindings</a> appeared first on <a href="https://www.anujvarma.com">Anuj Varma, Hands-On Technology Architect, Clean Air Activist</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.anujvarma.com/gcp-service-accounts-and-iam-bindings/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Content Delivery Network via N/A
Minified using Disk

Served from: www.anujvarma.com @ 2026-07-22 12:29:54 by W3 Total Cache
-->