This repository has been archived by the owner on Jan 23, 2025. It is now read-only.
forked from schubergphilis/terraform-aws-mcaf-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodepipeline.tf
98 lines (85 loc) · 2.47 KB
/
codepipeline.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
data "aws_iam_policy_document" "codepipeline_role_policy" {
statement {
actions = [
"s3:ListBucket",
"s3:ListBucketVersions",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:GetObjectAttributes",
"s3:GetObjectTagging",
"s3:PutObject"
]
resources = [
"arn:aws:s3:::${local.deployment_bucket}",
"arn:aws:s3:::${local.deployment_bucket}/*"
]
}
statement {
actions = [
"codebuild:BatchGetBuilds",
"codebuild:StartBuild"
]
resources = ["arn:aws:codepipeline:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:*"]
}
}
module "codepipeline_role" {
source = "github.com/schubergphilis/terraform-aws-mcaf-role?ref=v0.3.2"
name = "${var.workload_name}-pipeline"
create_policy = true
principal_identifiers = ["codepipeline.amazonaws.com"]
principal_type = "Service"
role_policy = data.aws_iam_policy_document.codepipeline_role_policy.json
tags = var.tags
permissions_boundary = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:policy/PermissionsBoundary"
}
resource "aws_codepipeline" "codepipeline" {
name = var.workload_name
role_arn = module.codepipeline_role.arn
tags = var.tags
artifact_store {
location = module.deployment_bucket.name
type = "S3"
}
stage {
name = "Source"
action {
name = "Source"
category = "Source"
output_artifacts = ["source_output"]
owner = "AWS"
provider = "S3"
version = "1"
configuration = {
S3Bucket = module.deployment_bucket.name
S3ObjectKey = "${var.workload_name}-source/workload.zip"
}
}
}
stage {
name = "Deploy"
action {
name = "Functions"
category = "Build"
input_artifacts = ["source_output"]
owner = "AWS"
provider = "CodeBuild"
run_order = 2
version = "1"
configuration = {
ProjectName = "${var.workload_name}-deploy-functions"
}
}
action {
name = "GlueJobs"
category = "Build"
input_artifacts = ["source_output"]
owner = "AWS"
provider = "CodeBuild"
run_order = 2
version = "1"
configuration = {
ProjectName = "${var.workload_name}-deploy-gluejobs"
}
}
}
}