Deploying the AWS services VPC, Subnet, RDS, S3

Creating the VPC and Subnet from Terraform:                We can create the VPC and subnet by using terraform, using the terraform registry...

Creating the VPC and Subnet from Terraform:

               We can create the VPC and subnet by using terraform, using the terraform registry taking the code, change the code for our case. run the terraform commands. build the AWS VPC and subnet.

VPC code:

resource "aws_vpc" "main" {

  cidr_block       = ""

  instance_tenancy = "default"

  tags = {

    Name = "main"



“main” need to change our aws custom VPC name, here I am going to give as “techiev-vpc”

For the Cidr_block,  I am going to use the network

Instance tendency, tags kept the same default, main

Subnet code: 

resource "aws_subnet" "main" {

  vpc_id     =

  cidr_block = ""

  tags = {

    Name = "Main"



Code explanation:

“Main” needs to change our aws custom subnet name, here I am going to give as “techiev-subnet”

For the VPC id need to use our custom VPC name as “”

For the Cidr_block, I am going to use the network so that we can use the 32766 IP address. Tags kept leave it as main only.

Now will run the code using the below commands

terraform init

terraform plan

terraform apply

In this step, it asks for verification, so need to give “yes”.

For the Verification, check the AWS VPC services.

So we successfully created the AWS VPC, subnet using terraform. If we don’t want this VPC and subnet use the terraform destroy command to delete it.

Creating the RDS using Terraform:

RDS is one of the services used for database provisioning. I am going to take the basic usage code from the terraform registry to create the RDS.

RDS code:

resource "aws_db_instance" "default" {

  allocated_storage    = 10

  engine               = "mysql"

  engine_version       = "5.7"

  instance_class       = "db.t3.micro"

  name                 = "mydb"

  username             = "foo"

  password             = "foobarbaz"

  parameter_group_name = "default.mysql5.7"

  skip_final_snapshot  = true


Code explanation:

The resource “aws_db_instance”- we are going to create the RDS, It was basically a database instance, so will define as aws_db_instance.

For the DB instance name use our custom name instead of the default, here going to mention “Techiev-DB”.

Allocated storage needs to be defined in the numbers, it takes the numbers in gibibytes.

The engine need to mention the database engine name, Aws has several engines such as mysql, MariaDB, postsql, Oracle, Amazon aurora. So choose anyone for our use cases, 

For us going to use the mysql.

Every engine has versions, so we need to define the version, here I am going to use mysql 8.0.

AWS has the DB instance types(standard, memory-optimized, Burstable), we need to choose the type for our requirements.

For the name, we need to provide the database name. Username and password also set a custom name and password.

Parameter groups can give the default. if already have the custom parameter groups, we can use the custom parameter instead of the default one.

If we want to skip the snapshot of the database, we can give the option “true” in the skip_final_snapshot.

After adding the code inside the terraform file save and run the commands.

terraform init

terraform plan

terraform apply

Now check the AWS console, it definitely automatically created the rds instance.

Now other settings in the RDS kept using the default one, we can customize all the settings using terraform itself, In the next blogs will see to configure RDS as a customized Terraform code.

Creating the S3 Bucket:

 We can create the S3 bucket using the terraform, going to use the example terraform code from the terraform registry.

S3 code:

resource "aws_s3_bucket" "b" {

  bucket = "my-tf-test-bucket"

  acl    = "private"

  tags = {

    Name        = "My bucket"

    Environment = "Dev"



Code explanation:

Resource “aws_s3_bucket” kept as same for “b” we can give anything, in my case give as my_first_bucket.

   Bucket name, we need to mention the name of our bucket.

   ACL means access control list, it enables the buckets and objects. for the security reason kept private.

   For the Tags, we can give them to our used case.

   The environment can be given as dev, QA, prod, and pre-prod.

Once all the above codes are updated save them and be ready to run the terraform command.

Run the below commands.

terraform init

terraform plan

terraform plan

Check the aws console to whether the s3 bucket was created.

We can destroy the s3 bucket anytime using the terraform destroy.

So, now we learned the basics of terraforming, creating the AWS services such as EC2, S3, RDS, and VPC using terraform. 

Now we have created the aws services using the basics only will see the advanced level of all the aws services one by one. 

-----------------------------------------!!!Happy Learning With Techiev!!!! ---------------------------------------



Techie View: Deploying the AWS services VPC, Subnet, RDS, S3
Deploying the AWS services VPC, Subnet, RDS, S3
Techie View
Loaded All Posts Not found any posts VIEW ALL View Full Article Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy