<?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>Kitchen Terraform &#8211; My Shitty Code</title>
	<atom:link href="https://myshittycode.com/tag/kitchen-terraform/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Fri, 06 Jan 2023 16:14:05 +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>Kitchen Terraform &#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>GCP + Kitchen Terraform: Local Development Workflow</title>
		<link>https://myshittycode.com/2020/01/23/kitchen-terraform-local-development-workflow/</link>
					<comments>https://myshittycode.com/2020/01/23/kitchen-terraform-local-development-workflow/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Thu, 23 Jan 2020 17:46:38 +0000</pubDate>
				<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Infrastructure as Code]]></category>
		<category><![CDATA[Google Cloud Platform]]></category>
		<category><![CDATA[Kitchen Terraform]]></category>
		<category><![CDATA[Terraform]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=1123</guid>

					<description><![CDATA[<p>INTRODUCTION Here&#8217;s a typical workflow for implementing and running Kitchen Terraform tests outside of the GCP environment, for example, from an IDE on a Mac laptop. Enable &#8220;gcloud&#8221; Access Command: The first step is to ensure we can interact with GCP using the gcloud command using our user credential. This is needed because the tests [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2020/01/23/kitchen-terraform-local-development-workflow/">GCP + Kitchen Terraform: Local Development Workflow</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">INTRODUCTION</h2>



<p>Here&#8217;s a typical workflow for implementing and running Kitchen Terraform tests outside of the GCP environment, for example, from an IDE on a Mac laptop.</p>



<h2 class="wp-block-heading">Enable &#8220;gcloud&#8221; Access</h2>



<p>Command:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
gcloud auth login
</pre></div>


<p>The first step is to ensure we can interact with GCP using the <b>gcloud</b> command using our user credential. This is needed because the tests use the <b>gcloud</b> commands to retrieve GCP resource information in order to do the assertions.</p>



<h2 class="wp-block-heading">Enable SDK Access</h2>



<p>Command:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
gcloud auth application-default login
</pre></div>


<p>This ensures our Terraform code can run the GCP SDK successfully without a service account. Instead, it will use our user credential.</p>



<p>Without this command, we may get the following error when running the Terraform code:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
Response: {
 &quot;error&quot;: &quot;invalid_grant&quot;,
 &quot;error_description&quot;: &quot;reauth related error (invalid_rapt)&quot;,
 &quot;error_subtype&quot;: &quot;invalid_rapt&quot;
}
</pre></div>


<h2 class="wp-block-heading">Display All Kitchen Test Suites</h2>



<p>Command:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
bundle exec kitchen list
</pre></div>


<p>This command displays a list of Kitchen test suites defined in <b>kitchen.yml</b>.</p>



<p>The output looks something like this:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
Instance                            Driver     Provisioner  Verifier   Transport  Last Action    Last Error
router-all-subnets-ip-ranges-local  Terraform  Terraform    Terraform  Ssh
router-interface-local              Terraform  Terraform    Terraform  Ssh
router-no-bgp-no-nat-local          Terraform  Terraform    Terraform  Ssh
router-with-bgp-local               Terraform  Terraform    Terraform  Ssh
router-with-nat-local               Terraform  Terraform    Terraform  Ssh
</pre></div>


<h2 class="wp-block-heading">Run a Specific Test Suite</h2>



<p>Command:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
bundle exec kitchen test &#x5B;INSTANCE_NAME]    

# For example:-
bundle exec kitchen test router-with-nat-local
</pre></div>


<p>This command allows us to run a specific test suite. This will handle the entire Terraform lifecycle&#8230; ie: setting up the infrastructure, running the tests and destroying the infrastructure.</p>



<p>This is helpful especially when we need to run just the test suite that is currently under development. This way, it runs faster because we don&#8217;t have to provision/deprovision the cloud infrastructure for other test suites. At the same time, we will also reduce the incurred cost.</p>



<h2 class="wp-block-heading">Run a Specific Test Suite with Finer Controls</h2>



<p>There are times where running <b>bundle exec kitchen test [INSTANCE_NAME]</b> is still very time consuming and expensive, especially when we try to debug any failed assertions or add a little assertions at a time.</p>



<p>To provision the infrastructure once, run the following command:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
bundle exec kitchen converge &#x5B;INSTANCE_NAME]    

# For example:-
bundle exec kitchen converge router-with-nat-local
</pre></div>


<p>To run the assertions, run the following command as many times as possible until all the assertions are implemented successfully:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
bundle exec kitchen verify &#x5B;INSTANCE_NAME]    

# For example:-
bundle exec kitchen verify router-with-nat-local
</pre></div>


<p>Finally, once the test suite is implemented properly, we can now deprovision the infrastructure:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
bundle exec kitchen destroy &#x5B;INSTANCE_NAME]    

# For example:-
bundle exec kitchen destroy router-with-nat-local
</pre></div><p>The post <a rel="nofollow" href="https://myshittycode.com/2020/01/23/kitchen-terraform-local-development-workflow/">GCP + Kitchen Terraform: Local Development Workflow</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2020/01/23/kitchen-terraform-local-development-workflow/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1123</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 using Disk

Served from: myshittycode.com @ 2026-02-21 16:32:42 by W3 Total Cache
-->