<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Olaiya Stephen</title>
    <description>The latest articles on DEV Community by Olaiya Stephen (@stephyards).</description>
    <link>https://dev.to/stephyards</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F287585%2Fd54c0296-7629-4546-aaa9-2a94a2ea3ce8.png</url>
      <title>DEV Community: Olaiya Stephen</title>
      <link>https://dev.to/stephyards</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stephyards"/>
    <language>en</language>
    <item>
      <title>Terraform intro,setup,create s3bucket,ec2 instance in its own network</title>
      <dc:creator>Olaiya Stephen</dc:creator>
      <pubDate>Thu, 18 May 2023 16:08:09 +0000</pubDate>
      <link>https://dev.to/stephyards/terraform-introsetupcreate-s3bucketec2-instance-in-its-own-network-g8g</link>
      <guid>https://dev.to/stephyards/terraform-introsetupcreate-s3bucketec2-instance-in-its-own-network-g8g</guid>
      <description>&lt;p&gt;Terraform is written in go and more important in building infrastructure compare to chef and ansible which are better with configurations.&lt;br&gt;
Terraform can be use with all cloud services. Unlike cloud formation that covers AWS platform only.&lt;/p&gt;

&lt;p&gt;use these three commands to perform terraform deployments.. &lt;br&gt;
&lt;strong&gt;terraform “init”&lt;br&gt;
terraform "plan"&lt;br&gt;
terraform "apply"&lt;/strong&gt; (sometime you add** “--auto-approve”** to avoid the Yes/No confirmation response.)&lt;/p&gt;

&lt;h2&gt;
  
  
  INSTALLING TERRAFORM
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;download Terraform from the terraform page or use already made shell file from my &lt;a href="https://github.com/hesblac/installation_scripts/blob/master/terraform.sh" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;that has all the commands to install and get terraform up and running in seconds.&lt;/li&gt;
&lt;li&gt;Use the commands terraform --version to confirm that terraform is installed.&lt;/li&gt;
&lt;li&gt;Use vscode or any editor you like for convenience. We’ll use Vscode.&lt;/li&gt;
&lt;li&gt;In the vscode, install the terraform extension for easy coding and template helps.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8wqzzkyx76pfthvzecn1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8wqzzkyx76pfthvzecn1.png" alt="terraform installed" width="533" height="134"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring our “AWS secret key and Access key”
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;STEPS:&lt;/strong&gt;&lt;br&gt;
    • launch your aws console &lt;br&gt;
    • search for IAM&lt;br&gt;
    • click on user&lt;br&gt;
    • click on Add user&lt;br&gt;
    • create a username by entering any meaningful name you desire&lt;br&gt;
from the next section click on the "attach policy directly"&lt;br&gt;
    • in this section &lt;em&gt;Permissions policies&lt;/em&gt;, search and check/choose your prefered permission to perform what you need.&lt;br&gt;
    • We’ll use the the Admin full access “AdministratorAccess” then click the “Next Tags”&lt;br&gt;
    • click next again&lt;br&gt;
    • click on “create user”&lt;br&gt;
    • your user is ready, click on it &lt;br&gt;
go to the security credential tab&lt;br&gt;
in the access key section , click on create access key&lt;br&gt;
click the Command Line Interface, accept the terms and click next, in the next section,input a tag name or leave it empty then click &lt;strong&gt;create access key&lt;/strong&gt;&lt;br&gt;
 save them both.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F35ricf9ghbn3dhjurpx2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F35ricf9ghbn3dhjurpx2.png" alt="access keys" width="754" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will show you set them up securely for use in your Terraform codes.&lt;/p&gt;

&lt;p&gt;CREATING AN EC2 INSTANCE WITH TERRAFORM&lt;/p&gt;

&lt;p&gt;for beginners, go to Google and search for “aws instance terraform”&lt;br&gt;
copy the sample basic code for the instance to a file in your workspace named main.tf&lt;br&gt;
note: every file in terraform uses the extension &lt;strong&gt;“.tf”&lt;/strong&gt;  except some.&lt;br&gt;
when you have that set in your vscode,&lt;br&gt;
go to the search tab again and search for “terraform aws provider”&lt;br&gt;
this block will authenticate you to use terraform with aws.&lt;br&gt;
then copy the basic provider block of code into your main.tf file.&lt;/p&gt;

