-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
58 lines (49 loc) · 1.34 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
provider "aws" {
region = "us-east-1"
}
# Setup IAM Roles
resource "aws_iam_role" "apprunner_role" {
name = "apprunner-ecr-role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "build.apprunner.amazonaws.com"
}
}
]
})
}
resource "aws_iam_policy_attachment" "apprunner_policy_attachment" {
name = "apprunner-ecr-policy-attachment"
roles = [aws_iam_role.apprunner_role.name]
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSAppRunnerServicePolicyForECRAccess"
}
# Create an App Runner service
resource "aws_apprunner_service" "chessio_backend" {
service_name = "chessio-backend"
source_configuration {
image_repository {
image_configuration {
port = "8080"
}
image_identifier = "039612890043.dkr.ecr.us-east-1.amazonaws.com/awsxero/chessio-backend:latest"
image_repository_type = "ECR"
}
authentication_configuration {
access_role_arn = aws_iam_role.apprunner_role.arn
}
auto_deployments_enabled = true
}
instance_configuration {
cpu = "1024"
memory = "2048"
}
}
# Output the App Runner service URL
output "app_runner_service_url" {
value = aws_apprunner_service.chessio_backend.service_url
}