<?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/"
	>

<channel>
	<title>VPC SC &#8211; My Shitty Code</title>
	<atom:link href="https://myshittycode.com/tag/vpc-sc/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Fri, 18 Aug 2023 22:37:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://myshittycode.com/wp-content/uploads/2022/04/cropped-icon-32x32.png</url>
	<title>VPC SC &#8211; My Shitty Code</title>
	<link>https://myshittycode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">205304208</site>	<item>
		<title>VPC SC: 2 Ways to Fix NO_MATCHING_ACCESS_LEVEL Error</title>
		<link>https://myshittycode.com/2023/08/18/vpc-sc-2-ways-to-fix-no_matching_access_level-error/</link>
					<comments>https://myshittycode.com/2023/08/18/vpc-sc-2-ways-to-fix-no_matching_access_level-error/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Fri, 18 Aug 2023 22:37:10 +0000</pubDate>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Google Cloud Platform]]></category>
		<category><![CDATA[VPC SC]]></category>
		<guid isPermaLink="false">https://myshittycode.com/?p=2359</guid>

					<description><![CDATA[<p>This post shows you how to fix the dreaded NO_MATCHING_ACCESS_LEVEL error when dealing with VPC Service Control in GCP. Background Let&#8217;s assume you want to protect a project and its resources by putting it within a VPC SC perimeter. You must also ensure your trusted device(s) can access the protected project resources. In this case, [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2023/08/18/vpc-sc-2-ways-to-fix-no_matching_access_level-error/">VPC SC: 2 Ways to Fix NO_MATCHING_ACCESS_LEVEL Error</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#background">Background</a></li><li><a href="#problem">Problem</a></li><li><a href="#solution">Solution</a><ul><li><a href="#option-a-keep-existing-scoped-access-policy-create-dummy-unscoped-access-policy">Option A: Keep Existing Scoped Access Policy, Create Dummy Unscoped Access Policy</a></li><li><a href="#option-b-preferred-delete-existing-scoped-access-policy-create-unscoped-access-policy-with-vpc-sc-perimeter">Option B (Preferred): Delete Existing Scoped Access Policy, Create Unscoped Access Policy with VPC SC Perimeter</a></li></ul></li></ul></nav></div>



<p>This post shows you how to fix the dreaded NO_MATCHING_ACCESS_LEVEL error when dealing with VPC Service Control in GCP.</p>



<h2 class="wp-block-heading" id="background">Background</h2>



<p>Let&#8217;s assume you want to protect a project and its resources by putting it within a VPC SC perimeter. You must also ensure your trusted device(s) can access the protected project resources.</p>



<figure class="wp-block-image aligncenter size-large is-resized"><img decoding="async" src="https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-logical-diagram-1024x381.png?x45560" alt="" class="wp-image-2360" style="width:800px" width="800" srcset="https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-logical-diagram-1024x381.png 1024w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-logical-diagram-300x112.png 300w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-logical-diagram-768x286.png 768w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-logical-diagram.png 1187w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>In this case, an access level is created to capture the IP address (or CIDR ranges) that requires access to the protected resources.</p>



<figure class="wp-block-image aligncenter size-large is-resized"><img decoding="async" src="https://myshittycode.com/wp-content/uploads/2023/08/access-context-manager-1024x644.png?x45560" alt="" class="wp-image-2361" style="width:700px" width="700" srcset="https://myshittycode.com/wp-content/uploads/2023/08/access-context-manager-1024x644.png 1024w, https://myshittycode.com/wp-content/uploads/2023/08/access-context-manager-300x189.png 300w, https://myshittycode.com/wp-content/uploads/2023/08/access-context-manager-768x483.png 768w, https://myshittycode.com/wp-content/uploads/2023/08/access-context-manager.png 1056w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Once an access level is created, a VPC SC perimeter is also created with the ingress policy configured to allow any identities from the whitelisted IPs access to the protected project resources. </p>



<figure class="wp-block-image aligncenter size-large"><img fetchpriority="high" decoding="async" width="454" height="1024" src="https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-perimeter-454x1024.png?x45560" alt="" class="wp-image-2362" srcset="https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-perimeter-454x1024.png 454w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-perimeter-133x300.png 133w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-perimeter-768x1733.png 768w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-perimeter-681x1536.png 681w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-perimeter.png 882w" sizes="(max-width: 454px) 100vw, 454px" /></figure>



<h2 class="wp-block-heading" id="problem">Problem</h2>



<p>One easy way to test the VPC SC perimeter is to interact with a GCS bucket from the command line. If the perimeter is configured properly, you should see a list of files. Otherwise, you will get a VPC SC error like below.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&gt; gsutil ls gs://my-shitty-bucket
AccessDeniedException: 403 Request is prohibited by organization&#039;s policy. 
vpcServiceControlsUniqueIdentifier: qQgF9j6AzA413Mfinr2fC5c67-TQoJRuNFKfCzAfXXXXXXXX
</pre></div>


<p>When looking up the VPC SC UID for more details, it states there is no matching access level, even though the VPC SC perimeter is configured with an access level containing a matching IP address.</p>



<figure class="wp-block-image aligncenter size-large"><img decoding="async" width="946" height="1024" src="https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-troubleshooter-946x1024.png?x45560" alt="" class="wp-image-2363" srcset="https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-troubleshooter-946x1024.png 946w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-troubleshooter-277x300.png 277w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-troubleshooter-768x832.png 768w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-troubleshooter-1419x1536.png 1419w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-troubleshooter-1891x2048.png 1891w" sizes="(max-width: 946px) 100vw, 946px" /></figure>



<h2 class="wp-block-heading" id="solution">Solution</h2>



<p>The most likely reason for this error is you have <a href="https://cloud.google.com/access-context-manager/docs/create-access-policy#scoped-access-policy" target="_blank" rel="noopener">accidentally created a scoped access policy</a> (see the red warning below) without an unscoped access policy at the org level.</p>



<figure class="wp-block-image aligncenter size-large is-resized"><img decoding="async" src="https://myshittycode.com/wp-content/uploads/2023/08/gcp-doc-1024x280.png?x45560" alt="" class="wp-image-2377" style="width:800px" width="800" srcset="https://myshittycode.com/wp-content/uploads/2023/08/gcp-doc-1024x280.png 1024w, https://myshittycode.com/wp-content/uploads/2023/08/gcp-doc-300x82.png 300w, https://myshittycode.com/wp-content/uploads/2023/08/gcp-doc-768x210.png 768w, https://myshittycode.com/wp-content/uploads/2023/08/gcp-doc-1536x420.png 1536w, https://myshittycode.com/wp-content/uploads/2023/08/gcp-doc.png 1610w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>To verify this, go to <strong>Security</strong> > <strong>VPC Service Controls</strong> > <strong>MANAGE POLICIES</strong>. </p>



<figure class="wp-block-image aligncenter size-large is-resized"><img decoding="async" src="https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-manage-policies-1024x219.png?x45560" alt="" class="wp-image-2364" style="width:700px" width="700" srcset="https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-manage-policies-1024x219.png 1024w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-manage-policies-300x64.png 300w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-manage-policies-768x164.png 768w, https://myshittycode.com/wp-content/uploads/2023/08/vpc-sc-manage-policies.png 1162w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>In this example, the &#8220;main&#8221; access policy is scoped to a project (covered by blue color).</p>



<figure class="wp-block-image aligncenter size-large is-resized"><img decoding="async" src="https://myshittycode.com/wp-content/uploads/2023/08/scoped-policy-1024x390.png?x45560" alt="" class="wp-image-2365" style="width:700px" width="700" srcset="https://myshittycode.com/wp-content/uploads/2023/08/scoped-policy-1024x390.png 1024w, https://myshittycode.com/wp-content/uploads/2023/08/scoped-policy-300x114.png 300w, https://myshittycode.com/wp-content/uploads/2023/08/scoped-policy-768x293.png 768w, https://myshittycode.com/wp-content/uploads/2023/08/scoped-policy.png 1108w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>There are 2 ways to fix this.</p>



<h3 class="wp-block-heading" id="option-a-keep-existing-scoped-access-policy-create-dummy-unscoped-access-policy">Option A: Keep Existing Scoped Access Policy, Create Dummy Unscoped Access Policy</h3>



<p>If you share this GCP org with other team members and you want to get it working without impacting other GCP resources, the easiest way is to create another access policy that is unscoped (i.e., no project or folder specified) at the org level. This unscoped access policy does not have any VPC SC perimeters configured.</p>



<p>In this example, an unscoped access policy named &#8220;default&#8221; is created.</p>



<figure class="wp-block-image aligncenter size-large is-resized"><img decoding="async" src="https://myshittycode.com/wp-content/uploads/2023/08/scoped-unscoped-policies-1024x439.png?x45560" alt="" class="wp-image-2366" style="width:700px" width="700" srcset="https://myshittycode.com/wp-content/uploads/2023/08/scoped-unscoped-policies-1024x439.png 1024w, https://myshittycode.com/wp-content/uploads/2023/08/scoped-unscoped-policies-300x128.png 300w, https://myshittycode.com/wp-content/uploads/2023/08/scoped-unscoped-policies-768x329.png 768w, https://myshittycode.com/wp-content/uploads/2023/08/scoped-unscoped-policies.png 1102w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Once the changes are propagated, you can execute the same <strong>gsutil</strong> command successfully.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&gt;  gsutil ls gs://my-shitty-bucket
gs://my-shitty-bucket/my-shitty-file.jpg
</pre></div>


<h3 class="wp-block-heading" id="option-b-preferred-delete-existing-scoped-access-policy-create-unscoped-access-policy-with-vpc-sc-perimeter">Option B (Preferred): Delete Existing Scoped Access Policy, Create Unscoped Access Policy with VPC SC Perimeter</h3>



<p>Unfortunately, an existing scoped access policy cannot be unscoped. So, if you accidentally create a scoped access policy, you can delete it and create an unscoped access policy instead, which requires you to reconfigure the VPC SC perimeter. The upside is you won&#8217;t confuse yourself with multiple access policies if you truly don&#8217;t need the scoped access policy. </p>



<p>In this example, an unscoped access policy named &#8220;default&#8221; is created, and it also has the VPC SC perimeter configured with the same settings.</p>



<figure class="wp-block-image aligncenter size-large is-resized"><img decoding="async" src="https://myshittycode.com/wp-content/uploads/2023/08/unscoped-policy-1024x382.png?x45560" alt="" class="wp-image-2381" style="width:700px" width="700" srcset="https://myshittycode.com/wp-content/uploads/2023/08/unscoped-policy-1024x382.png 1024w, https://myshittycode.com/wp-content/uploads/2023/08/unscoped-policy-300x112.png 300w, https://myshittycode.com/wp-content/uploads/2023/08/unscoped-policy-768x286.png 768w, https://myshittycode.com/wp-content/uploads/2023/08/unscoped-policy.png 1126w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Once the changes are propagated, the same <strong>gsutil</strong> command will also execute successfully.</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2023/08/18/vpc-sc-2-ways-to-fix-no_matching_access_level-error/">VPC SC: 2 Ways to Fix NO_MATCHING_ACCESS_LEVEL Error</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2023/08/18/vpc-sc-2-ways-to-fix-no_matching_access_level-error/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2359</post-id>	</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 
Lazy Loading (feed)
Database Caching 60/73 queries in 0.028 seconds using Disk

Served from: myshittycode.com @ 2026-02-21 06:33:45 by W3 Total Cache
-->