This repository has been archived by the owner on Jun 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask.tf
69 lines (55 loc) · 1.66 KB
/
task.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
# Create two Cloudwatch Log Groups for the backup container
resource "aws_cloudwatch_log_group" "stdout" {
name = "${var.name}-s3-backup-stdout"
retention_in_days = "7"
}
resource "aws_cloudwatch_log_group" "stderr" {
name = "${var.name}-s3-backup-stderr"
retention_in_days = "7"
}
module "s3_backup_container_definition" {
source = "github.com/mergermarket/tf_ecs_container_definition?ref=no-secrets"
name = "${var.name}-s3-backup"
image = var.docker_image
cpu = 512
memory = 512
container_env = merge(
var.backup_env,
{
"LOGSPOUT_CLOUDWATCHLOGS_LOG_GROUP_STDOUT" = "${var.name}-s3-backup-stdout"
"LOGSPOUT_CLOUDWATCHLOGS_LOG_GROUP_STDERR" = "${var.name}-s3-backup-stderr"
},
)
metadata = var.metadata
mountpoint = {
sourceVolume = "s3_backup_volume"
containerPath = var.bind_container_path
readOnly = "false"
}
}
module "s3_backup_taskdef" {
source = "github.com/mergermarket/tf_ecs_task_definition_with_task_role?ref=pre-assume-role"
family = "${var.name}-s3-backup"
container_definitions = [module.s3_backup_container_definition.rendered]
policy = data.aws_iam_policy_document.s3_backup_policy.json
volume = {
name = "s3_backup_volume"
host_path = var.bind_host_path
}
}
# Allow the task to sync files into the container
data "aws_iam_policy_document" "s3_backup_policy" {
statement {
effect = "Allow"
actions = [
"s3:ListBucket",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:DeleteObject",
]
resources = [
"arn:aws:s3:::${var.bucket_name}",
"arn:aws:s3:::${var.bucket_name}/*",
]
}
}