{"id":1655,"date":"2022-07-12T08:49:36","date_gmt":"2022-07-12T07:49:36","guid":{"rendered":"https:\/\/www.easydeploy.io\/blog\/?p=1655"},"modified":"2022-07-12T09:39:07","modified_gmt":"2022-07-12T08:39:07","slug":"s3-bucket-aws-terraform-cli-command","status":"publish","type":"post","link":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/","title":{"rendered":"How To Create a S3 Bucket using Terraform Script from CLI?"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">In this blog post, we are going to explain how to create S3 Bucket using Terraform Script from CLI. This is one of the first blog posts on the Terraform blog series we have planned to publish in this blog. We are providing consulting services for Terraform and also helping companies to write <strong>Terraform scripts<\/strong> to provision infrastructure as they need.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you have any questions related to this article, please write it in the comments section or contact us for more information. We would be happy to help you in learning more about Terraform.<\/span><\/p>\n<p><b>Note: <\/b><span style=\"font-weight: 400;\">The objective of this Terraform script is to teach you the basics of how to write and execute Terraform script and an introduction to Infrastructure as Code (IaC).<\/span><\/p>\n<h2 style=\"text-align: center;\">Create S3 Bucket Using Terraform CLI Commands<\/h2>\n<h3><b>Prerequisites<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Here is the prerequisite to execute the scripts given in this blog post.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Access key ID &amp; Secret Access Key of your AWS IAM User&#8217;s.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">AWS IAM User must have an AWS IAM role with S3 permissions<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">This example is written using the Visual Studio Code<\/span><\/li>\n<\/ol>\n<h3><b>Steps To Create S3 Bucket Using Terraform<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Here is the list of steps that would help you to write and execute the simple Terraform script that will create a S3 bucket in the backend.<\/span><\/p>\n<h4><b>Step 1: Create a module folder in the local<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">If you<\/span> <span style=\"font-weight: 400;\">look at the below screenshot, this is the project that is used for writing the terraform scripts in our local project. The first step is to create a \u201cmodules\u201d folder where we store all the terraform scripts that are used for creating S3 buckets. This folder will be referred from outside files.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1656 size-full\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/module-folder-terraform-local-environment.png\" alt=\"Module Folder in Terraform Environment\" width=\"1214\" height=\"512\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/module-folder-terraform-local-environment.png 1214w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/module-folder-terraform-local-environment-300x127.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/module-folder-terraform-local-environment-1024x432.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/module-folder-terraform-local-environment-768x324.png 768w\" sizes=\"(max-width: 1214px) 100vw, 1214px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">If you look at the above screenshot, we have created two files under the \u201cmodules\u201d folder:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">s3.tf<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">var.tf<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The next step is to write the configuration parameter inside the scripts. Let\u2019s move on to the next step.<\/span><\/p>\n<h4><b>Step 2: Add Bucket Configurations<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">As we have explained, this example is to create an S3 bucket. We have to write the required configurations to create S3 buckets in the AWS infrastructure using the code.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here is the script written for creating the S3 bucket:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1657\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/create-s3-bucket-terraform-1024x591.png\" alt=\"S3 Bucket Creation using Terraform\" width=\"1024\" height=\"591\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/create-s3-bucket-terraform-1024x591.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/create-s3-bucket-terraform-300x173.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/create-s3-bucket-terraform-768x443.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/create-s3-bucket-terraform.png 1220w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">In the above script, it contains a block named &#8220;resource&#8221; which has the resource type &#8220;<\/span><i><span style=\"font-weight: 400;\">aws_s3_bucket<\/span><\/i><span style=\"font-weight: 400;\">&#8220;. This is the fixed resource value for S3 defined in the AWS documentation. &#8220;bucket&#8221; is a resource name that the user provides.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">bucket and acl are the argument types, which we have provided the details of our resource. Either we can provide value directly or use the <\/span><i><span style=\"font-weight: 400;\">variables.tf<\/span><\/i><span style=\"font-weight: 400;\"> file to declare the value of an argument.<\/span><\/li>\n<\/ul>\n<h4><b>Step 3: Defining Variables<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">The next step would be to declare variables that are used in the project. We have added all the variables in the file <\/span><i><span style=\"font-weight: 400;\">var.tf.<\/span><\/i><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1658\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/variables-terraform-1024x350.png\" alt=\"Terraform Variables\" width=\"1024\" height=\"350\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/variables-terraform-1024x350.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/variables-terraform-300x103.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/variables-terraform-768x263.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/variables-terraform.png 1198w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">For our bucket we provide an argument &#8220;bucket&#8221; as <\/span><i><span style=\"font-weight: 400;\">var.bucket_name<\/span><\/i><span style=\"font-weight: 400;\">, Which is declared in <\/span><i><span style=\"font-weight: 400;\">var.tf<\/span><\/i><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span><\/p>\n<h4><b>Step 4: Create main.tf and variables.tf in root folder<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">The final step would be to create the two files outside the \u201c<\/span><i><span style=\"font-weight: 400;\">modules<\/span><\/i><span style=\"font-weight: 400;\">\u201d folder which are used for invoking the scripts and declaring the global variables.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here is the snapshot of the <\/span><i><span style=\"font-weight: 400;\">main.tf <\/span><\/i><span style=\"font-weight: 400;\">code.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1659\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/main_terraform_file-1024x633.png\" alt=\"Terraform Main Script\" width=\"1024\" height=\"633\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/main_terraform_file-1024x633.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/main_terraform_file-300x185.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/main_terraform_file-768x475.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/main_terraform_file.png 1204w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">In the &#8220;provider&#8221; section we provide our aws &#8220;access_key&#8221; and &#8220;secret_key&#8221; and the region where we need to create our bucket.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Since we are creating S3 using terraform modules, we need to add an S3 module to create an S3 bucket.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">For this, we will use the keyword \u201cmodule\u201d and the name of the modules (folder) which we have created earlier.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">In argument &#8220;source&#8221;, we will provide a source to the S3 module.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">For &#8220;bucket name&#8221;, from the <\/span><i><span style=\"font-weight: 400;\">modules\/var.tf<\/span><\/i><span style=\"font-weight: 400;\"> we defined var.bucket name in <\/span><i><span style=\"font-weight: 400;\">variables.tf<\/span><\/i><span style=\"font-weight: 400;\">.<\/span><\/li>\n<\/ol>\n<h4><b>Step 5: Add all the variables<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">\u00a0This is the variables, where we enter the details of these variables when we run the script.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1660\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/common-variables-1024x535.png\" alt=\"Common Variables\" width=\"1024\" height=\"535\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/common-variables-1024x535.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/common-variables-300x157.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/common-variables-768x401.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/common-variables.png 1202w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">From the above code we give the values for Access key, Secret key, Region and the Bucket name.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">So, We done our code. Now we can execute our code from <\/span><b>CLI<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h3><strong>RUN TERRAFORM CODE FROM OUR SYSTEM<\/strong><\/h3>\n<p><span style=\"font-weight: 400;\">In the above sections, we have explained the code and why it is required. We have completed writing the code that is required to create the S3 bucket, now it\u2019s time to execute the code using the following commands.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We are using Visual Source Code to run this example project. Here is the steps to execute this script:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Open Visual Source Code<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Open menu \u201c<\/span><i><span style=\"font-weight: 400;\">Terminal<\/span><\/i><span style=\"font-weight: 400;\">\u201d\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Click on \u201c<\/span><i><span style=\"font-weight: 400;\">New Terminal<\/span><\/i><span style=\"font-weight: 400;\">\u201d window (This is the place where we will run all the commands to execute the script)<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Here are the snapshots of the terminal window for your reference. You can follow the same steps to execute the terraform scripts.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1661\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terminal-window-1-1024x288.png\" alt=\"Terminal Window 1\" width=\"1024\" height=\"288\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terminal-window-1-1024x288.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terminal-window-1-300x84.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terminal-window-1-768x216.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terminal-window-1.png 1202w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1662\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terminal_window_2-1024x282.png\" alt=\"\" width=\"1024\" height=\"282\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terminal_window_2-1024x282.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terminal_window_2-300x83.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terminal_window_2-768x211.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terminal_window_2.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Here is the three <\/span><a href=\"https:\/\/www.terraform.io\/cli\/commands\"><span style=\"font-weight: 400;\">commands<\/span><\/a><span style=\"font-weight: 400;\"> that is required to execute this script from the CLI:<\/span><\/p>\n<ul>\n<li aria-level=\"1\"><b>init:<\/b> <span style=\"font-weight: 400;\">This command is used to initialize a working directory containing Terraform configuration files. This is the first command that should be run after writing a new Terraform configuration or cloning an existing one from version control.<\/span><\/li>\n<\/ul>\n<ul>\n<li aria-level=\"1\"><b>plan: <\/b><span style=\"font-weight: 400;\">The terraform plan command creates an execution plan, which lets you preview the changes that Terraform plans to make to your infrastructure.<\/span><\/li>\n<\/ul>\n<ul>\n<li aria-level=\"1\"><b>apply:<\/b> <span style=\"font-weight: 400;\">This command performs a plan just like terraform plan does, but then actually carries out the planned changes to each resource. It asks for confirmation from the user before making any changes, unless it was explicitly told to skip approval. Use &#8220;terraform apply -auto-approve&#8221; if you want to execute it without asking for confirmation.<\/span> <span style=\"font-weight: 400;\">So after the apply command execution s3 bucket was created successfully. You can check your bucket in aws console.<\/span><\/li>\n<\/ul>\n<ul>\n<li aria-level=\"1\"><b>destroy: <\/b><span style=\"font-weight: 400;\">For delete your bucket run terraform destroy command. It shows the destroy plan of our code and asks for confirmation. Give yes to that confirmation and delete the bucket.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">The following screenshots shows that console messages for executing the above commands:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1667\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_init-1024x736.png\" alt=\"Terraform Init\" width=\"1024\" height=\"736\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_init-1024x736.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_init-300x216.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_init-768x552.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_init.png 1196w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1663\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_1-1024x513.png\" alt=\"Terraform Plan 1\" width=\"1024\" height=\"513\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_1-1024x513.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_1-300x150.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_1-768x385.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_1.png 1202w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1664\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_2-1024x453.png\" alt=\"Terraform Plan 2\" width=\"1024\" height=\"453\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_2-1024x453.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_2-300x133.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_2-768x340.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_2.png 1202w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1665\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_3-1024x580.png\" alt=\"Terraform Plan 3\" width=\"1024\" height=\"580\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_3-1024x580.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_3-300x170.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_3-768x435.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_3.png 1198w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1666\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_4-1024x370.png\" alt=\"Terraform Plan 4\" width=\"1024\" height=\"370\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_4-1024x370.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_4-300x108.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_4-768x277.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/terraform_plan_4.png 1196w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now you can check the AWS console to see a new S3 bucket is created. Here is how it looks:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1668\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/s3_bucket_1-1024x136.png\" alt=\"S3 Bucket 1\" width=\"1024\" height=\"136\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/s3_bucket_1-1024x136.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/s3_bucket_1-300x40.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/s3_bucket_1-768x102.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/s3_bucket_1.png 1208w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1669\" src=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/s3_bucket_2-1024x523.png\" alt=\"S3 Bucket 2\" width=\"1024\" height=\"523\" srcset=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/s3_bucket_2-1024x523.png 1024w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/s3_bucket_2-300x153.png 300w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/s3_bucket_2-768x392.png 768w, https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/s3_bucket_2.png 1186w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Hope you liked this article!!. With this, we have learned how to create a S3 bucket using terraform scripts through CLI commands. In our next article, we will explain how to achieve the same objective using the <strong>Terraform Cloud<\/strong>.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Happy reading!!<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, we are going to explain how to create S3 Bucket using Terraform Script from CLI. This is one of the first blog posts on the Terraform blog series we have planned to publish in this blog. We are providing consulting services for Terraform and also helping companies to write Terraform scripts [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":1672,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[424],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Create a S3 Bucket using Terraform Script from CLI? | easydeploy.io<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Create a S3 Bucket using Terraform Script from CLI? | easydeploy.io\" \/>\n<meta property=\"og:description\" content=\"In this blog post, we are going to explain how to create S3 Bucket using Terraform Script from CLI. This is one of the first blog posts on the Terraform blog series we have planned to publish in this blog. We are providing consulting services for Terraform and also helping companies to write Terraform scripts [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/\" \/>\n<meta property=\"og:site_name\" content=\"easydeploy.io\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-12T07:49:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-12T08:39:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/aws-s3-bucket-terraform-script-cli.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1110\" \/>\n\t<meta property=\"og:image:height\" content=\"546\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Krishna Srinivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Krishna Srinivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/\"},\"author\":{\"name\":\"Krishna Srinivasan\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/54128f8cae0bc181f1d70234db269eb4\"},\"headline\":\"How To Create a S3 Bucket using Terraform Script from CLI?\",\"datePublished\":\"2022-07-12T07:49:36+00:00\",\"dateModified\":\"2022-07-12T08:39:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/\"},\"wordCount\":1045,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/aws-s3-bucket-terraform-script-cli.png\",\"articleSection\":[\"Terraform\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/\",\"name\":\"How To Create a S3 Bucket using Terraform Script from CLI? | easydeploy.io\",\"isPartOf\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/aws-s3-bucket-terraform-script-cli.png\",\"datePublished\":\"2022-07-12T07:49:36+00:00\",\"dateModified\":\"2022-07-12T08:39:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#primaryimage\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/aws-s3-bucket-terraform-script-cli.png\",\"contentUrl\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/aws-s3-bucket-terraform-script-cli.png\",\"width\":1110,\"height\":546,\"caption\":\"How to Create S3 Bucket Using Terraform?\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.easydeploy.io\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Create a S3 Bucket using Terraform Script from CLI?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#website\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/\",\"name\":\"easydeploy.io\",\"description\":\"A Cloud Architect Company\",\"publisher\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.easydeploy.io\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#organization\",\"name\":\"EasyDeploy Technologies Pvt Ltd\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2019\/02\/easydeploy.png\",\"contentUrl\":\"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2019\/02\/easydeploy.png\",\"width\":536,\"height\":100,\"caption\":\"EasyDeploy Technologies Pvt Ltd\"},\"image\":{\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/54128f8cae0bc181f1d70234db269eb4\",\"name\":\"Krishna Srinivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6183899524dd850ce183daff860b2518?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6183899524dd850ce183daff860b2518?s=96&d=mm&r=g\",\"caption\":\"Krishna Srinivasan\"},\"url\":\"https:\/\/www.easydeploy.io\/blog\/author\/krishna\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Create a S3 Bucket using Terraform Script from CLI? | easydeploy.io","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/","og_locale":"en_GB","og_type":"article","og_title":"How To Create a S3 Bucket using Terraform Script from CLI? | easydeploy.io","og_description":"In this blog post, we are going to explain how to create S3 Bucket using Terraform Script from CLI. This is one of the first blog posts on the Terraform blog series we have planned to publish in this blog. We are providing consulting services for Terraform and also helping companies to write Terraform scripts [&hellip;]","og_url":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/","og_site_name":"easydeploy.io","article_published_time":"2022-07-12T07:49:36+00:00","article_modified_time":"2022-07-12T08:39:07+00:00","og_image":[{"width":1110,"height":546,"url":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/aws-s3-bucket-terraform-script-cli.png","type":"image\/png"}],"author":"Krishna Srinivasan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Krishna Srinivasan","Estimated reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#article","isPartOf":{"@id":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/"},"author":{"name":"Krishna Srinivasan","@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/54128f8cae0bc181f1d70234db269eb4"},"headline":"How To Create a S3 Bucket using Terraform Script from CLI?","datePublished":"2022-07-12T07:49:36+00:00","dateModified":"2022-07-12T08:39:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/"},"wordCount":1045,"commentCount":0,"publisher":{"@id":"https:\/\/www.easydeploy.io\/blog\/#organization"},"image":{"@id":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#primaryimage"},"thumbnailUrl":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/aws-s3-bucket-terraform-script-cli.png","articleSection":["Terraform"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/","url":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/","name":"How To Create a S3 Bucket using Terraform Script from CLI? | easydeploy.io","isPartOf":{"@id":"https:\/\/www.easydeploy.io\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#primaryimage"},"image":{"@id":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#primaryimage"},"thumbnailUrl":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/aws-s3-bucket-terraform-script-cli.png","datePublished":"2022-07-12T07:49:36+00:00","dateModified":"2022-07-12T08:39:07+00:00","breadcrumb":{"@id":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#primaryimage","url":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/aws-s3-bucket-terraform-script-cli.png","contentUrl":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2022\/07\/aws-s3-bucket-terraform-script-cli.png","width":1110,"height":546,"caption":"How to Create S3 Bucket Using Terraform?"},{"@type":"BreadcrumbList","@id":"https:\/\/www.easydeploy.io\/blog\/s3-bucket-aws-terraform-cli-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.easydeploy.io\/blog\/"},{"@type":"ListItem","position":2,"name":"How To Create a S3 Bucket using Terraform Script from CLI?"}]},{"@type":"WebSite","@id":"https:\/\/www.easydeploy.io\/blog\/#website","url":"https:\/\/www.easydeploy.io\/blog\/","name":"easydeploy.io","description":"A Cloud Architect Company","publisher":{"@id":"https:\/\/www.easydeploy.io\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.easydeploy.io\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/www.easydeploy.io\/blog\/#organization","name":"EasyDeploy Technologies Pvt Ltd","url":"https:\/\/www.easydeploy.io\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2019\/02\/easydeploy.png","contentUrl":"https:\/\/www.easydeploy.io\/blog\/wp-content\/uploads\/2019\/02\/easydeploy.png","width":536,"height":100,"caption":"EasyDeploy Technologies Pvt Ltd"},"image":{"@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/54128f8cae0bc181f1d70234db269eb4","name":"Krishna Srinivasan","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.easydeploy.io\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6183899524dd850ce183daff860b2518?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6183899524dd850ce183daff860b2518?s=96&d=mm&r=g","caption":"Krishna Srinivasan"},"url":"https:\/\/www.easydeploy.io\/blog\/author\/krishna\/"}]}},"_links":{"self":[{"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/posts\/1655"}],"collection":[{"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/comments?post=1655"}],"version-history":[{"count":2,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/posts\/1655\/revisions"}],"predecessor-version":[{"id":1671,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/posts\/1655\/revisions\/1671"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/media\/1672"}],"wp:attachment":[{"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/media?parent=1655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/categories?post=1655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.easydeploy.io\/blog\/wp-json\/wp\/v2\/tags?post=1655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}