-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathapprunner.tf
92 lines (81 loc) · 2.22 KB
/
apprunner.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
data "external" "apprunner-deploy" {
program = ["ruby", "${path.module}/apprunner_deploy.rb"]
}
resource "aws_apprunner_service" "prd" {
service_name = "sponsor-app"
source_configuration {
image_repository {
image_configuration {
port = "3000"
runtime_environment_variables = merge(jsondecode(data.external.apprunner-deploy.result.runtime_environment_variables), {
})
runtime_environment_secrets = jsondecode(data.external.apprunner-deploy.result.runtime_environment_secrets)
}
image_identifier = data.external.apprunner-deploy.result.image_identifier
image_repository_type = "ECR"
}
authentication_configuration {
access_role_arn = aws_iam_role.app-runner-access.arn
}
auto_deployments_enabled = false
}
instance_configuration {
cpu = "256"
memory = "512"
instance_role_arn = aws_iam_role.SponsorApp.arn
}
health_check_configuration {
protocol = "TCP"
#path = "/site/sha"
healthy_threshold = 2
unhealthy_threshold = 3
interval = 5
}
tags = {
Name = "sponsor-app"
Environment = "production"
}
}
resource "aws_iam_role" "app-runner-access" {
name = "AppraSponsorApp"
description = "prd tf/iam.tf"
assume_role_policy = data.aws_iam_policy_document.app-runner-access-trust.json
}
data "aws_iam_policy_document" "app-runner-access-trust" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = [
"build.apprunner.amazonaws.com"
]
}
}
}
resource "aws_iam_role_policy" "app-runner-access" {
role = aws_iam_role.app-runner-access.name
policy = data.aws_iam_policy_document.app-runner-access.json
}
data "aws_iam_policy_document" "app-runner-access" {
statement {
effect = "Allow"
actions = [
"ecr:GetAuthorizationToken",
"sts:GetServiceBearerToken",
]
resources = ["*"]
}
statement {
effect = "Allow"
actions = [
"ecr:GetDownloadUrlForLayer",
"ecr:BatchCheckLayerAvailability",
"ecr:BatchGetImage",
"ecr:DescribeImages",
]
resources = [
aws_ecr_repository.app.arn,
]
}
}