-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcode_build.tf
101 lines (72 loc) · 2.16 KB
/
code_build.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
92
93
94
95
96
97
98
99
100
module "s3_bucket_code_build" {
source = "terraform-aws-modules/s3-bucket/aws"
bucket = "code-build-s3-bucket-${random_id.random_id.hex}"
acl = "private"
versioning = {
enabled = true
}
tags = merge(local.common_tags, {})
}
# CodeBuild
resource "aws_codebuild_project" "n8n_codebuild_project" {
name = "build-n8n-container"
description = "lorem ipsum"
build_timeout = 60
service_role = module.codebuild_admin_iam_assumable_role.iam_role_arn
artifacts {
type = "NO_ARTIFACTS"
#type = "S3"
#location = module.s3_bucket_code_build.s3_bucket_id
}
environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/standard:5.0"
type = "LINUX_CONTAINER"
image_pull_credentials_type = "CODEBUILD"
privileged_mode = true
environment_variable {
name = "AWS_DEFAULT_REGION"
value = data.aws_region.current.id
type = "PLAINTEXT"
}
environment_variable {
name = "AWS_ACCOUNT_ID"
value = data.aws_caller_identity.current.account_id
type = "PLAINTEXT"
}
environment_variable {
name = "IMAGE_TAG"
value = "latest"
type = "PLAINTEXT"
}
environment_variable {
name = "IMAGE_REPO_NAME"
value = split("/", aws_ecr_repository.n8n_ecr.arn)[1]
type = "PLAINTEXT"
}
environment_variable {
name = "ECS_SERVICE_NAME"
value = module.ecs-fargate.service_name
type = "PLAINTEXT"
}
}
source {
buildspec = file("${path.module}/buildspec.yml")
type = "GITHUB"
location = "https://github.com/msharma24/foxy-terraform-n8n.git"
git_clone_depth = 1
}
logs_config {
cloudwatch_logs {
group_name = module.codebuild_log_group.cloudwatch_log_group_name
}
}
tags = merge(local.common_tags, {})
}
module "codebuild_log_group" {
source = "terraform-aws-modules/cloudwatch/aws//modules/log-group"
version = "3.0.0"
name = "codebuild_log_group_${random_id.random_id.hex}"
retention_in_days = 7
tags = merge(local.common_tags, {})
}