&lt;p&gt;Now , arrange your code so we have the provider block before the instance block.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbrk0gyb8pgmw848jnt7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbrk0gyb8pgmw848jnt7a.png" alt="aws terra code" width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;we can just leave our credential in the code, but with security in mind, it's a bad practice.&lt;/p&gt;

&lt;p&gt;In your vscode, we’ll want to use the terminal to configure the credentials we got from AWS (Access key and Secret key) so as to get it ready for terraform usage.&lt;br&gt;
right click on the main.tf then choose terminal  to open the terminal or just use Ctrl + back-tick to access the Terminal from vscode or just use the normal terminal like me.&lt;br&gt;
i'm using an ec2 instance for this since i already have terraform set up on my local.&lt;/p&gt;

&lt;h2&gt;
  
  
  CONFIGURING TERRAFORM TO USE AWS CREDENTIALS
&lt;/h2&gt;

&lt;p&gt;first we'll install AWScli on our server to use aws command line. &lt;br&gt;
we'll go to our &lt;a href="https://github.com/hesblac/installation_scripts/blob/master/Awscli" rel="noopener noreferrer"&gt;github&lt;/a&gt; and get the ready shell script. you can use the main aws site also and get the installation commands.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1msgh3wqwoupcfh0sqs6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1msgh3wqwoupcfh0sqs6.png" alt="aws cli" width="800" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;in the terminal, run the command &lt;strong&gt;“aws configure”&lt;/strong&gt;&lt;br&gt;
you will be prompted for both keys,a region, enter the keys as requested and your preferred region.(where you want your deployment). Also, use json for the output prompt.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faqa0725748q05d04f1pj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faqa0725748q05d04f1pj.png" alt="aws configure" width="496" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To confirm that your credentials are saved :&lt;/p&gt;

&lt;p&gt;in your home folder, there is a file named “.aws”&lt;br&gt;
this folder should have these files “credentials and config”&lt;br&gt;
you can edit the credential file and change the default to “myaws”  or a name you like&lt;br&gt;
The config has the default settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwqm90z2n2v4u0t4h45i5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwqm90z2n2v4u0t4h45i5.png" alt="aws profile" width="497" height="96"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also confirm that your credentials are set and they are working by completing these terraform setup;&lt;/p&gt;

&lt;p&gt;In your terraform code, remove everything in the provider block, you can leave it blank or set your profile as “myaws” or to the name you set in the setup, and set your region to what you want like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpxdgxussp1kmy1egshmh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpxdgxussp1kmy1egshmh.png" alt="profile set" width="675" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;terraform will automatically use the credentials we saved earlier.&lt;/p&gt;

