Skip to content
Merged
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
16 changes: 11 additions & 5 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ resource "aws_security_group" "backend" {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["112.134.144.32/32"] #My IP address
cidr_blocks = ["0.0.0.0/0"] #My IP address
}

ingress {
from_port = 3000
to_port = 3000
from_port = 5000
to_port = 5000
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] #App port
}
Expand All @@ -121,7 +121,7 @@ resource "aws_security_group" "backend" {

# AWS EC2 Instance for Backend
resource "aws_instance" "backend" {
ami = "ami-0c02fb55956c7d316"
ami = "ami-03f9680ef0c07a3d1"
instance_type = "t3.micro"
subnet_id = aws_subnet.main.id
vpc_security_group_ids = [aws_security_group.backend.id]
Expand Down Expand Up @@ -154,6 +154,12 @@ resource "mongodbatlas_project" "issue_tracker" {
org_id = var.mongodb_org_id
}

resource "mongodbatlas_project_ip_access_list" "backend_access" {
project_id = mongodbatlas_project.issue_tracker.id
ip_address = aws_instance.backend.public_ip
comment = "Allow access from Backend EC2"
}

resource "mongodbatlas_cluster" "free_cluster" {
project_id = mongodbatlas_project.issue_tracker.id
name = "issue-tracker-free"
Expand Down Expand Up @@ -185,7 +191,7 @@ resource "vercel_deployment" "frontend_prod" {
resource "vercel_project_environment_variable" "api_url" {
project_id = vercel_project.frontend.id
key = "REACT_APP_API_URL"
value = "https://${aws_instance.backend.public_ip}:3000/api"
value = "http://${aws_instance.backend.public_ip}:5000/api"
target = ["production"]
}

Expand Down
5 changes: 5 additions & 0 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ output "custom_domain" {
output "ec2_public_ip" {
description = "EC2 Public IP"
value = aws_instance.backend.public_ip
}

output "ssh_connection" {
description = "SSH connection command"
value = "ssh -i ~/.ssh/issue-tracker-key.pem ec2-user@${aws_instance.backend.public_ip}"
}
72 changes: 50 additions & 22 deletions terraform/terraform.tfstate
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": 4,
"terraform_version": "1.5.7",
"serial": 21,
"serial": 39,
"lineage": "c5f764b6-5db0-0d43-a8bc-df41d8037f1a",
"outputs": {
"backend_url": {
"value": "https://54.161.119.55:3000",
"value": "https://54.174.186.182:3000",
"type": "string"
},
"ec2_public_ip": {
"value": "54.161.119.55",
"value": "54.174.186.182",
"type": "string"
},
"frontend_url": {
Expand All @@ -32,8 +32,8 @@
{
"schema_version": 1,
"attributes": {
"ami": "ami-0c02fb55956c7d316",
"arn": "arn:aws:ec2:us-east-1:053678525731:instance/i-0fcfbf9f6bbe41214",
"ami": "ami-03f9680ef0c07a3d1",
"arn": "arn:aws:ec2:us-east-1:053678525731:instance/i-0e2d84a39c215bb4e",
"associate_public_ip_address": true,
"availability_zone": "us-east-1b",
"capacity_reservation_specification": [
Expand Down Expand Up @@ -72,15 +72,15 @@
"host_id": "",
"host_resource_group_arn": null,
"iam_instance_profile": "",
"id": "i-0fcfbf9f6bbe41214",
"id": "i-0e2d84a39c215bb4e",
"instance_initiated_shutdown_behavior": "stop",
"instance_lifecycle": "",
"instance_market_options": [],
"instance_state": "running",
"instance_type": "t3.micro",
"ipv6_address_count": 0,
"ipv6_addresses": [],
"key_name": "",
"key_name": "issue-tracker-key",
"launch_template": [],
"maintenance_options": [
{
Expand All @@ -102,18 +102,18 @@
"password_data": "",
"placement_group": "",
"placement_partition_number": 0,
"primary_network_interface_id": "eni-0b7b142ade0b95ae9",
"private_dns": "ip-10-0-0-71.ec2.internal",
"primary_network_interface_id": "eni-0eca2a5656080fcf1",
"private_dns": "ip-10-0-0-138.ec2.internal",
"private_dns_name_options": [
{
"enable_resource_name_dns_a_record": false,
"enable_resource_name_dns_aaaa_record": false,
"hostname_type": "ip-name"
}
],
"private_ip": "10.0.0.71",
"private_ip": "10.0.0.138",
"public_dns": "",
"public_ip": "54.161.119.55",
"public_ip": "54.174.186.182",
"root_block_device": [
{
"delete_on_termination": true,
Expand All @@ -124,7 +124,7 @@
"tags": {},
"tags_all": {},
"throughput": 0,
"volume_id": "vol-0044720a11fb25f1f",
"volume_id": "vol-04a86b4baf0f569a7",
"volume_size": 8,
"volume_type": "gp2"
}
Expand Down Expand Up @@ -161,7 +161,8 @@
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwicmVhZCI6OTAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9",
"dependencies": [
"aws_security_group.backend",
"aws_subnet.main"
"aws_subnet.main",
"aws_vpc.main"
]
}
]
Expand Down Expand Up @@ -302,26 +303,26 @@
"0.0.0.0/0"
],
"description": "",
"from_port": 3000,
"from_port": 22,
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"protocol": "tcp",
"security_groups": [],
"self": false,
"to_port": 3000
"to_port": 22
},
{
"cidr_blocks": [
"112.134.144.32/32"
"0.0.0.0/0"
],
"description": "",
"from_port": 22,
"from_port": 5000,
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"protocol": "tcp",
"security_groups": [],
"self": false,
"to_port": 22
"to_port": 5000
}
],
"name": "issue-tracker-backend-sg",
Expand Down Expand Up @@ -486,7 +487,7 @@
"id": "Y2x1c3Rlcl9pZA==:NjhlMmFiZGFlMjM3N2EwMjk3ZmYwMmNl-Y2x1c3Rlcl9uYW1l:aXNzdWUtdHJhY2tlci1mcmVl-cHJvamVjdF9pZA==:NjhlMmE3MjdkYjk1YzA0Y2YzNDBhYTY3-cHJvdmlkZXJfbmFtZQ==:VEVOQU5U",
"labels": [],
"mongo_db_major_version": "8.0",
"mongo_db_version": "8.0.14",
"mongo_db_version": "8.0.16",
"mongo_uri": "mongodb://ac-a7lyfgg-shard-00-00.ffoquxf.mongodb.net:27017,ac-a7lyfgg-shard-00-01.ffoquxf.mongodb.net:27017,ac-a7lyfgg-shard-00-02.ffoquxf.mongodb.net:27017",
"mongo_uri_updated": "2025-10-05T17:33:32Z",
"mongo_uri_with_options": "mongodb://ac-a7lyfgg-shard-00-00.ffoquxf.mongodb.net:27017,ac-a7lyfgg-shard-00-01.ffoquxf.mongodb.net:27017,ac-a7lyfgg-shard-00-02.ffoquxf.mongodb.net:27017/?ssl=true\u0026authSource=admin\u0026replicaSet=atlas-qh4n6x-shard-0",
Expand Down Expand Up @@ -544,7 +545,7 @@
{
"schema_version": 0,
"attributes": {
"cluster_count": 0,
"cluster_count": 1,
"created": "2025-10-05T17:13:14Z",
"id": "68e2a727db95c04cf340aa67",
"name": "issue-tracker",
Expand All @@ -564,6 +565,32 @@
}
]
},
{
"mode": "managed",
"type": "mongodbatlas_project_ip_access_list",
"name": "backend_access",
"provider": "provider[\"registry.terraform.io/mongodb/mongodbatlas\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"aws_security_group": "",
"cidr_block": "54.174.186.182/32",
"comment": "Allow access from Backend EC2",
"id": "ZW50cnk=:NTQuMTc0LjE4Ni4xODI=-cHJvamVjdF9pZA==:NjhlMmE3MjdkYjk1YzA0Y2YzNDBhYTY3",
"ip_address": "54.174.186.182",
"project_id": "68e2a727db95c04cf340aa67",
"timeouts": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoyNzAwMDAwMDAwMDAwLCJyZWFkIjoyNzAwMDAwMDAwMDAwfX0=",
"dependencies": [
"aws_instance.backend",
"mongodbatlas_project.issue_tracker"
]
}
]
},
{
"mode": "managed",
"type": "vercel_deployment",
Expand Down Expand Up @@ -672,21 +699,22 @@
"comment": "",
"custom_environment_ids": [],
"git_branch": null,
"id": "dJFoP9CiFfCRENbi",
"id": "rr1uMPP5XTVbf7Up",
"key": "REACT_APP_API_URL",
"project_id": "prj_gHiloCgAI4CfCjbKkhCSghOcxwGi",
"sensitive": false,
"target": [
"production"
],
"team_id": null,
"value": "https://54.161.119.55:3000/api"
"value": "http://54.174.186.182:5000/api"
},
"sensitive_attributes": [],
"dependencies": [
"aws_instance.backend",
"aws_security_group.backend",
"aws_subnet.main",
"aws_vpc.main",
"vercel_project.frontend"
]
}
Expand Down
Loading
Loading