-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
72 lines (60 loc) · 1.51 KB
/
main.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
terraform {
backend "s3" {
encrypt = "true"
}
}
provider "aws" {
region = var.region
version = "~> 2.0"
}
resource "aws_iam_role" "codebuild_role" {
name = "${var.name}-codebuild"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "codebuild.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
EOF
}
data "template_file" "codebuild_policy" {
template = file("./codebuild-role-policy.tpl")
vars = {
kms_key_arns = var.kms_key_arns
ssm_parameter_arns = var.ssm_parameter_arns
}
}
resource "aws_iam_role_policy" "codebuild_policy" {
name = "${var.name}-codebuild-policy"
role = aws_iam_role.codebuild_role.id
policy = data.template_file.codebuild_policy.rendered
}
resource "aws_codebuild_webhook" "codebuild_webhook" {
project_name = var.name
branch_filter = "master"
}
module "codebuild_project" {
source = "github.com/jch254/terraform-modules//codebuild-project?ref=1.0.5"
name = var.name
codebuild_role_arn = aws_iam_role.codebuild_role.arn
build_docker_image = var.build_docker_image
build_docker_tag = var.build_docker_tag
source_type = var.source_type
buildspec = var.buildspec
source_location = var.source_location
cache_bucket = var.cache_bucket
}
module "webapp" {
source = "github.com/jch254/terraform-modules//web-app?ref=1.0.5"
bucket_name = var.bucket_name
dns_names = var.dns_names
route53_zone_id = var.route53_zone_id
acm_arn = var.acm_arn
}