&lt;p&gt;Use “terraform init” &amp;gt;&amp;gt;&amp;gt;&amp;gt; this will initialize the code and install all the plugins needed, if the credential  is wrong, we’ll get an error.&lt;br&gt;
If it succeed , we’ll get a ready response.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0zk43620vbq91o3npmqg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0zk43620vbq91o3npmqg.png" alt="terraform init" width="675" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use “terraform plan” &amp;gt;&amp;gt;&amp;gt; this will show us what we are deploying . And if there’s any problem with our code, this is the place where we’ll know and rectify/debug it&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp8otswc6fsfinnjkqldm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp8otswc6fsfinnjkqldm.png" alt="terraform plan" width="680" height="152"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use “terraform apply” &amp;gt;&amp;gt;&amp;gt;&amp;gt; this will apply our code and deploy our infrastructure as stated in our code and we will also see the detail of our deployment just as we see after the plan command.&lt;br&gt;
After this command, terraform will prompt us to type yes to continue(after this , there’s no going back unless you use Ctr l C). Instead of typing yes in the prompt, we can add “--auto-approve” to the terraform apply command. And we won’t be prompted, terraform will just run the commands and show us success or failure of our deployment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwon1p0cied95yx3ejhz8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwon1p0cied95yx3ejhz8.png" alt="terraform apply" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After deployment, that is , when terraform shows us that the run is complete,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4uwmu8qif0ogise0nr0k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4uwmu8qif0ogise0nr0k.png" alt="success" width="630" height="474"&gt;&lt;/a&gt;&lt;br&gt;
to see the infrastructure we just deploy,&lt;br&gt;
go to the aws console, &lt;br&gt;
change your region to the one you choose or used in your aws default configuration or in your provider block. In my case, I used us-west-2&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqi7xzx7a91s00ny6ls2s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqi7xzx7a91s00ny6ls2s.png" alt="region" width="390" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you are in that region, use the search box on the console to search for &lt;em&gt;ec2 instance&lt;/em&gt;.&lt;br&gt;
you should Immediately  see your instance, either already deployed or its starting up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F41q6tv8y847avoreqvzl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F41q6tv8y847avoreqvzl.png" alt="instance running" width="800" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’ve confirmed your deployment , to destroy or delete your infrastructure, it’s better to destroy from the same place you apply from and not in the console, so as to delete all created components,&lt;/p&gt;

&lt;p&gt;in our case , we only have an ec2 instance. So it’s easy to destroy.&lt;br&gt;&lt;br&gt;
In deployments where many components are involved, its not a good practice to go into the console and delete each one after the other. &lt;/p&gt;

&lt;p&gt;using “terraform destroy” or “terraform destroy --auto-approve” will delete all the infrastructure you just created.&lt;br&gt;
Ensure you’re still in the terminal and also inside the folder where your files are located.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh5551mnva8gouhsud1dt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh5551mnva8gouhsud1dt.png" alt="terraform destroy" width="677" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TERRAFORM VARIABLES&lt;/p&gt;

&lt;p&gt;type contraints are created from a mixture of type keywords and type contructors.&lt;br&gt;
The supported type keywords are:&lt;br&gt;
string, number, bool&lt;br&gt;
type constructors allow you to specify complex types such as collections:&lt;br&gt;
list, set, map,object, tuple&lt;/p&gt;

&lt;p&gt;to perform this lab,&lt;br&gt;
use the google again to search for terraform aws s3bucket, copy the s3bucket basic block code to a main.tf file.&lt;/p&gt;

&lt;p&gt;Ensure your provider block is already set and configured as explained earlier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmzjsi3g9xn2so9pj90gl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmzjsi3g9xn2so9pj90gl.png" alt="s3bucket" width="337" height="222"&gt;&lt;/a&gt;&lt;br&gt;
After your components are ready, extract each of  the variables from it, with the type, description and default all stated, like so&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flouy0x0aumvkh0nf7hab.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flouy0x0aumvkh0nf7hab.png" alt="variables" width="448" height="368"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;copy all the variables to a file name “variable.tf”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foa2lmu91hnidf1d6mk29.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foa2lmu91hnidf1d6mk29.png" alt="var ready" width="598" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;you should do this for all resources &lt;/p&gt;

&lt;p&gt;deploy and  confirm your s3buckets just the same way we confirmed our ec2 instance earlier (search on the console for s3bucket) you should see your bucket.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F80qxr8rlsaaxxpdlh3h2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F80qxr8rlsaaxxpdlh3h2.png" alt="bucket ready" width="800" height="283"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;destroy the s3bucket when you're done.&lt;/p&gt;

&lt;p&gt;TERRAFORM (MULTIPLE BLOCKS IN A SINGLE TERRAFORM CODE)&lt;br&gt;
in this lab, We’ll be launching :&lt;br&gt;
EC2 instance&lt;br&gt;
Vpc&lt;br&gt;
Subnet&lt;br&gt;
Nic ==&amp;gt; network interface card&lt;/p&gt;

&lt;p&gt;we’ll be creating all this in a main.tf . No variables.&lt;br&gt;
The work-flow:&lt;/p&gt;

