-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcode_pipeline.tf
77 lines (66 loc) · 1.87 KB
/
code_pipeline.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
resource "aws_codepipeline" "codepipeline" {
name = var.service_name
pipeline_type = var.code_pipeline_type
role_arn = var.code_pipeline_role == "" ? aws_iam_role.code_pipeline_role[0].arn : data.aws_iam_role.code_pipeline[0].arn
tags = merge(var.tags, {
tf_module = basename(path.module)
})
artifact_store {
location = var.artifact_bucket == "" ? module.s3_bucket.s3_bucket_id : data.aws_s3_bucket.codepipeline[0].bucket
type = "S3"
}
stage {
name = "Source"
action {
name = "ECR"
category = "Source"
owner = "AWS"
provider = "ECR"
version = "1"
output_artifacts = ["ecr_source"]
configuration = {
"ImageTag" : var.ecr_image_tag,
"RepositoryName" : var.ecr_repository_name
}
}
}
stage {
name = "Build"
action {
name = "CodeBuild"
category = "Build"
owner = "AWS"
provider = "CodeBuild"
version = "1"
input_artifacts = ["ecr_source"]
output_artifacts = ["image_definitions_json"]
configuration = {
"ProjectName" : aws_codebuild_project.this.name
}
}
}
stage {
name = "Deploy"
action {
name = "Deploy"
category = "Deploy"
owner = "AWS"
provider = "ECS"
input_artifacts = ["image_definitions_json"]
version = "1"
configuration = {
"ClusterName" : var.cluster_name,
"ServiceName" : var.service_name
"FileName" : "imagedefinitions.json"
}
}
}
dynamic "variable" {
for_each = var.code_pipeline_variables
content {
name = variable.value.name
default_value = variable.value.default_value
description = variable.value.description
}
}
}