-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
74 lines (66 loc) · 1.3 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.47.0"
}
}
}
provider "aws" {
region = "us-east-1"
}
variable "key" {
default = "jenkins-project"
}
variable "user" {
default = "techpro"
}
resource "aws_instance" "managed_nodes" {
ami = "ami-0230bd60aa48260c6"
instance_type = "t2.micro"
key_name = var.key
vpc_security_group_ids = [aws_security_group.tf-sec-gr.id]
iam_instance_profile = "jenkins-project-profile-${var.user}"
tags = {
Name = "jenkins_project"
}
}
resource "aws_security_group" "tf-sec-gr" {
name = "project-jenkins-sec-gr"
tags = {
Name = "project-jenkins-sec-gr"
}
ingress {
from_port = 22
protocol = "tcp"
to_port = 22
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 5000
protocol = "tcp"
to_port = 5000
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 3000
protocol = "tcp"
to_port = 3000
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 5432
protocol = "tcp"
to_port = 5432
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
protocol = -1
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
}
output "node_public_ip" {
value = aws_instance.managed_nodes.public_ip
}