forked from Kholoud-ouda/StaticWebsiteOnAWS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
5-codepipeline.tf
60 lines (55 loc) · 1.83 KB
/
5-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
########################################################################################
###### Pipeline to deploy the static web site to s3 bucket. The pipeline ######
#### has 2 stages. 1- for pulling code 2- deploy on s3(bucket name need to be ####
### passed as a varibale). ###
########################################################################################
resource "aws_codepipeline" "this" {
count = "${var.environmentNumber}"
name = "${var.project}-${var.environment[count.index]}-FrontEnd-Pipeline"
role_arn = "${aws_iam_role.codePipelineRole.arn}"
artifact_store {
location = "${aws_s3_bucket.artifactsBucket.bucket}"
type = "S3"
}
stage {
name = "Source"
action {
name = "Source"
category = "Source"
owner = "AWS"
provider = "CodeCommit"
version = "1"
output_artifacts = ["SourceArtifact"]
configuration = {
RepositoryName = "${var.project}"
BranchName = "${var.repoBranch[count.index]}"
}
}
}
stage {
name = "Build"
action {
name = "Build"
category = "Build"
owner = "AWS"
provider = "CodeBuild"
version = "1"
input_artifacts = ["SourceArtifact"]
output_artifacts = ["BuildArtifact"]
configuration = {
ProjectName = "${aws_codebuild_project.this.arn}"
EnvironmentVariables = jsonencode([
{
name = "BUCKET_NAME"
value = "${aws_s3_bucket.this[count.index].bucket}"
},
{
name = "BUILD_ENV"
value = "${lower(var.environment[count.index])}"
type = "PLAINTEXT"
}
])
}
}
}
}