-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
73 lines (57 loc) · 1.61 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
provider "aws" {
region = var.region
}
resource "aws_s3_bucket" "frontend" {
bucket = "my-frontend-bucket"
}
resource "aws_s3_bucket_acl" "frontend" {
bucket = aws_s3_bucket.frontend.bucket
acl = "public-read"
}
resource "aws_s3_bucket_website_configuration" "frontend" {
bucket = aws_s3_bucket.frontend.bucket
index_document {
suffix = "index.html"
}
error_document {
key = "error.html"
}
}
output "bucket_url" {
value = "http://${aws_s3_bucket.frontend.bucket}.s3-website-${var.region}.amazonaws.com"
}
resource "aws_elastic_beanstalk_application" "my_app" {
name = "my-app"
description = "My application"
}
resource "aws_elastic_beanstalk_environment" "backend_beanstalk" {
name = "my-app-env"
application = aws_elastic_beanstalk_application.my_app.name
solution_stack_name = "64bit Amazon Linux 2 v3.4.10 running Node.js 14"
setting {
namespace = "aws:elasticbeanstalk:environment"
name = "EnvironmentType"
value = "SingleInstance"
}
setting {
namespace = "aws:elasticbeanstalk:application:environment"
name = "NODE_ENV"
value = "production"
}
}
output "beanstalk_url" {
value = aws_elastic_beanstalk_environment.backend_beanstalk.endpoint_url
}
resource "aws_db_instance" "mysql_db" {
identifier = "mydb"
engine = "mysql"
instance_class = "db.t2.micro"
db_name = "mydb"
username = var.db_username
password = var.db_password
allocated_storage = 20
storage_type = "gp2"
}
output "rds_endpoint" {
value = aws_db_instance.mysql_db.endpoint
}