Skip to content

Created tf files for EC2, IAM, S3, VPC, SG and provider.tf #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Ignore transient lock info files created by terraform apply
.terraform.tfstate.lock.info

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
8 changes: 8 additions & 0 deletions Create-EC2-Instance/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "aws_instance" "ec2-instance" {
ami = "ami-04a81a99f5ec58529"
instance_type = "t2.micro"

tags = {
Name = "ashwan-isntance"
}
}
11 changes: 11 additions & 0 deletions Create-IAM-User/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

resource "aws_iam_user" "ashwan-user" {
name = "ashwan-cloud-user"
path = "/"
}

resource "aws_iam_access_key" "user_access_key" {
user = aws_iam_user.ashwan-user.name
}


3 changes: 3 additions & 0 deletions Create-S3-Bucket/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "aws_s3_bucket" "s3-bucket" {
bucket = "ashwan-bucket-terraform-cloudHub8877"
}
37 changes: 37 additions & 0 deletions Create-Security-Group/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

resource "aws_security_group" "ashwan_sg" {
name = "ashwan-sg"
description = "Security group with ports 22, 80, and 443 open"

ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}

tags = {
Name = "ashwan-sg"
}
}
52 changes: 52 additions & 0 deletions Create-VPC/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Create a VPC
resource "aws_vpc" "ashwan-vpc" {
cidr_block = "10.0.0.0/16"

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

# Creating private subnet
resource "aws_subnet" "private-subnet" {
cidr_block = "10.0.1.0/24"
vpc_id = aws_vpc.ashwan-vpc.id

tags = {
Name = "private-subnet"
}
}

# Creating public subnet
resource "aws_subnet" "public-subnet" {
cidr_block = "10.0.2.0/24"
vpc_id = aws_vpc.ashwan-vpc.id

tags = {
Name = "public-subnet"
}
}

# Internet Gateway
resource "aws_internet_gateway" "ashwan-igw" {
vpc_id = aws_vpc.ashwan-vpc.id

tags = {
Name = "ashwan-igw"
}
}

# Routing table
resource "aws_route_table" "ashwan-rt" {
vpc_id =aws_vpc.ashwan-vpc.id

route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.ashwan-igw.id
}
}

resource "aws_route_table_association" "public-sub" {
route_table_id = aws_route_table.ashwan-rt.id
subnet_id = aws_subnet.public-subnet.id
}
12 changes: 12 additions & 0 deletions provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.61.0"
}
}
}

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