-
Notifications
You must be signed in to change notification settings - Fork 4
/
codepipeline.tf
118 lines (100 loc) · 2.9 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
resource "aws_s3_bucket" "codepipeline_bucket" {
bucket = "code-pipeline-${local.region}-${local.account_id}"
force_destroy = true
}
resource "aws_s3_bucket_server_side_encryption_configuration" "codepipeline_s3_sse" {
bucket = aws_s3_bucket.codepipeline_bucket.bucket
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
resource "aws_s3_bucket_public_access_block" "cpl_bkt_block_public_access" {
bucket = aws_s3_bucket.codepipeline_bucket.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
resource "aws_codepipeline" "demo_codepipeline" {
name = var.codepipeline_name
role_arn = aws_iam_role.codepipeline_role.arn
artifact_store {
location = aws_s3_bucket.codepipeline_bucket.bucket
type = "S3"
}
stage {
name = "Source"
action {
name = "Source"
category = "Source"
owner = "AWS"
provider = "CodeCommit"
version = "1"
output_artifacts = ["source_output"]
configuration = {
RepositoryName = aws_codecommit_repository.demo_codecommit_repo.repository_name
BranchName = var.codecommit_repo_branch_name
PollForSourceChanges = false
}
}
}
stage {
name = "Test"
action {
name = "Test"
category = "Build"
owner = "AWS"
provider = "CodeBuild"
version = "1"
input_artifacts = ["source_output"]
output_artifacts = ["test_output"]
configuration = {
ProjectName = aws_codebuild_project.demo_codebuild_test_project.name
}
}
action {
name = "Lint"
category = "Build"
owner = "AWS"
provider = "CodeBuild"
version = "1"
input_artifacts = ["source_output"]
output_artifacts = ["lint_output"]
configuration = {
ProjectName = aws_codebuild_project.demo_codebuild_lint_project.name
}
}
}
stage {
name = "Build"
action {
name = "Build"
category = "Build"
owner = "AWS"
provider = "CodeBuild"
version = "1"
input_artifacts = ["source_output"]
output_artifacts = ["build_output"]
configuration = {
ProjectName = aws_codebuild_project.demo_codebuild_project.name
}
}
}
stage {
name = "Deploy"
action {
name = "Deploy"
category = "Build"
owner = "AWS"
provider = "CodeBuild"
version = "1"
input_artifacts = ["source_output"]
output_artifacts = ["deploy_output"]
configuration = {
ProjectName = aws_codebuild_project.demo_codebuild_deploy_project.name
}
}
}
}