&lt;p&gt;VPC===&amp;gt;subnet==&amp;gt;NIC==&amp;gt;EC2&lt;/p&gt;

&lt;p&gt;assuming we already have our provider block.&lt;br&gt;
We will start with our vpc,&lt;br&gt;
as usual, search for your vpc code block, and copy the basic vpc block of code to main.tf file.&lt;br&gt;
This comes with a cidr_block.&lt;br&gt;
Do the same for the subnet block and copy that to our code into vscode.&lt;br&gt;
Edit the vpc in the subnet block to use the vpc we added first. Like so.==&amp;gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6hq12sihb8rh7ikt1e73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6hq12sihb8rh7ikt1e73.png" alt="vpc and subnet" width="800" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;also search for the nic block of code. And copy that to our vscode .&lt;br&gt;
From the nic block, change the subnet to use ours, also change the private_ips to anyone, just pick from the subnet cidr_block&lt;/p&gt;

&lt;p&gt;remember to remove the components not needed or the optional ones, since this is just a simple deployment,we shouldn’t complicate things..&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft16jv8xoepj3qfr84bdh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft16jv8xoepj3qfr84bdh.png" alt="network interface" width="418" height="55"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally,&lt;br&gt;
Search for ec2 instance and copy its basic to  your code and&lt;br&gt;
edit your ec2 like so,===&amp;gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxg97qld59zj5v5hduu9m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxg97qld59zj5v5hduu9m.png" alt="ec2 instance" width="800" height="159"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;after these,&lt;br&gt;
use the &lt;strong&gt;terraform init,plan and apply&lt;/strong&gt; commands to initialize and deploy your infrastructure&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4xo26edyw0b62q2hjqxb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4xo26edyw0b62q2hjqxb.png" alt="instance ready" width="800" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;use the &lt;strong&gt;terraform destroy --auto-approve&lt;/strong&gt; to destroy it.&lt;/p&gt;

&lt;p&gt;this is the end of this part. thanks for reading.&lt;/p&gt;

</description>
      <category>terraform</category>
      <category>aws</category>
      <category>vscode</category>
      <category>devops</category>
    </item>
    <item>
      <title>Setting up Sonartype nexus on your local docker</title>
      <dc:creator>Olaiya Stephen</dc:creator>
      <pubDate>Sun, 30 Apr 2023 05:33:55 +0000</pubDate>
      <link>https://dev.to/stephyards/setting-up-sonartype-nexus-on-your-local-docker-2n9j</link>
      <guid>https://dev.to/stephyards/setting-up-sonartype-nexus-on-your-local-docker-2n9j</guid>
      <description>&lt;p&gt;If you installed Sonatype Nexus Repository Manager with Docker and the generated password for the admin user is stored in a file named admin.password inside a volume, you can retrieve the password by accessing the file.&lt;/p&gt;

&lt;p&gt;Here are the steps to retrieve the admin password:&lt;/p&gt;

&lt;p&gt;Identify the volume that contains the admin.password file. You can do this by running the docker inspect command on your Nexus container:&lt;/p&gt;

&lt;p&gt;docker inspect  | grep Source&lt;/p&gt;

&lt;p&gt;Replace  with the name of your Nexus container.&lt;/p&gt;

&lt;p&gt;Once you have identified the volume, you can use the docker run command to start a temporary container with access to that volume:&lt;/p&gt;

&lt;p&gt;bash&lt;/p&gt;

&lt;p&gt;docker run --rm -v :/data alpine cat /data/admin.password&lt;/p&gt;

&lt;p&gt;Replace  with the name of the volume that contains the admin.password file.&lt;/p&gt;

&lt;p&gt;The output of the command will be the generated password for the admin user. You can use this password to log in to the Nexus web interface and change the admin password to something more secure.&lt;/p&gt;

&lt;p&gt;Note that the docker run command used in step 2 starts a temporary container and mounts the specified volume to the /data directory in the container. The cat command is used to read the contents of the admin.password file and output it to the terminal. Once the command has completed, the temporary container is automatically removed with the --rm option.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>cicd</category>
      <category>artifacts</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
