<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by MissInfoSec360 on Medium]]></title>
        <description><![CDATA[Stories by MissInfoSec360 on Medium]]></description>
        <link>https://medium.com/@InfoSecurity360?source=rss-e4bf73aea0fe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OM-_Ga0GpuUoOgLtDHlOPw.jpeg</url>
            <title>Stories by MissInfoSec360 on Medium</title>
            <link>https://medium.com/@InfoSecurity360?source=rss-e4bf73aea0fe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 21:38:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@InfoSecurity360/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Lab-Introduction to SQL for BigQuery and Cloud SQL]]></title>
            <link>https://medium.com/@InfoSecurity360/lab-introduction-to-sql-for-bigquery-and-cloud-sql-ac8109b69a29?source=rss-e4bf73aea0fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac8109b69a29</guid>
            <category><![CDATA[manage-cloud-environments]]></category>
            <category><![CDATA[sql-for-bigquery]]></category>
            <category><![CDATA[cloud-sql]]></category>
            <dc:creator><![CDATA[MissInfoSec360]]></dc:creator>
            <pubDate>Sat, 14 Jun 2025 23:03:09 GMT</pubDate>
            <atom:updated>2025-06-14T23:03:09.840Z</atom:updated>
            <content:encoded><![CDATA[<h4>Deploy and Manage Cloud Environments with Google Cloud</h4><h3>Task 1. Create a Cloud SQL instance</h3><p>In the console, select <strong>Navigation menu</strong> &gt; <strong>SQL</strong>.</p><ol><li>Click <strong>CREATE INSTANCE, </strong>instance id as <strong>qwiklabs-demo </strong>and a secure password.</li><li>Select the database version as <strong>MySQL v5.7</strong>.</li><li>Set the <strong>Multi zones (Highly available)</strong> field as “ style=”box-sizing: border-box;”&gt;us-central1</li><li>Click <strong>CREATE INSTANCE</strong>.</li></ol><h3>Task 2. Exploring the BigQuery console</h3><p><a href="https://cloud.google.com/bigquery/"><em>BigQuery</em></a><em> is a fully-managed petabyte-scale data warehouse that runs on the Google Cloud. Data analysts and data scientists can quickly query and filter large datasets, aggregate results, and perform complex operations without having to worry about setting up and managing servers.</em></p><ol><li>In the Google Cloud Console, select <strong>Navigation menu</strong> &gt; <strong>BigQuery</strong>.</li><li>Click on <strong>+ ADD DATA, and add </strong>project name as <strong>bigquery-public-dataP </strong>in a project popup and <strong>Pin</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gEcX1YHVontO0r8GAkLmMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gEcX1YHVontO0r8GAkLmMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S5ux95WM6yGPYQU_yTK0yA.png" /></figure><p>3. In the search bar, enter <strong>London bicycles to </strong>access to the following data:</p><ul><li>Google Cloud Project → bigquery-public-data</li><li>Dataset → london_bicycles</li></ul><p>4. Click on the <strong>london bicycles</strong> dataset to reveal the associated tables</p><ul><li>Table → cycle_hire</li><li>Table → cycle_stations</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O69KwtZs2RvOWB6m8TcbTg.png" /></figure><p>5. Running SELECT, FROM, and WHERE in BigQuery in the Editor:</p><pre>SELECT end_station_name FROM `bigquery-public-data.london_bicycles.cycle_hire`;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zbt-V7nU6sNA-JXt7FsEcQ.png" /></figure><p>6. Run the new query that utilizes the WHERE keyword:</p><pre>SELECT * FROM `bigquery-public-data.london_bicycles.cycle_hire` WHERE duration&gt;=1200;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Soy6N1Q5TB9YPMMGXQBQkw.png" /></figure><p>7. More SQL Keywords: GROUP BY, COUNT, AS, and ORDER BY.</p><pre>SELECT start_station_name FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7s1vBvMQXk4J-_oy9fPnjg.png" /></figure><p>8. Another COUNT query:</p><pre>SELECT start_station_name, COUNT(*) FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ttSMVDo3LXKgAgb8SVkkEw.png" /></figure><p>9. Add an AS keyword to the last query we ran to see this in action.</p><pre>SELECT start_station_name, COUNT(*) AS num_starts FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Bh9nC7Ajxok3OJARqGaEg.png" /></figure><p>10. The ORDER BY keyword sorts the returned data from a query in ascending or descending order based on a specified criteria or column value.</p><pre>SELECT start_station_name, COUNT(*) AS num FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name ORDER BY start_station_name;</pre><pre>SELECT start_station_name, COUNT(*) AS num FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name ORDER BY num;</pre><pre>SELECT start_station_name, COUNT(*) AS num FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name ORDER BY num DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I7nBaANm2VtMsdLQlRQsrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5aIl71mApxkAwGWiZiEoAA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NpsrBQeAqdVPXofCcvRsPg.png" /></figure><h3>Task 5. Working with Cloud SQL (Exporting queries as CSV files)</h3><p><a href="https://cloud.google.com/sql/">Cloud SQL</a> is a fully-managed database service that makes it easy to set up, maintain, manage, and administer your relational PostgreSQL and MySQL databases in the cloud. There are two formats of data accepted by Cloud SQL: dump files (.sql) or CSV files (.csv).</p><p>Back in the BigQuery Console, this should have been the last command that you ran:</p><pre>SELECT start_station_name, COUNT(*) AS num FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name ORDER BY num DESC;</pre><ol><li>In the Query Results section click <strong>SAVE RESULTS</strong> &gt; <strong>CSV(local file)</strong>. This initiates a download, which saves this query as a CSV file.</li><li>Clear the query EDITOR, then copy and run the following in the query editor:</li></ol><pre>SELECT end_station_name, COUNT(*) AS num FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY end_station_name ORDER BY num DESC;</pre><h3>Task 6. Upload CSV files to Cloud Storage</h3><ol><li>Go to the Cloud Console where you’ll create a storage bucket where you can upload the files you just created.</li><li>Select <strong>Navigation menu</strong> &gt; <strong>Cloud Storage</strong> &gt; <strong>Browser</strong>, and then click <strong>CREATE BUCKET</strong>.</li></ol><h3>Task 7. Create a database in Cloud Shell</h3><p>Now that you have a Cloud SQL instance up and running, create a database inside of it using the Cloud Shell Command Line. Copy the Cloud Shell link below and paste in a new browser incognito tab.</p><pre><a href="https://shell.cloud.google.com/?show=terminal">https://shell.cloud.google.com/?show=terminal</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KIawwPPSq7gQgSaCPPSfCQ.png" /></figure><ol><li>Run the following command in Cloud Shell to connect to your SQL instance, replacing qwiklabs-demo if you used a different name for your instance:</li></ol><pre>gcloud sql connect  qwiklabs-demo --user=root</pre><p>I encountered an error but got workaround it by setting project in config as:</p><pre>gcloud config set project qwiklabs-gcp-04–616a9fbe420e</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3JFe5GHGmsBppNElR-pl_w.png" /></figure><h3>Task 8. Create a table in Cloud Shell</h3><ol><li>Make a table inside of the bike database by running the following command:</li></ol><pre>USE bike;<br>CREATE TABLE london1 (start_station_name VARCHAR(255), num INT);</pre><p>This statement uses the CREATE keyword, but this time it uses the TABLE clause to specify that it wants to build a table instead of a database. The USE keyword specifies a database that you want to connect to. You now have a table named &quot;london1&quot; that contains two columns, &quot;start_station_name&quot; and &quot;num&quot;. VARCHAR(255) specifies variable length string column that can hold up to 255 characters and INT is a column of type integer.</p><p>Create another table named “london2” by running the following command:</p><pre>USE bike;<br>CREATE TABLE london2 (end_station_name VARCHAR(255), num INT);</pre><p>Now confirm that your empty tables were created. Run the following commands at the MySQL server prompt:</p><pre>SELECT * FROM london1;<br>SELECT * FROM london2;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eldse3o1vWcMpuP2vxwgyQ.png" /></figure><h3>Task 9. Upload CSV files to tables</h3><ol><li>In your Cloud SQL instance page, click <strong>IMPORT, Browse</strong>, <strong>Select</strong> bucket name, and then click start_station_data.csv.</li><li>Select <strong>CSV</strong> as File format, bike database and type in &quot;london1&quot; as your table and then <strong>Import</strong>:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*se6bBNOU-67tGF_rVlsSmA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac8109b69a29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lab-Multiple VPC Networks]]></title>
            <link>https://medium.com/@InfoSecurity360/lab-multiple-vpc-networks-4f0e0be778ee?source=rss-e4bf73aea0fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f0e0be778ee</guid>
            <category><![CDATA[vpc]]></category>
            <category><![CDATA[vpc-network]]></category>
            <category><![CDATA[multiple-vpc-networks]]></category>
            <dc:creator><![CDATA[MissInfoSec360]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 18:20:03 GMT</pubDate>
            <atom:updated>2025-06-12T18:20:03.803Z</atom:updated>
            <content:encoded><![CDATA[<h4>Set Up and Configure a Cloud Environment in Google Cloud</h4><p>In this lab you create several VPC networks and VM instances and test connectivity across networks. Specifically, you create two custom mode networks (<strong>managementnet</strong> and <strong>privatenet</strong>) with firewall rules and VM instances as shown in this network diagram.</p><p><em>(Note: The </em><strong><em>mynetwork</em></strong><em> network with its firewall rules and two VM instances (</em><strong><em>mynet-eu-vm</em></strong><em> and </em><strong><em>mynet-us-vm</em></strong><em>) have already been created for you in this Qwiklabs project.)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YkAAOSvtksjYRuJqBIymYA.png" /></figure><h3>Task 1: Create custom mode VPC networks with firewall rules</h3><p>Create the <strong>managementnet</strong> network using the Cloud Console.</p><ol><li>In the Cloud Console, navigate to <strong>Navigation menu</strong> () &gt; <strong>VPC network</strong> &gt; <strong>VPC networks</strong>.</li><li>Create the <strong>privatenet</strong> network using the Cloud Shell command line.</li></ol><pre>gcloud compute networks create privatenet --subnet-mode=custom</pre><p>3. Run the following command to create the <strong>privatesubnet-us</strong> subnet:</p><pre>gcloud compute networks subnets create privatesubnet-us --network=privatenet --region=us-east1 --range=172.16.0.0/24</pre><p>4. Run the following command to create the <strong>privatesubnet-eu</strong> subnet:</p><pre>gcloud compute networks subnets create privatesubnet-eu --network=privatenet --region=europe-west4 --range=172.20.0.0/20</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W3K5IT0zcNY2nq2JeXXglg.png" /></figure><p>5. Run the following command to list the available VPC networks:</p><pre>gcloud compute networks list</pre><p><strong><em>Note: default</em></strong><em> and </em><strong><em>mynetwork</em></strong><em> are auto mode networks, whereas, </em><strong><em>managementnet</em></strong><em> and </em><strong><em>privatenet</em></strong><em> are custom mode networks. Auto mode networks create subnets in each region automatically, while custom mode networks start with no subnets, giving you full control over subnet creation</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*dsJUIPx_6ytY989749e23w.png" /></figure><p>5. Run the following command to list the available VPC subnets (sorted by VPC network):</p><pre>gcloud compute networks subnets list --sort-by=NETWORK</pre><p><strong><em>Note: </em></strong><em>As expected, the </em><strong><em>default</em></strong><em> and </em><strong><em>mynetwork</em></strong><em> networks have subnets in </em><a href="https://cloud.google.com/compute/docs/regions-zones/#available"><em>each region</em></a><em> as they are auto mode networks. The </em><strong><em>managementnet</em></strong><em> and </em><strong><em>privatenet</em></strong><em> networks only have the subnets that you created as they are custom mode networks.</em></p><p>You can see results of the above command in console too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sjD5iA23X44WKEpiRzmgCQ.png" /></figure><p>6. Create firewall rules to allow <strong>SSH</strong>, <strong>ICMP</strong>, and <strong>RDP</strong> ingress traffic to VM instances on the <strong><em>managementnet</em></strong> network. In the Cloud Console, navigate to <strong>Navigation menu</strong>&gt; <strong>VPC network</strong> &gt; <strong>Firewall &gt;</strong> <strong>+ Create Firewall Rule</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*Kz1HAUxpYvrZ4HFFKibnMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*xL7lr4C4SG28mVup9cpXrg.png" /></figure><p>Now we create the <strong>privatenet-allow-icmp-ssh-rdp</strong> firewall rule for privatenet network as follows:</p><pre>gcloud compute firewall-rules create privatenet-allow-icmp-ssh-rdp --direction=INGRESS --priority=1000 --network=privatenet --action=ALLOW --rules=icmp,tcp:22,tcp:3389 --source-ranges=0.0.0.0/0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fNCFpXQd4v0CGvE1T4IgkA.png" /></figure><pre>gcloud compute firewall-rules list --sort-by=NETWORK</pre><p>The output should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L7OPhP5vfoDEghLy5F_T2g.png" /></figure><h3>Task 2. Create two VM instances</h3><ul><li><strong>privatenet-us-vm</strong> in <strong>privatesubnet-us</strong></li></ul><ol><li>In the Cloud Console, navigate to <strong>Navigation menu</strong> &gt; <strong>Compute Engine</strong> &gt; <strong>VM instances &gt;</strong>Create the <strong>managementnet-us-vm. <br></strong><em>The </em><strong><em>mynet-eu-vm</em></strong><em> and </em><strong><em>mynet-us-vm</em></strong><em> has been created for you, as part of your network diagram.</em></li><li>In Cloud Shell, run the following command to create the <strong>privatenet-us-vm</strong> instance:</li></ol><pre>gcloud compute instances create privatenet-us-vm --zone=&quot;us-east1-b&quot; --machine-type=e2-micro --subnet=privatesubnet-us</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*deU3ZGQc9AHgkTSiM8GA6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t9DdBuoLWJfxmPU0MYyszw.png" /></figure><h3>Task 3. Explore the connectivity between VM instances — Ping external IP addresses</h3><p>Note the exeternal IPs of the VMs:</p><p><a href="https://console.cloud.google.com/compute/instancesDetail/zones/us-east1-b/instances/managementnet-us-vm?project=qwiklabs-gcp-04-c6d4803ceb78&amp;supportedpurview=project">managementnet-us-vm</a>: 34.138.75.108<br><a href="https://console.cloud.google.com/compute/instancesDetail/zones/europe-west4-c/instances/mynet-eu-vm?project=qwiklabs-gcp-04-c6d4803ceb78&amp;supportedpurview=project">mynet-eu-vm</a>: 34.141.159.123<br><a href="https://console.cloud.google.com/compute/instancesDetail/zones/us-east1-b/instances/mynet-us-vm?project=qwiklabs-gcp-04-c6d4803ceb78&amp;supportedpurview=project">mynet-us-vm</a>: 35.196.146.207<br><a href="https://console.cloud.google.com/compute/instancesDetail/zones/us-east1-b/instances/privatenet-us-vm?project=qwiklabs-gcp-04-c6d4803ceb78&amp;supportedpurview=project">privatenet-us-vm</a>: 104.196.215.156</p><ol><li>For <strong>mynet-us-vm</strong>, click <strong>SSH</strong> to launch a terminal and connect. To test connectivity to <strong>mynet-eu-vm</strong>’s external IP, run the following command, replacing <strong>mynet-eu-vm</strong>’s external IP (on terminal of <strong>mynet-eu-vm</strong>):</li><li>ping -c 3 &lt;Enter mynet-eu-vm’s external IP here&gt;.<br>Repeat step 2 to for <a href="https://console.cloud.google.com/compute/instancesDetail/zones/us-east1-b/instances/managementnet-us-vm?project=qwiklabs-gcp-04-c6d4803ceb78&amp;supportedpurview=project">managementnet-us-vm</a> and <a href="https://console.cloud.google.com/compute/instancesDetail/zones/us-east1-b/instances/privatenet-us-vm?project=qwiklabs-gcp-04-c6d4803ceb78&amp;supportedpurview=project">privatenet-us-vm</a>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6_IyO4kAud86iUn8kQLw4Q.png" /></figure><p><strong><em>Note: </em></strong><em>You are able to ping the external IP address of all VM instances, even though they are either in a different zone or VPC network. This confirms public access to those instances is only controlled by the </em><strong><em>ICMP</em></strong><em> firewall rules that you established earlier.</em></p><h3>Task 4. . Explore the connectivity between VM instances — Ping internal Ip addresses</h3><p>1. Ping the internal IP addresses. <strong>SSH</strong> terminal for <strong>mynet-us-vm and </strong>test connectivity to <strong>mynet-eu-vm</strong>’s internal IP, run the following command, replacing <strong>mynet-eu-vm</strong>’s internal IP:</p><pre>ping -c 3 &lt;Enter mynet-eu-vm&#39;s internal IP here&gt;</pre><p><strong><em>Note: </em></strong><em>You are able to ping the internal IP address of </em><strong><em>mynet-eu-vm</em></strong><em> because it is on the same VPC network as the source of the ping (</em><strong><em>mynet-us-vm</em></strong><em>), even though both VM instances are in separate zones, regions and continents!</em></p><p><a href="https://console.cloud.google.com/compute/instancesDetail/zones/us-east1-b/instances/managementnet-us-vm?project=qwiklabs-gcp-04-c6d4803ceb78&amp;supportedpurview=project">managementnet-us-vm</a>: 10.130.0.2<br><a href="https://console.cloud.google.com/compute/instancesDetail/zones/europe-west4-c/instances/mynet-eu-vm?project=qwiklabs-gcp-04-c6d4803ceb78&amp;supportedpurview=project">mynet-eu-vm</a>: 10.164.0.2<br><a href="https://console.cloud.google.com/compute/instancesDetail/zones/us-east1-b/instances/mynet-us-vm?project=qwiklabs-gcp-04-c6d4803ceb78&amp;supportedpurview=project">mynet-us-vm</a>: 10.142.0.2<br><a href="https://console.cloud.google.com/compute/instancesDetail/zones/us-east1-b/instances/privatenet-us-vm?project=qwiklabs-gcp-04-c6d4803ceb78&amp;supportedpurview=project">privatenet-us-vm</a>:172.16.0.2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*-jW1J_Cpmv4Xuw1cE-Kh5Q.png" /></figure><h3>Task 4. Create a VM instance with multiple network interfaces</h3><p><em>Every instance in a VPC network has a default network interface. You can create additional network interfaces attached to your VMs. Multiple network interfaces enable you to create configurations in which an instance connects directly to several VPC networks (up to 8 interfaces, depending on the instance’s type).</em></p><ol><li>In the Cloud Console, navigate to <strong>Navigation menu</strong> &gt; <strong>Compute Engine</strong> &gt; <strong>VM instances &gt;</strong> <strong>Create instance “</strong>vm-appliance<strong>” (</strong>us-east1 region/us-east1-b zone/E2 Series/e2-standard-4 machine type<strong>)</strong></li></ol><p>Task 5: Explore the network interface details</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tEHSf_yzBO48-fi_dE014g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f0e0be778ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lab-Google Cloud Pub/Sub: Qwik Start — Console]]></title>
            <link>https://medium.com/@InfoSecurity360/lab-google-cloud-pub-sub-qwik-start-console-2e295fbb1707?source=rss-e4bf73aea0fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e295fbb1707</guid>
            <category><![CDATA[qwik-start]]></category>
            <category><![CDATA[pub-sub]]></category>
            <category><![CDATA[google-cloud]]></category>
            <dc:creator><![CDATA[MissInfoSec360]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 18:19:40 GMT</pubDate>
            <atom:updated>2025-06-12T18:19:40.937Z</atom:updated>
            <content:encoded><![CDATA[<h3>Lab-Google Cloud Pub/Sub: Qwik Start — Console</h3><h4>Perform Foundational Infrastructure Tasks in Google Cloud</h4><p><em>Google Cloud Pub/Sub is a messaging service for exchanging event data among applications and services. A producer of data publishes messages to a Cloud Pub/Sub topic. A consumer creates a subscription to that topic. Subscribers either pull messages from a subscription or are configured as </em><strong><em>webhooks</em></strong><em> for push subscriptions. Every subscriber must acknowledge each message within a configurable window of time.<br>Cloud Pub/Sub is an asynchronous messaging service designed to be highly reliable and scalable.</em></p><h3>Task 1. Setting up Pub/Sub</h3><ol><li>Firstly, we create a topic to hold data and a subscription to access data published to the topic.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fkK6fhywausx8I7d6PlBnw.png" /><figcaption><strong>Navigation menu</strong> () &gt; <strong>Pub/Sub</strong> &gt; <strong>Topics</strong></figcaption></figure><p>2. <strong>Create a topic</strong> dialog with a unique name. For this lab, name your topic MyTopic and default value for other fields.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NOuG1VEFJCAEyvPulxtBrg.png" /></figure><h3>Task 2. Add a subscription</h3><ol><li><strong>Create subscription</strong> by going to the list of topics page<strong>, and </strong>click the three dot icon.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dqf1WtK99XTTVZRNPEeCUw.png" /></figure><p>2. <strong>Add subscription to topic</strong> dialog, as <strong>MySub, </strong>Delivery Type to <strong>Pull </strong>and<strong> </strong>other fields as<strong> </strong>default values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*ZqLRMurhueMMw-fNET0XJw.png" /></figure><h3>Task 4. Publish a message to the topic</h3><ol><li>Go to <strong>MyTopic</strong>, click <strong>Messages</strong> tab and then click <strong>Publish Message</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PTHXlcTd4AXB09-rpKekDQ.png" /></figure><p>2. Enter Hello World in the <strong>Message</strong> field and click <strong>Publish</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hP3NhxM7nVetssPKnM-RNA.png" /></figure><h3>Task 5. View the message</h3><p>To view the message you’ll use the subscription (MySub) to pull the message (Hello World) from the topic (MyTopic).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Asxoiq2AETJVAEpRiPeeFw.png" /><figcaption>Message appears in the DATA field</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e295fbb1707" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lab-Managing Deployments Using Kubernetes Engine]]></title>
            <link>https://medium.com/@InfoSecurity360/lab-managing-deployments-using-kubernetes-engine-bb7a695c42e9?source=rss-e4bf73aea0fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb7a695c42e9</guid>
            <category><![CDATA[kubernetes-engine]]></category>
            <category><![CDATA[managing-deployments]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[MissInfoSec360]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 18:18:57 GMT</pubDate>
            <atom:updated>2025-06-12T18:18:57.330Z</atom:updated>
            <content:encoded><![CDATA[<h4>Set Up and Configure a Cloud Environment in Google Cloud</h4><p><em>Kubernetes is the most popular container orchestration system, and Google Kubernetes Engine was designed specifically to support managed Kubernetes deployments in Google Cloud.</em></p><ol><li>Get the sample code for creating and running containers and deployments:</li></ol><pre>gsutil -m cp -r gs://spls/gsp053/orchestrate-with-kubernetes .<br>cd orchestrate-with-kubernetes/kubernetes</pre><p>2. Create a cluster with five n1-standard-1 nodes (<em>this will take a few minutes to complete</em>):</p><pre>gcloud container clusters create bootcamp --num-nodes 5 --scopes &quot;https://www.googleapis.com/auth/projecthosting,storage-rw&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SWhZP5m6RKvmi5P1StJ21g.png" /></figure><p>3. Look at the Deployment object, where the explain command in kubectl can tell us about the Deployment object. We can also see all of the fields using the --recursive option.</p><pre>kubectl explain deployment<br>kubectl explain deployment --recursive<br>kubectl explain deployment.metadata.name</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YndYLDWOX4beErl4izYgkQ.png" /></figure><h3>Task 2. Create a deployment</h3><ol><li>Update the deployments/auth.yaml configuration file:</li></ol><pre>vi deployments/auth.yaml</pre><p>2. Change the image in the containers section of the Deployment to the following and save the auth.yaml file:</p><pre>...<br>containers:<br>- name: auth<br>  image: &quot;kelseyhightower/auth:1.0.0&quot;<br>...</pre><p>Examine the deployment configuration file:</p><pre>cat deployments/auth.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tSedccMvPM87b0ghquefcQ.png" /></figure><p><em>When you run the </em><em>kubectl create command to create the auth deployment, it will make one pod that conforms to the data in the Deployment manifest. This means we can scale the number of Pods by changing the number specified in the </em><em>replicas field.</em></p><p>3. Go ahead and create your deployment object using kubectl create and verify deployments created:</p><pre>kubectl create -f deployments/auth.yaml</pre><p>Once the deployment is created, Kubernetes will create a ReplicaSet and Pods for the Deployment. Check them here:</p><pre>kubectl get deployments<br>kubectl get replicasets<br>kubectl get pods</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAElW-AjT1OJOt5nfkCvJQ.png" /></figure><p>4. It’s time to create a service for our auth deployment. Use the kubectl create command to create the auth service.</p><pre>kubectl create -f services/auth.yaml</pre><p>Now, do the same thing to create and expose the hello Deployment.</p><pre>kubectl create -f deployments/hello.yaml<br>kubectl create -f services/hello.yaml</pre><p>And one more time to create and expose the frontend Deployment.</p><pre>kubectl create secret generic tls-certs --from-file tls/<br>kubectl create configmap nginx-frontend-conf --from-file=nginx/frontend.conf<br>kubectl create -f deployments/frontend.yaml<br>kubectl create -f services/frontend.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YbGAzMxkNIzYw-bnMetJSg.png" /><figcaption><strong>Note:</strong> You created a ConfigMap for the frontend.</figcaption></figure><p>Interact with the frontend by grabbing its external IP and then curling to it.</p><pre>kubectl get services frontend<br>curl -ks https://&lt;EXTERNAL-IP&gt;<br><strong><em>or</em></strong> <br>curl -ks <a href="https://`kubectl/">https://`kubectl</a> get svc frontend -o=jsonpath=&quot;{.status.loadBalancer.ingress[0].ip}&quot;`</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zxU-dABATjSPsW8DC__Caw.png" /></figure><h3>Task 3. Scale a Deployment</h3><p>We can scale by updatingspec.replicas field we see in output ofkubectl explain. Kubernetes will automatically update the associated ReplicaSet and start new Pods.</p><pre>kubectl explain deployment.spec.replicas<br>kubectl scale deployment hello --replicas=5<br>kubectl get pods | grep hello- | wc -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3FrZ4-i92_NGIlBbLW8quA.png" /></figure><h3>Task 4. Rolling update</h3><p>Deployments support updating images to a new version through a rolling update mechanism. When a Deployment is updated with a new version, it creates a new ReplicaSet and slowly increases the number of replicas in the new ReplicaSet as it decreases the replicas in the old ReplicaSet.</p><ol><li>To update your Deployment, run the following command:</li></ol><pre>kubectl edit deployment hello</pre><p>Change the image in the containers section of the Deployment to the following:</p><pre><em>...<br>containers:<br>  image: kelseyhightower/hello:2.0.0<br>...</em></pre><p>2. See the new ReplicaSet that Kubernetes creates, and rollout history.:</p><pre>kubectl get replicaset<br>kubectl rollout history deployment/hello</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R2JwS54yYjmjRyWHj2bfMg.png" /></figure><p>3. If you detect problems with a running rollout, pause and later resume it. kubectl rollout pause deployment/hello and verify the current state of the rollout and Pods:</p><pre>kubectl rollout pause deployment/hello<br>kubectl rollout status deployment/hello</pre><pre>kubectl get pods -o jsonpath --template=&#39;{range .items[*]}{.metadata.name}{&quot;\t&quot;}{&quot;\t&quot;}{.spec.containers[0].image}{&quot;\n&quot;}{end}&#39;content_copy</pre><pre>kubectl rollout resume deployment/hello<br>kubectl rollout status deployment/hello</pre><pre>kubectl rollout undo deployment/hello<br>kubectl rollout history deployment/hello</pre><pre>kubectl get pods -o jsonpath --template=&#39;{range .items[*]}{.metadata.name}{&quot;\t&quot;}{&quot;\t&quot;}{.spec.containers[0].image}{&quot;\n&quot;}{end}&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o56ab9KER3HzmPSW0GW9hg.png" /></figure><h3>Task 5. Canary deployments</h3><p>When you want to test a new deployment in production with a subset of your users, use a canary deployment. Canary deployments allow you to release a change to a small subset of your users to mitigate risk associated with new releases.</p><p>First, create a new canary deployment for the new version and verify if you now have two deployments hello and hello-canary. Also, verify the hello version being served by the request:</p><pre>cat deployments/hello-canary.yaml<br>kubectl create -f deployments/hello-canary.yaml<br>kubectl get deployments<br>curl -ks <a href="https://`kubectl/">https://`kubectl</a> get svc frontend -o=jsonpath=&quot;{.status.loadBalancer.ingress[0].ip}&quot;`/version</pre><p>On the hello service, the selector uses the app:hello selector which will match pods in <strong>both</strong> the prod deployment and canary deployment. However, because the canary deployment has a fewer number of pods, it will be visible to fewer users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb7a695c42e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lab- Interact with Terraform Modules]]></title>
            <link>https://medium.com/@InfoSecurity360/lab-interact-with-terraform-modules-c66188888566?source=rss-e4bf73aea0fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/c66188888566</guid>
            <category><![CDATA[terraform-modules]]></category>
            <category><![CDATA[interact-terraform-module]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[MissInfoSec360]]></dc:creator>
            <pubDate>Sun, 08 Jun 2025 15:57:31 GMT</pubDate>
            <atom:updated>2025-06-08T15:57:31.523Z</atom:updated>
            <content:encoded><![CDATA[<h4>Automating Infrastructure on Google Cloud with Terraform</h4><p>Here are some of the ways that modules help solve the problems listed above:</p><ul><li><strong>Organize configuration:</strong> Modules make it easier to navigate, understand, and update your configuration by keeping related parts of your configuration together.</li><li><strong>Encapsulate configuration:</strong> It encapsulates configuration into distinct logical components, which help prevent unintended consequences — such as a change to one part of your configuration accidentally causing changes to other infrastructure — and reduce the chances of simple errors like using the same name for two different resources.</li><li><strong>Re-use configuration:</strong> Writing all of your configuration without using existing code can be time-consuming and error-prone.</li><li><strong>Provide consistency and ensure best practices:</strong> Modules also help to provide consistency in your configurations. For example, cloud providers offer many options for configuring object storage services, such as Amazon S3 (Simple Storage Service) or Google’s Cloud Storage buckets.</li></ul><p><em>A </em><strong><em>Terraform module</em></strong><em> is a set of Terraform configuration files in a single directory. Even a simple configuration consisting of a single directory with one or more </em><em>.tf files is a module. When you run Terraform commands directly from such a directory, it is considered the </em><strong><em>root module</em></strong><em>. So in this sense, every Terraform configuration is part of a module.</em></p><p><strong>Calling modules:</strong> Terraform commands will only directly use the configuration files in one directory, which is usually the current working directory. However, your configuration can use module blocks to call modules in other directories. When Terraform encounters a module block, it loads and processes that module’s configuration files.</p><p>A module that is called by another configuration is sometimes referred to as a “child module” of that configuration.</p><p><strong>Local and remote modules:</strong> Modules can be loaded from either the local filesystem or a remote source. Terraform supports a variety of remote sources, including the Terraform Registry, most version control systems, HTTP URLs, and Terraform Cloud or Terraform Enterprise private module registries.</p><h3>Task 1. Use modules from the Registry</h3><ol><li>Copy the files over to the bucket, replacing YOUR-BUCKET-NAME with the name of your storage bucket:</li></ol><pre>gsutil cp *.html gs://YOUR-BUCKET-NAME</pre><ol><li>In a new tab in your browser, go to the website https://storage.cloud.google.com/YOUR-BUCKET-NAME/index.html, replacing YOUR-BUCKET-NAME with the name of your storage bucket.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mgB8iTuuZdZaJFXRK0uFBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRERav02Z3MA7cRzJOb7KA.png" /></figure><ul><li>Destroy your Terraform resources:</li></ul><pre>terraform destroy</pre><p>After you respond to the prompt with yes, Terraform will destroy all of the resources you created by following this lab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kx7Iv-8W_mqUVcLHcwWbTw.png" /></figure><p>RE-DO this</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c66188888566" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lab- Infrastructure as Code with Terraform]]></title>
            <link>https://medium.com/@InfoSecurity360/lab-infrastructure-as-code-with-terraform-ac9cfe1ee6d8?source=rss-e4bf73aea0fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac9cfe1ee6d8</guid>
            <category><![CDATA[iac]]></category>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <dc:creator><![CDATA[MissInfoSec360]]></dc:creator>
            <pubDate>Sun, 08 Jun 2025 15:56:28 GMT</pubDate>
            <atom:updated>2025-06-08T15:56:28.826Z</atom:updated>
            <content:encoded><![CDATA[<h4>Automating Infrastructure on Google Cloud with Terraform</h4><h3>Task 1. Build infrastructure</h3><ol><li>Start by creating your example configuration to a file named main.tf.<br>Create the main.tf file:</li></ol><pre>touch main.tf</pre><p>2. Click the <strong>Open Editor</strong> button on the toolbar of Cloud Shell, add the following content to the main.tf file, and replace &lt;PROJECT_ID&gt; with the lab&#39;s Project ID:<br>&lt;PROJECT_ID&gt; with the lab&#39;s Project ID:</p><pre>terraform {<br>  required_providers {<br>    google = {<br>      source = &quot;hashicorp/google&quot;<br>    }<br>  }<br>}<br>provider &quot;google&quot; {<br>  version = &quot;3.5.0&quot;<br>  project = &quot;&lt;PROJECT_ID&gt;&quot;<br>  region  = &quot;us-central1&quot;<br>  zone    = &quot;us-central1-c&quot;<br>}<br>resource &quot;google_compute_network&quot; &quot;vpc_network&quot; {<br>  name = &quot;terraform-network&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PHaHDJjKsM3uN9_ce1C40g.png" /><figcaption>Add project id</figcaption></figure><p><strong>Terraform Block</strong>: The terraform {} block is required so Terraform knows which provider to download from the <a href="https://registry.terraform.io/">Terraform Registry</a>. In the configuration above, the google provider&#39;s source is defined as hashicorp/google which is shorthand for registry.terraform.io/hashicorp/google. You can also assign a version to each provider defined in the required_providers block.</p><p><strong>Provider</strong>: The provider block is used to configure the named provider, in this case google. A provider is responsible for creating and managing resources. Multiple provider blocks can exist if a Terraform configuration manages resources from different providers.</p><ul><li>Initialize:</li></ul><pre>terraform init</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*70BEQPyb6Osh7qIhFfgTpA.png" /></figure><ul><li>Create resources:</li></ul><pre>terraform apply</pre><ul><li>Verify<strong>:<br></strong>Goto<strong> Navigation menu &gt; VPC network</strong>. You will see the terraform-network has been provisioned.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b24R31TmjwXkYUld" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4bFOzKj0BF-NwZQ37ONp9Q.png" /></figure><ul><li>Check the state:</li></ul><pre>terraform show</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*144la7z4fl4_6Bv8a6lNkg.png" /></figure><h3>Task 2. Change infrastructure</h3><ol><li>Adding resources: add a compute instance resource to main.tf:</li></ol><pre>resource &quot;google_compute_instance&quot; &quot;vm_instance&quot; {<br>  name         = &quot;terraform-instance&quot;<br>  machine_type = &quot;f1-micro&quot;<br>  boot_disk {<br>    initialize_params {<br>      image = &quot;debian-cloud/debian-10&quot;<br>    }<br>  }<br>  network_interface {<br>    network = google_compute_network.vpc_network.name<br>    access_config {<br>    }<br>  }<br>}</pre><p>This resource includes a few more arguments:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TJhHmmwa7FplMW2doIRYrg.png" /></figure><p>2. Create the compute instance:</p><pre>terraform apply</pre><p>In addition to creating resources, Terraform can also make changes to those resources.</p><p>a. Add a tags argument to your &quot;vm_instance&quot; so that it looks like this:</p><pre>resource &quot;google_compute_instance&quot; &quot;vm_instance&quot; {<br>  name         = &quot;terraform-instance&quot;<br>  machine_type = &quot;f1-micro&quot;<br>  tags         = [&quot;web&quot;, &quot;dev&quot;]<br>  # ...<br>}</pre><p>b. Run terraform apply again to update the instance:</p><pre>terraform apply</pre><p><em>The prefix </em><em>~ means that Terraform will update the resource in-place. You can go and apply this change now by responding </em><em>yes, and Terraform will add the tags to your instance.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AA2lVbqR1SonIDLdhhXt2A.png" /></figure><h3>Task 3: Destruction</h3><ol><li>Edit the boot_disk block inside the vm_instance resource in your configuration file and change it to the following:</li></ol><pre>boot_disk {<br>    initialize_params {<br>      image = &quot;cos-cloud/cos-stable&quot;<br>    }<br>  }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mrpyeGcAlkL_SeesWRc44A.png" /></figure><p>2. Now run terraform apply again to see how Terraform will apply this change to the existing resources:</p><pre>resource &quot;google_compute_instance&quot; &quot;vm_instance&quot; {</pre><pre>name         = &quot;terraform-instance&quot;</pre><pre>machine_type = &quot;f1-micro&quot;</pre><pre>tags         = [&quot;web&quot;, &quot;dev&quot;]</pre><pre>boot_disk {</pre><pre>initialize_params {</pre><pre>image = &quot;cos-cloud/cos-stable&quot;</pre><pre>}</pre><pre>}</pre><p>We found error with the image = “cos-cloud/cos-stable” so replaced it with image = “cos-cloud/cos-dev” and then it worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Aa7ajakqCAInbjkLf15LQ.png" /></figure><p>3. Try the terraform destroy command. Answer yes to execute this plan and destroy the infrastructure:</p><pre>terraform destroy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Tcbhgz2yLNmHBvAIoCxlw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6fuSI7_B4LG5BnqKV9vQ0A.png" /></figure><h3>Task 4: Assigning a static IP address</h3><ol><li>Now add to your configuration by assigning a static IP to the VM instance in main.tf:</li></ol><pre>resource &quot;google_compute_address&quot; &quot;vm_static_ip&quot; {<br>  name = &quot;terraform-static-ip&quot;<br>}</pre><p>This should look familiar from the earlier example of adding a VM instance resource, except this time you’re creating a “google_compute_address” resource type. This resource type allocates a reserved IP address to your project.</p><ol><li>Next, run terraform plan:</li></ol><pre>terraform plan</pre><p>REDO this….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac9cfe1ee6d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lab-Terraform Fundamentals]]></title>
            <link>https://medium.com/@InfoSecurity360/lab-terraform-fundamentals-1fa2192aa49c?source=rss-e4bf73aea0fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fa2192aa49c</guid>
            <dc:creator><![CDATA[MissInfoSec360]]></dc:creator>
            <pubDate>Sun, 08 Jun 2025 15:55:58 GMT</pubDate>
            <atom:updated>2025-06-08T15:55:58.739Z</atom:updated>
            <content:encoded><![CDATA[<h4>Automating Infrastructure on Google Cloud with Terraform</h4><h3>Background</h3><p><em>Terraform enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files (using HashiCorp Configuration Language, or optionally JSON) that can be shared among co-workers, treated as code, edited, reviewed, and versioned.</em></p><p><em>Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Configuration files describe to Terraform the components needed to run a single application or your entire data center. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform can determine what changed and create incremental execution plans that can be applied. The infrastructure Terraform can manage includes both low-level components such as compute instances, storage, and networking, and high-level components such as DNS entries and SaaS features.</em></p><p>Infrastructure as code is the process of managing infrastructure in a file or files rather than manually configuring resources in a user interface. A resource in this instance is any piece of infrastructure in a given environment, such as a virtual machine, security group, network interface, etc. At a high level, Terraform allows operators to use HCL to author files containing definitions of their desired resources on almost any provider (AWS, Google Cloud, GitHub, Docker, etc.) and automates the creation of those resources at the time of apply. <br>A simple workflow for deployment will follow closely to the steps below:</p><ul><li><strong>Scope</strong> — Confirm what resources need to be created for a given project.</li><li><strong>Author</strong> — Create the configuration file in HCL based on the scoped parameters.</li><li><strong>Initialize</strong> — Run terraform init in the project directory with the configuration files. This will download the correct provider plug-ins for the project.</li><li><strong>Plan &amp; Apply</strong> — Run terraform plan to verify creation process and then terraform apply to create real resources as well as the state file that compares future changes in your configuration files to what actually exists in your deployment environment.</li></ul><h3>Task 1. Verifying Terraform installation</h3><ul><li>Open a new Cloud Shell tab, and verify that Terraform is available:</li></ul><pre>terraform</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CpCfq26zjTjF2BIsFTBcoQ.png" /><figcaption>Output of Task 1</figcaption></figure><h3>Task 2. Build infrastructure</h3><p>The set of files used to describe infrastructure in Terraform is known as a Terraform configuration.</p><ol><li>First, we write a configuration to launch a single VM instance.</li></ol><pre>touch instance.tf</pre><p>2. Click <strong>Open Editor</strong> on the Cloud Shell toolbar, and open new window, then select the instance.tf file and add the following content in it, replacing &lt;PROJECT_ID&gt; with your Google Cloud project ID:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lOo1pKNBXnG7plcY9Sh2mQ.png" /></figure><p>3. Now, verify that your new file has been added and that there are no other *.tf files in your directory, because Terraform loads all of them</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wvfe3H3MreXcdo-_E3qMZg.png" /></figure><p>4. The first command to run for a new configuration is terraform init.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0SAnbI67a6Lnh1PAuiMeXA.png" /><figcaption>Output of Initialization command</figcaption></figure><p>5. Create an execution plan:</p><p><em>Terraform performs a refresh, unless explicitly disabled, and then determines what actions are necessary to achieve the desired state specified in the configuration files. This command is a convenient way to check whether the execution plan for a set of changes matches your expectations without making any changes to real resources or to the state. For example, you might run this command before committing a change to version control, to create confidence that it will behave as expected.</em></p><pre>terraform plan</pre><p>The output is :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ncmxOI5vIq3SFDwzQCLwSQ.png" /><figcaption>Screenshot of “<em>terraform plan”</em></figcaption></figure><p>Below is the output information in details:</p><pre>student_00_7da664cb1588@cloudshell:~ (qwiklabs-gcp-03-4007b62a921c)$ terraform plan</pre><pre>Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:<br>  + create</pre><pre>Terraform will perform the following actions:</pre><pre># google_compute_instance.terraform will be created<br>  + resource &quot;google_compute_instance&quot; &quot;terraform&quot; {<br>      + can_ip_forward       = false<br>      + cpu_platform         = (known after apply)<br>      + current_status       = (known after apply)<br>      + deletion_protection  = false<br>      + guest_accelerator    = (known after apply)<br>      + id                   = (known after apply)<br>      + instance_id          = (known after apply)<br>      + label_fingerprint    = (known after apply)<br>      + machine_type         = &quot;n1-standard-1&quot;<br>      + metadata_fingerprint = (known after apply)<br>      + min_cpu_platform     = (known after apply)<br>      + name                 = &quot;terraform&quot;<br>      + project              = &quot;qwiklabs-gcp-03-4007b62a921c&quot;<br>      + self_link            = (known after apply)<br>      + tags_fingerprint     = (known after apply)<br>      + zone                 = &quot;us-west1-c&quot;</pre><pre>+ boot_disk {<br>          + auto_delete                = true<br>          + device_name                = (known after apply)<br>          + disk_encryption_key_sha256 = (known after apply)<br>          + kms_key_self_link          = (known after apply)<br>          + mode                       = &quot;READ_WRITE&quot;<br>          + source                     = (known after apply)</pre><pre>+ initialize_params {<br>              + image  = &quot;debian-cloud/debian-9&quot;<br>              + labels = (known after apply)<br>              + size   = (known after apply)<br>              + type   = (known after apply)<br>            }<br>        }</pre><pre>+ confidential_instance_config {<br>          + enable_confidential_compute = (known after apply)<br>        }</pre><pre>+ network_interface {<br>          + ipv6_access_type   = (known after apply)<br>          + name               = (known after apply)<br>          + network            = &quot;default&quot;<br>          + network_ip         = (known after apply)<br>          + stack_type         = (known after apply)<br>          + subnetwork         = (known after apply)<br>          + subnetwork_project = (known after apply)</pre><pre>+ access_config {<br>              + nat_ip       = (known after apply)<br>              + network_tier = (known after apply)<br>            }<br>        }</pre><pre>+ reservation_affinity {<br>          + type = (known after apply)</pre><pre>+ specific_reservation {<br>              + key    = (known after apply)<br>              + values = (known after apply)<br>            }<br>        }</pre><pre>+ scheduling {<br>          + automatic_restart           = (known after apply)<br>          + instance_termination_action = (known after apply)<br>          + min_node_cpus               = (known after apply)<br>          + on_host_maintenance         = (known after apply)<br>          + preemptible                 = (known after apply)<br>          + provisioning_model          = (known after apply)</pre><pre>+ node_affinities {<br>              + key      = (known after apply)<br>              + operator = (known after apply)<br>              + values   = (known after apply)<br>            }<br>        }<br>    }</pre><pre>Plan: 1 to add, 0 to change, 0 to destroy.</pre><pre>────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</pre><pre>Note: You didn&#39;t use the -out option to save this plan, so Terraform can&#39;t guarantee to take exactly these actions if you run &quot;terraform apply&quot; now.<br>student_00_7da664cb1588@cloudshell:~ (qwiklabs-gcp-03-4007b62a921c)$</pre><p>6. In the same directory as the instance.tf file you created, run this command:</p><pre>terraform apply</pre><p>This output shows the Execution Plan, which describes the actions Terraform will take in order to change real infrastructure to match the configuration. The output format is similar to the <strong>diff format generated by tools like Git.</strong></p><p>There is a + next to google_compute_instance.terraform, which means that Terraform will create this resource. Following that are the attributes that will be set. When the value displayed is &lt;computed&gt;, it means that the value won&#39;t be known until the resource is created.</p><p>There was an error creating VM instance debian-9 mentioned in intance.tf, so made edits to use debian-10 image instead and execute command again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VfX_qTGuYUzA0I7ArCHveg.png" /><figcaption>Edit to use available debian-10 image</figcaption></figure><pre>student_00_7da664cb1588@cloudshell:~ (qwiklabs-gcp-03-4007b62a921c)$ terraform apply</pre><pre>Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:<br>  + create</pre><pre>Terraform will perform the following actions:</pre><pre># google_compute_instance.terraform will be created<br>  + resource &quot;google_compute_instance&quot; &quot;terraform&quot; {<br>      + can_ip_forward       = false<br>      + cpu_platform         = (known after apply)<br>      + current_status       = (known after apply)<br>      + deletion_protection  = false<br>      + guest_accelerator    = (known after apply)<br>      + id                   = (known after apply)<br>      + instance_id          = (known after apply)<br>      + label_fingerprint    = (known after apply)<br>      + machine_type         = &quot;n1-standard-1&quot;<br>      + metadata_fingerprint = (known after apply)<br>      + min_cpu_platform     = (known after apply)<br>      + name                 = &quot;terraform&quot;<br>      + project              = &quot;qwiklabs-gcp-03-4007b62a921c&quot;<br>      + self_link            = (known after apply)<br>      + tags_fingerprint     = (known after apply)<br>      + zone                 = &quot;us-west1-c&quot;</pre><pre>+ boot_disk {<br>          + auto_delete                = true<br>          + device_name                = (known after apply)<br>          + disk_encryption_key_sha256 = (known after apply)<br>          + kms_key_self_link          = (known after apply)<br>          + mode                       = &quot;READ_WRITE&quot;<br>          + source                     = (known after apply)</pre><pre>+ initialize_params {<br>              + image  = &quot;debian-cloud/debian-10&quot;<br>              + labels = (known after apply)<br>              + size   = (known after apply)<br>              + type   = (known after apply)<br>            }<br>        }</pre><pre>+ confidential_instance_config {<br>          + enable_confidential_compute = (known after apply)<br>        }</pre><pre>+ network_interface {<br>          + ipv6_access_type   = (known after apply)<br>          + name               = (known after apply)<br>          + network            = &quot;default&quot;<br>          + network_ip         = (known after apply)<br>          + stack_type         = (known after apply)<br>          + subnetwork         = (known after apply)<br>          + subnetwork_project = (known after apply)</pre><pre>+ access_config {<br>              + nat_ip       = (known after apply)<br>              + network_tier = (known after apply)<br>            }<br>        }</pre><pre>+ reservation_affinity {<br>          + type = (known after apply)</pre><pre>+ specific_reservation {<br>              + key    = (known after apply)<br>              + values = (known after apply)<br>            }<br>        }</pre><pre>+ scheduling {<br>          + automatic_restart           = (known after apply)<br>          + instance_termination_action = (known after apply)<br>          + min_node_cpus               = (known after apply)<br>          + on_host_maintenance         = (known after apply)<br>          + preemptible                 = (known after apply)<br>          + provisioning_model          = (known after apply)</pre><pre>+ node_affinities {<br>              + key      = (known after apply)<br>              + operator = (known after apply)<br>              + values   = (known after apply)<br>            }<br>        }<br>    }</pre><pre>Plan: 1 to add, 0 to change, 0 to destroy.</pre><pre>Do you want to perform these actions?<br>  Terraform will perform the actions described above.<br>  Only &#39;yes&#39; will be accepted to approve.</pre><pre>Enter a value: yes</pre><pre>google_compute_instance.terraform: Creating...<br>google_compute_instance.terraform: Still creating... [10s elapsed]<br>google_compute_instance.terraform: Creation complete after 14s [id=projects/qwiklabs-gcp-03-4007b62a921c/zones/us-west1-c/instances/terraform]</pre><p>7. In the Google Cloud Console, on the <strong>Navigation menu</strong>, click <strong>Compute Engine</strong> &gt; <strong>VM instances</strong>. The <strong>VM instances</strong> page opens and you’ll see the VM instance you just created in the <strong>VM instances</strong> list.</p><p><em>Terraform has written some data into the </em><em>terraform.tfstate file. This state file is extremely important: it keeps track of the IDs of created resources so that Terraform knows what it is managing.</em></p><p>8. In Cloud Shell, inspect the current state:</p><pre>terraform show</pre><p><strong>Example output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nuy9FezKfJLnLKna3XNY8g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fa2192aa49c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lab- Interact with Terraform Modules]]></title>
            <link>https://medium.com/@InfoSecurity360/lab-interact-with-terraform-modules-b719b38644e7?source=rss-e4bf73aea0fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/b719b38644e7</guid>
            <category><![CDATA[gcp-lab]]></category>
            <category><![CDATA[terraform-modules]]></category>
            <dc:creator><![CDATA[MissInfoSec360]]></dc:creator>
            <pubDate>Tue, 03 Jun 2025 15:28:04 GMT</pubDate>
            <atom:updated>2025-06-03T15:28:04.147Z</atom:updated>
            <content:encoded><![CDATA[<h4>Automating Infrastructure on Google Cloud with Terraform</h4><p><em>Terraform must store state about your managed infrastructure and configuration. This state is used by Terraform to map real-world resources to your configuration, keep track of metadata, and improve performance for large infrastructures.</em></p><p><em>This state is stored by default in a local file named </em><em>terraform.tfstate, but it can also be stored remotely, which works better in a team environment.</em></p><p><em>Terraform uses this local state to create plans and make changes to your infrastructure. Before any operation, Terraform does a </em><a href="https://www.terraform.io/docs/commands/refresh.html"><em>refresh</em></a><em> to update the state with the real infrastructure.</em></p><p><em>The primary purpose of Terraform state is to store bindings between objects in a remote system and resource instances declared in your configuration. When Terraform creates a remote object in response to a change of configuration, it will record the identity of that remote object against a particular resource instance and then potentially update or delete that object in response to future configuration changes.</em></p><p>State is a necessary requirement for Terraform to function. People sometimes ask whether Terraform can work without state or not use state and just inspect cloud resources on every run. In the scenarios where Terraform may be able to get away without state, doing so would require shifting massive amounts of complexity from one place (state) to another place (the replacement concept). This section will help explain why Terraform state is required.</p><h3>Task 1: Add a local backend</h3><ol><li>In a new Cloud Shell window, create your main.tf configuration file:</li></ol><pre>touch main.tf</pre><ol><li>To retrieve your Project ID, run the following command:</li></ol><pre>gcloud config list --format &#39;value(core.project)&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yFXz3OQ8tDhdQLHh6xXLnw.png" /></figure><p>2. Click <strong>Open Editor</strong> or <strong>Open Terminal</strong> <strong>in new window</strong> and copy the Cloud Storage bucket resource code into your main.tf configuration file, replacing the project and name variable definitions with your Project ID. Also add a local backend to your main.tf file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eCjawRGEheoo8jkvj4BNSQ.png" /></figure><ol><li>On the Cloud Shell toolbar, click <strong>Open Terminal</strong>, then initialize Terraform. The Cloud Shell Editor should now display the state file called terraform.tfstate in the terraform/state directory.</li></ol><pre>terraform init</pre><pre>terraform apply</pre><pre>terraform show</pre><p>Your google_storage_bucket.test-bucket-for-state resource should be displayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TBeq3nYAZ3NPKv2BHz0Q9w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3z_e40GIZQfbnqMWQerZSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I45tXXbr5MfAW1zgDAxgdQ.png" /></figure><h3>Task 2: Add a Cloud Storage backend</h3><ol><li>Navigate back to your main.tf file in the editor and replace the current local backend with a gcs backend.</li><li>To change the existing local backend configuration, copy the following configuration into your file, replacing the local backend:</li></ol><pre>terraform {<br>  backend &quot;gcs&quot; {<br>    bucket  = &quot;# REPLACE WITH YOUR BUCKET NAME&quot;<br>    prefix  = &quot;terraform/state&quot;<br>  }<br>}<br><strong>Note:</strong> Be sure to update the variable definition of the bucket. If you didn&#39;t change the configuration, it will be the name from the google_storage_bucket resource. This bucket will be used to host the state file.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zB96yYQTYqi80zqnSr38Uw.png" /></figure><p>3. In the Cloud Console, in the <strong>Navigation menu</strong>, click <strong>Cloud Storage &gt; Browser </strong>and click on your bucket and navigate to the file terraform/state/default.tfstate. Your state file now exists in a Cloud Storage bucket!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sI2G6hWbz0Y3bW2JsdWhwg.png" /></figure><h3>Task 3: Refresh the state</h3><p>The terraform refresh command is used to reconcile the state Terraform knows about (via its state file) with the real-world infrastructure. This can be used to detect any drift from the last-known state and to update the state file.</p><ol><li>Return to your storage bucket in the Cloud Console. Select the check box next to the name, and click <strong>Show info panel</strong>. The info panel with <strong>Permissions</strong> and <strong>Labels</strong> tabs will open up.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NQPSM4zKHCtEwlJ1xZumQA.png" /></figure><p>2. Click the <strong>Labels</strong> tab &gt; <strong>Add Label</strong>. Set the <strong>Key 1</strong> = key and <strong>Value 1</strong> = value &gt; <strong>Save</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JyPNr_8DFUKS1i2m1KIArg.png" /></figure><p>3. Cloud Shell and use the following command to update the state file and examine the updates::</p><pre>terraform refresh<br>terraform show</pre><pre><em>The </em><em>&quot;key&quot; = &quot;value&quot; key-value pair should be displayed in the labels attribute of the configuration.</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tTxPvT6oYpl1IjZ3mr0d5w.png" /></figure><h3>Task 4: Clean up your workspace</h3><ol><li>First, revert your backend to local so you can delete the storage bucket. Copy and replace the gcs configuration with the following:</li></ol><pre>terraform {<br>  backend &quot;local&quot; {<br>    path = &quot;terraform/state/terraform.tfstate&quot;<br>  }<br>}</pre><p>2. Initialize the local backend again.</p><pre>terraform init -migrate-state</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-x5vq_l5K8KUA0_QjCtCZA.png" /></figure><p>3. In the main.tf file, add the force_destroy = true argument to your google_storage_bucket resource. <br><em>When you delete a bucket, this boolean option will </em><a href="https://www.terraform.io/docs/providers/google/r/storage_bucket#force_destroy"><em>delete all contained objects</em></a><em>. If you try to delete a bucket that contains objects, Terraform will fail that run. Your resource configuration should resemble the following:</em></p><pre>resource &quot;google_storage_bucket&quot; &quot;test-bucket-for-state&quot; {<br>  name        = &quot;qwiklabs-gcp-03-c26136e27648&quot;<br>  location    = &quot;US&quot;<br>  uniform_bucket_level_access = true<br>  force_destroy = true<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SP75FQnw8OeGwM-809qoUw.png" /></figure><p>4. Apply the changes and then you can now successfully destroy your infrastructure</p><pre>terraform apply</pre><pre>terraform destroy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sdCko1M_2xcANLli8ge2ng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NvbsHy3lFLeEa64Fc3sptA.png" /></figure><h3>Import Terraform configuration</h3><p><em>In this section, you will import an existing Docker container and image into an empty Terraform workspace. <br>The default Terraform workflow involves three steps:</em></p><ul><li><em>Write a Terraform configuration that defines the infrastructure you want to create.</em></li><li><em>Review the Terraform plan to ensure that the configuration will result in the expected state and infrastructure.</em></li><li><em>Apply the configuration to create your Terraform state and infrastructure.</em></li></ul><p><em>Bringing existing infrastructure under Terraform’s control involves five main steps:</em></p><ul><li><em>Identify the existing infrastructure to be imported.</em></li><li><em>Import the infrastructure into your Terraform state.</em></li><li><em>Write a Terraform configuration that matches that infrastructure.</em></li><li><em>Review the Terraform plan to ensure that the configuration matches the expected state and infrastructure.</em></li><li><em>Apply the configuration to update your Terraform state.</em></li></ul><h3>Task 5: Create a Docker container</h3><ol><li>Create a container named hashicorp-learn using the latest NGINX image from Docker Hub, and preview the container on the Cloud Shell virtual machine over port 80 (HTTP):</li></ol><pre>docker run --name hashicorp-learn --detach --publish 8080:80 nginx:latest</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NSrWjh6zi7gX1o6m1PaCPg.png" /></figure><p>2. Verify that the container is running:</p><pre>docker ps</pre><p>In the Cloud Shell pane, click <strong>Web Preview</strong>, and then click <strong>Preview on port 8080</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5OYGcaf6YqB_lwlK04iUmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aVyUTrwPysxFTHP4Qr1ldQ.png" /><figcaption>Cloud Shell opens the preview URL on its proxy service in a new browser window and displays the NGINX default index page. Now you have a Docker image and container to import into your workspace and manage with Terraform.</figcaption></figure><h3>Task 6: Import the container into Terraform</h3><ol><li>Clone the example repository:</li></ol><pre>git clone <a href="https://github.com/hashicorp/learn-terraform-import.git">https://github.com/hashicorp/learn-terraform-import.git</a></pre><p>2. Change into that directory and initialize your Terraform workspace::</p><pre>cd learn-terraform-import</pre><pre>terraform init</pre><p>This directory contains two Terraform configuration files that make up the configuration you will use in this guide:</p><ul><li>main.tf file configures the Docker provider.</li><li>docker.tf file will contain the configuration necessary to manage the Docker container you created in an earlier step.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aXKPfT4R8dvl0M4XzdtTUw.png" /></figure><p>3. In the Cloud Shell Editor, navigate to learn-terraform-import/main.tfand and find the provider: docker resource and <strong>comment out or delete</strong> the host argument:</p><pre>provider &quot;docker&quot; {<br>#   host    = &quot;npipe:////.//pipe//docker_engine&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n1HWOFf_kT3ShYFmtuH3cw.png" /><figcaption>This is a current workaround for a known issue with a Docker initialization error.</figcaption></figure><p>4. Next, navigate to learn-terraform-import/docker.tf. Under the commented-out code, define an empty docker_container resource in your docker.tf file, which represents a Docker container with the Terraform resource ID docker_container.web:</p><pre>resource &quot;docker_container&quot; &quot;web&quot; {}</pre><p>5. Find the name of the container you want to import: in this case, the container you created in the previous step:</p><pre>docker ps</pre><p>6. Run the following terraform import command to attach the existing Docker container to the docker_container.web resource you just created. Terraform import requires this Terraform resource ID and the full Docker container ID. The command docker inspect -f {{.ID}} hashicorp-learn returns the full SHA256 container ID:</p><pre>terraform import docker_container.web $(docker inspect -f {{.ID}} hashicorp-learn)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L0j8CDjoYPC-TZ0nzDYE8w.png" /><figcaption><strong>Note:</strong> The ID accepted by terraform import varies by resource type and is documented in the provider documentation for any resource that can be imported to Terraform. For this example, consult the <a href="https://www.terraform.io/docs/providers/docker/r/container#import">Docker provider documentation</a></figcaption></figure><p>7. Verify that the container has been imported into your Terraform state:</p><pre>terraform show</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U1527vaskvokQ1D5o9Wmvw.png" /><figcaption>This state contains everything that Terraform knows about the Docker container you just imported. However, Terraform import does <strong>not</strong> create the configuration for the resource.</figcaption></figure><h3>Task 7: Create configuration</h3><ol><li>We create Terraform configuration before using Terraform to manage this container.</li></ol><pre>terraform plan</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xbeIMM_HDFDKImOIbh3p4g.png" /></figure><p>There are two approaches to update the configuration in docker.tf to match the state you imported. You can either accept the entire current state of the resource into your configuration as-is or select the required attributes into your configuration individually. Each of these approaches can be useful in different circumstances.</p><ul><li>Using the current state is often faster, but can result in an overly verbose configuration because every attribute is included in the state, whether it is necessary to include in your configuration or not.</li><li>Individually selecting the required attributes can lead to more manageable configuration, but requires you to understand which attributes need to be set in the configuration.</li></ul><p>For this lab’s purposes, you will use the current state as the resource.</p><ol><li>Copy your Terraform state into your docker.tf file:</li></ol><pre>terraform show -no-color &gt; docker.tf</pre><p>Copied!</p><p>content_copy</p><p><strong>Note:</strong> The &gt; symbol will replace the entire contents of docker.tf with the output of the terraform show command. Although this works for this example, importing a resource into a configuration that already manages resources will require you to edit the output of terraform show to remove existing resources whose configuration you do not want to replace completely and merge the new resources into your existing configuration.</p><ol><li>Inspect the docker.tf file to see that its contents have been replaced with the output of the terraform show command you just ran.</li><li>Run the following code:</li></ol><pre>terraform plan</pre><p>Copied!</p><p>content_copy</p><p>Terraform will show warnings and errors about a deprecated argument (‘links’), and several read-only arguments (ip_address, network_data, gateway, ip_prefix_length, id).</p><p>These read-only arguments are values that Terraform stores in its state for Docker containers but that it cannot set via configuration because they are managed internally by Docker. Terraform can set the links argument with configuration, but still displays a warning because it is deprecated and might not be supported by future versions of the Docker provider.</p><p>Because the approach shown here loads all of the attributes represented in Terraform state, your configuration includes optional attributes whose values are the same as their defaults. Which attributes are optional, and their default values, will vary from provider to provider, and are listed in the <a href="https://www.terraform.io/docs/providers/docker/r/container">provider documentation</a>.</p><ol><li>You can now selectively remove these optional attributes. <strong>Remove</strong> all of these attributes, <em>keeping only the required attributes</em>: image, name, and ports. After removing these optional attributes, your configuration should match the following:</li></ol><pre>resource &quot;docker_container&quot; &quot;web&quot; {<br>    image = &quot;sha256:87a94228f133e2da99cb16d653cd1373c5b4e8689956386c1c12b60a20421a02&quot;<br>    name  = &quot;hashicorp-learn&quot;<br>    ports {<br>        external = 8080<br>        internal = 80<br>        ip       = &quot;0.0.0.0&quot;<br>        protocol = &quot;tcp&quot;<br>    }<br>}</pre><p>Copied!</p><p>content_copy</p><p>When importing real infrastructure, consult the provider documentation to learn what each argument does. This will help you to determine how to handle any errors or warnings from the plan step. For instance, the documentation for the links argument is in the <a href="https://www.terraform.io/docs/providers/docker/r/container#links">Docker provider documentation</a>.</p><ol><li>Verify that the errors have been resolved:</li></ol><pre>terraform plan</pre><p>Copied!</p><p>content_copy</p><p>The plan should now execute successfully. Notice that the plan indicates that Terraform will update the container to add the attach, logs, must_run, and start attributes.</p><p>Terraform uses these attributes to create Docker containers, but Docker doesn’t store them. As a result, terraform import didn’t load their values into state. When you plan and apply your configuration, the Docker provider will assign the default values for these attributes and save them in state, but they won’t affect the running container.</p><ol><li>Apply the changes and finish the process of syncing your updated Terraform configuration and state with the Docker container they represent. Type <strong>yes</strong> at the prompt to confirm.</li></ol><pre>terraform apply</pre><p>Copied!</p><p>content_copy</p><p>Now your configuration file, Terraform state, and the container are all in sync, and you can use Terraform to manage the Terraform container as you normally would.</p><h3>Create image resource</h3><p>In some cases, you can bring resources under Terraform’s control without using the terraform import command. This is often the case for resources that are defined by a single unique ID or tag, such as Docker images.</p><p>In your docker.tf file, the docker_container.web resource specifies the SHA256 hash ID of the image used to create the container. This is how docker stores the image ID internally, and so terraform import loaded the image ID directly into your state. However the image ID is not as human readable as the image tag or name, and it may not match your intent. For example, you might want to use the latest version of the &quot;nginx&quot; image.</p><ol><li>To retrieve the image’s tag name, run the following command, replacing &lt;IMAGE-ID&gt; with the image ID from docker.tf:</li></ol><pre>docker image inspect &lt;IMAGE-ID&gt; -f {{.RepoTags}}</pre><p>Copied!</p><p>content_copy</p><ol><li>Add the following configuration to your docker.tf file to represent this image as a resource:</li></ol><pre>resource &quot;docker_image&quot; &quot;nginx&quot; {<br>  name         = &quot;nginx:latest&quot;<br>}</pre><p>Copied!</p><p>content_copy</p><p><strong>Note:</strong> Do not replace the image value in the docker_container.web resource yet, or Terraform will destroy and recreate your container. Because Terraform hasn’t loaded the docker_image.nginx resource into state yet, it does not have an image ID to compare with the hardcoded one, which will cause Terraform to assume the container must be replaced. To work around this situation, create the image first, and then update the container to use it, as shown in this lab.</p><ol><li>Create an image resource in state:</li></ol><pre>terraform apply</pre><p>Copied!</p><p>content_copy</p><p>Now that Terraform has created a resource for the image, you can reference it in your container’s configuration.</p><ol><li>Change the image value for docker_container.web to reference the new image resource:</li></ol><pre>resource &quot;docker_container&quot; &quot;web&quot; {<br>    image = docker_image.nginx.latest<br>    name  = &quot;hashicorp-learn&quot;<br>    ports {<br>        external = 8080<br>        internal = 80<br>        ip       = &quot;0.0.0.0&quot;<br>        protocol = &quot;tcp&quot;<br>    }<br>}</pre><p>Copied!</p><p>content_copy</p><ol><li>Look for changes:</li></ol><pre>terraform apply</pre><p>Copied!</p><p>content_copy</p><p>Because docker_image.nginx.latest will match the hardcoded image ID you replaced, running terraform apply at this point will show no changes.</p><p><strong>Note:</strong> If the image ID for the tag “nginx:latest” changed between the time you first created the Docker container and when you run this command, the container will be destroyed and recreated with the new image.</p><h3>Manage the container with Terraform</h3><p>Now that Terraform manages the Docker container, use Terraform to change the configuration.</p><ol><li>In your docker.tf file, change the container&#39;s external port from 8080 to 8081:</li></ol><pre>resource &quot;docker_container&quot; &quot;web&quot; {<br>  name  = &quot;hashicorp-learn&quot;<br>  image = docker_image.nginx.latest<br>  ports {<br>    external = 8081<br>    internal = 80<br>    ip       = &quot;0.0.0.0&quot;<br>    protocol = &quot;tcp&quot;<br>  }<br>}</pre><p>Copied!</p><p>content_copy</p><ol><li>Apply the change:</li></ol><pre>terraform apply</pre><p>Copied!</p><p>content_copy</p><p>Type yes at the prompt to confirm.</p><p>This will cause Terraform to destroy and recreate the container with the new port configuration.</p><ol><li>Verify that the container has been replaced with a new one with the new configuration:</li></ol><pre>docker ps</pre><p>Copied!</p><p>content_copy</p><p>Notice that the container ID has changed. Because changing the port configuration required destroying and recreating it, this is a completely new container.</p><h3>Destroy infrastructure</h3><p>You have now imported your Docker container and the image used to create it into Terraform.</p><ol><li>Destroy the container and image:</li></ol><pre>terraform destroy</pre><p>Copied!</p><p>content_copy</p><p>Type yes at the prompt to confirm.</p><ol><li>Validate that the container was destroyed:</li></ol><pre>docker ps --filter &quot;name=hashicorp-learn&quot;</pre><p>Copied!</p><p>content_copy</p><p><strong>Tip:</strong> Because you added the image to both your Terraform configuration and the container, the image will be removed from both Docker and the container. If another container was using the same image, the destroy step would fail. Remember that importing a resource into Terraform means that Terraform will manage the entire lifecycle of the resource, including destruction.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b719b38644e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud Identity and Access Management or Cloud IAM— GCP]]></title>
            <link>https://medium.com/@InfoSecurity360/cloud-identity-and-access-management-or-cloud-iam-gcp-7f476fe9354?source=rss-e4bf73aea0fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f476fe9354</guid>
            <category><![CDATA[access-management]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[cloud-iam]]></category>
            <category><![CDATA[cloud-identity]]></category>
            <dc:creator><![CDATA[MissInfoSec360]]></dc:creator>
            <pubDate>Tue, 03 Jun 2025 15:27:25 GMT</pubDate>
            <atom:updated>2025-06-03T15:27:25.787Z</atom:updated>
            <content:encoded><![CDATA[<p>IAM is a way of identifying who can do what on which resource.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2PzIC0UsgTqlIsITlAbjGQ.png" /></figure><p>The <strong><em>who</em></strong> can be a person, group or application. <br>The <strong><em>what</em></strong> refers to specific privileges or actions.<br>The <strong><em>resource</em></strong> could be any Google Cloud service.</p><p>Cloud IAM is composed of different objects:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4WKhA3U9dqMqalXGBdfXPw.png" /><figcaption>Cloud IAM is composed of different objects</figcaption></figure><p>Google Cloud resources are organized hierarchically as shown in this tree structure.<br>- The organization node is the root node in this hierarchy. The organization resource represents your company.<br>- Folders are the children of the organization. The folder resource could represent your department.<br>- Projects are the children of folders, and individual resources are the children of projects. Projects represent a trust boundary within your company. Services within the same project have the same default level of trust.<br>- Each resource has exactly one parent.</p><p>Ref: <a href="https://www.cloudskillsboost.google/course_sessions/1412712/video/314454">https://www.cloudskillsboost.google/course_sessions/1412712/video/314454</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f476fe9354" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GCP Practise Test 1]]></title>
            <link>https://medium.com/@InfoSecurity360/gcp-practise-test-1-de6793dd5198?source=rss-e4bf73aea0fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/de6793dd5198</guid>
            <category><![CDATA[gcp-practise-test]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[MissInfoSec360]]></dc:creator>
            <pubDate>Tue, 03 Jun 2025 15:26:45 GMT</pubDate>
            <atom:updated>2025-06-03T15:26:45.412Z</atom:updated>
            <content:encoded><![CDATA[<p>QUESTION 1: A mission-critical application running on a Managed Instance Group (MIG) in Google Cloud has been having scaling issues. Although the scaling works, it is not quick enough, and users experience slow response times. The solution architect has recommended moving to GKE to achieve faster scaling and optimize machine resource utilization. Your colleague containerized the application and provided you with a Dockerfile. You now need to deploy this in a GKE cluster. How should you do it?<br>a. Deploy the application using kubectl app deploy .<br>b. Build a container image from the Dockerfile and push it to Google Cloud Storage (GCS). Create a Kubernetes Deployment YAML file and have it use the image from GCS. Use kubectl apply -f to deploy the application to the GKE cluster.<br>c. Deploy the application using gcloud app deploy.<br>d. Build a container image from the Dockerfile and push it to Google Container Registry (GCR). Create a Kubernetes Deployment YAML file and have it use the image from GCR. Use kubectl apply -f to deploy the application to the GKE cluster.</p><p>QUESTION 2: You have a collection of audio/video files over 80GB each that you need to migrate to Google Cloud Storage. The files are in your on-premises data center. What migration method can you use to help speed up the transfer process?<br>a. Use multithreaded uploads using the -m option.<br>b. Use the Cloud Transfer Service to transfer.<br>c. Use parallel uploads to break the file into smaller chunks then transfer it simultaneously.<br>d. Start a recursive upload.</p><p>QUESTION 3: While running a Second Generation MySQL database in Cloud SQL, which of the following features can be configured?<br>a. Failover replicas can be configured<br>b. Maintenance windows can be configured<br>c. None of these<br>d. Machine type can be configured<br>e. All of these can be configured</p><p>QUESTION 4: You are designing a mobile game which you hope will be used by numerous users around the world. The game backend requires a Relational DataBase Management System (RDBMS) for persisting game state and player profiles. You want to select a database that can scale to a global audience with minimal configuration updates. Which database should you choose?<br>a. Cloud Firestore.<br>b. Cloud Datastore.<br>c. Cloud Spanner.<br>d. Cloud SQL.</p><p>QUESTION 5: Which of the below mentioned claims about Cloud Storage is false? <br>a. Cloud Storage buckets may have retention periods.<br>b. Cloud Storage is designed for high durability.<br>c. None of these.<br>d. Cloud Storage does not allow access of block-level to the data within files that are stored in buckets.<br>e. Lifecycle configurations are used in altering the storage class from regional to multiregional.</p><p>QUESTION 6: You want to create a new role and grant it to the SME team. The new role should provide your SME team BigQuery Job User and Cloud Bigtable User roles on all projects in the organization. You want to minimize operational overhead. You want to follow Google recommended practices.How should you create the new role?<br>a. In GCP Console under IAM Roles, select both roles and combine them into a new custom role. Grant the role to the SME team group at project. Use gcloud iam promote-role to promote the role to all other projects and grant the role in each project to the SME team group.<br>b. In GCP Console under IAM Roles, select both roles and combine them into a new custom role. Grant the role to the SME team group at the organization level.<br>c. In GCP Console under IAM Roles, select both roles and combine them into a new custom role. Grant the role to the SME team group at project. Repeat this step for each project.<br>d. Execute command gcloud iam combineroles — global to combine the 2 roles into a new custom role and grant them globally to SME team group.</p><p>QUESTION 7: You want to list all the compute instances in zones us-central1-b and europe-west1-d. Which of the commands below should you run to retrieve this information?<br>a. gcloud compute instances list — filter=”zone:( us-central1-b europe-west1-d )”<br>b. gcloud compute instances list — filter=”zone:( us-central1-b )” and gcloud compute instances list — filter=”zone:( europe-west1-d )” and combine the results.<br>c. gcloud compute instances get — filter=”zone:( us-central1-b )” and gcloud compute instances list — filter=”zone:( europe-west1-d )” and combine the results.<br>d. gcloud compute instances get — filter=”zone:( us-central1-b europe-west1-d )”.</p><p>QUESTION 8: As per the company policies of TPT Ltd. it critical to back the Datastore database at least once a day. John has been asked to explain about the sufficiency of the Datastore export, to an Auditor. Which of the following should John use to explain the outputs generated by the Datastore export command?<br>a. The Datastore export commands produces A single entity file as an output.<br>b. The Datastore export commands produces a metadata file and a folder with the data as an output.<br>c. The Datastore export commands produces a Metadata file as an output.<br>d. None of these.<br>e. The Datastore export commands produces A metadata file, an entity file, and a folder with the data as an output.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de6793dd5198" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>