Compare commits

..

6 Commits

5 changed files with 87 additions and 2 deletions
+1 -2
View File
@@ -5,5 +5,4 @@ aws-cli-config.txt
################
Terraform/.terraform*
Terraform/terra-ec2/.terraform*
**/.terraform*
+15
View File
@@ -0,0 +1,15 @@
services:
nginx:
image: nginx:stable-perl
container_name: nginx
restart: no
ports:
- "8080:80"
environment:
- NGINX_PORT=80
networks:
- nginx
networks:
nginx:
driver: bridge
+23
View File
@@ -0,0 +1,23 @@
services:
jenkins:
image: jenkins/jenkins:lts-jdk17
container_name: jenkins
restart: no
user: "1000:1000"
security_opt:
- no-new-privileges=true
volumes:
- "jenkins_home:/var/jenkins_home"
ports:
- 8080:8080
- 50000:50000
networks:
- jenkins-ntwk
volumes:
jenkins_home:
external: true
networks:
jenkins-ntwk:
driver: bridge
+40
View File
@@ -0,0 +1,40 @@
provider "aws" {
region = "ap-south-1"
}
# VPC
resource "aws_vpc" "TestVPC" { # Create a VPC
cidr_block = "172.16.0.0/16" # Specify CIDR block (IP range)
enable_dns_support = true # DNS support
enable_dns_hostnames = true # Hostname support
tags = {
Name = "TestVPC" # Name for VPC (on AWS)
}
}
# Subnet -> Associated w/ TestVPC
resource "aws_subnet" "TestSubnetOne" { # Create subnet
vpc_id = aws_vpc.TestVPC.id # Specify VPC under which subnet should be created
cidr_block = "172.16.1.0/24" # Specify segment of IP range (from VPC) for this subnet
availability_zone = "ap-south-1a" # Set availability zone
tags = {
Name = "TestSubnet1" # Name for subnet (on AWS)
}
}
# Internet gateway
# Route table
# |_ Route
# |_ Table association
# EC2 under TestVPC in TestSubnet1 IP
resource "aws_instance" "name" {
ami = "ami-0861f4e788f5069dd"
instance_type = "t2.micro"
key_name = "kshitij-personal-ed25519"
subnet_id = aws_subnet.TestSubnetOne.id
tags = {
Name = "EC2-TestSubnet1"
}
}
+8
View File
@@ -0,0 +1,8 @@
import boto3
session = boto3.Session (region_name = "ap-south-1")
ec2_instances = session.resource('ec2').instances.all()
for instance in ec2_instances:
print(f"ID: {instance.id}, State: {instance.state['Name']}, Type: {instance.instance_type}, Public IP: {instance.public_ip_address}")