-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
executable file
·86 lines (70 loc) · 1.67 KB
/
Copy pathmain.tf
File metadata and controls
executable file
·86 lines (70 loc) · 1.67 KB
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
75
76
77
78
79
80
81
82
83
84
85
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
# Configure the AWS Provider
provider "aws" {
region = "us-east-1"
shared_credentials_file = "./credentials"
}
module "chatterbox-api" {
# changed module from container to template which gives us an aws_launch_template
source = "git::https://github.com/CSSE6400/terraform//template"
image = "ghcr.io/csse6400/scalability-jamilboashash:main"
instance_type = "c4.large"
environment = {}
ports = {
"80" = "5000"
}
github_user = var.github_user
github_pat = var.github_pat
storage_size = 40
# changed .name to .id as the launch_template needs ids
security_groups = [aws_security_group.chatterbox-api.id]
tags = {
Name = "chatterbox-api"
}
}
resource "aws_instance" "chatterbox-api" {
# ami = "ami-0a8b4cd432b1c3063"
instance_type = "c4.large"
security_groups = [aws_security_group.chatterbox-api.name]
launch_template {
id = module.chatterbox-api.id
version = "$Latest"
}
tags = {
Name = "chatterbox"
}
}
# generates the api.txt with the APIs URL
resource "local_file" "url" {
content = aws_instance.chatterbox-api.public_ip
filename = "./api.txt"
}
resource "aws_security_group" "chatterbox-api" {
name = "chatterbox-api"
description = "Chatterbox server SSH access and API endpoint HTTP access"
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 22
to_port = 22
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"]
}
}