DEV Community

Cover image for if you know plz tell me Ans.
Vaibhav Jain
Vaibhav Jain

Posted on

if you know plz tell me Ans.

Image description

can you tell me the error that when the error come and how to solve this.

Que. Here is all steps --

  1. so the question is i as creating a vpc.
  2. And in vpc i was creating two subnets one is public-subnet and one is the private-subnet.
  3. third step is the create a internet gabneteway and connect with this from vpc. 4 after all that i have created 2 routing tables for public-subnet and for private-subnet. 5 and the last step and the final step is create a instance in the public-subnet

Here is the my code =

`provider "aws" {
region = "ap-south-1"
}

resource "aws_vpc" "Mum-vpc" {

cidr_block = "192.168.10.0/24"

tags = {
"Name" = "Mum-vpc"
}
}

resource "aws_subnet" "pub-sub" {
vpc_id = aws_vpc.Mum-vpc.id
cidr_block = "192.168.10.0/25"
availability_zone = "ap-south-1a"

tags = {
"Name" = "pub-sub"
}
}

resource "aws_subnet" "pri-sub" {
vpc_id = aws_vpc.Mum-vpc.id
cidr_block = "192.168.10.128/25"
availability_zone = "ap-south-1b"

tags = {
"Name" = "pri-sub"
}
}

resource "aws_internet_gateway" "IGW" {
vpc_id = aws_vpc.Mum-vpc.id

tags = {
"Name" = "IGW"
}
}

resource "aws_route_table" "pub-rt" {
vpc_id = aws_vpc.Mum-vpc.id

route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.IGW.id
}
tags = {
Name = "pub-rt"
}
}

resource "aws_route_table" "pri-rt" {
vpc_id = aws_vpc.Mum-vpc.id
tags = {
Name = "pri-rt"
}

}

resource "aws_route_table_association" "pr-1" {
subnet_id = aws_subnet.pub-sub.id
route_table_id = aws_route_table.pub-rt.id

}

resource "aws_route_table_association" "pr-2" {
subnet_id = aws_subnet.pri-sub.id
route_table_id = aws_route_table.pri-rt.id

}

resource "aws_instance" "ex-instance" {
ami = "ami-074f77adfeee318d3"
instance_type = "t2.micro"
//vpc_security_group_ids = ["aws_vpc.Mum-vpc.id"]
//vpc_security_group_ids = "aws_vpc.Mum-vpc.id"
key_name = "mumbai_key"
subnet_id = aws_subnet.pub-sub.id
//associate_public_ip_address = true

tags = {
Name = "ex-instance"
}
}
`

Top comments (2)

Collapse
 
olddutchcap profile image
Onorio Catenacci

@jainvaibhav Your screenshot appears to be cut off so it would be very tough for anyone to advise you as to how to resolve this problem.

Also, you can do a few other things to increase the likelihood of getting a helpful answer:

1.) Tell people the OS you're using (don't assume people can guess from a screenshot)

2.) Tell people what are the steps you're taking before this error occurs

3.) Tell people (as best you can) the versions of the various pieces of software involved. That is what is the version of the AWS command line interface you're using. What version of terraform are you using?

Collapse
 
jainvaibhav profile image
Vaibhav Jain

ok i will resumbit this full image. And also i shere the code