Skip to content

Commit e579fd0

Browse files
authored
Merge pull request #6 from rearc/mwkaufman/codebuild_image
Parameterize repo_path
2 parents 1fc4bdb + 4e8ac90 commit e579fd0

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

codebuild.tf

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ resource "aws_codebuild_project" "build" {
7676
value = "${jsonencode(var.task_role_arn)}"
7777
}
7878

79+
environment_variable {
80+
name = "REPO_PATH"
81+
value = "${jsonencode(var.repo_path)}"
82+
}
83+
7984
}
8085

8186
logs_config {
@@ -87,6 +92,7 @@ resource "aws_codebuild_project" "build" {
8792

8893
source {
8994
type = "CODEPIPELINE"
95+
buildspec = "${var.repo_path}/buildspec.yml"
9096
}
9197

9298
vpc_config {
@@ -162,6 +168,11 @@ resource "aws_codebuild_project" "e2e_tests" {
162168
value = "${jsonencode(var.task_role_arn)}"
163169
}
164170

171+
environment_variable {
172+
name = "REPO_PATH"
173+
value = "${jsonencode(var.repo_path)}"
174+
}
175+
165176
}
166177

167178
logs_config {
@@ -173,7 +184,7 @@ resource "aws_codebuild_project" "e2e_tests" {
173184

174185
source {
175186
type = "CODEPIPELINE"
176-
buildspec = "buildspec-cypress.yml"
187+
buildspec = "${var.repo_path}/buildspec-cypress.yml"
177188
}
178189

179190
vpc_config {
@@ -249,6 +260,11 @@ resource "aws_codebuild_project" "unit_tests" {
249260
value = "${jsonencode(var.task_role_arn)}"
250261
}
251262

263+
environment_variable {
264+
name = "REPO_PATH"
265+
value = "${jsonencode(var.repo_path)}"
266+
}
267+
252268
}
253269

254270
logs_config {
@@ -260,7 +276,7 @@ resource "aws_codebuild_project" "unit_tests" {
260276

261277
source {
262278
type = "CODEPIPELINE"
263-
buildspec = "buildspec-rspec.yml"
279+
buildspec = "${var.repo_path}/buildspec-rspec.yml"
264280
}
265281

266282
vpc_config {
@@ -336,6 +352,11 @@ resource "aws_codebuild_project" "publish" {
336352
value = "${jsonencode(var.task_role_arn)}"
337353
}
338354

355+
environment_variable {
356+
name = "REPO_PATH"
357+
value = "${jsonencode(var.repo_path)}"
358+
}
359+
339360
}
340361

341362
logs_config {
@@ -347,7 +368,7 @@ resource "aws_codebuild_project" "publish" {
347368

348369
source {
349370
type = "CODEPIPELINE"
350-
buildspec = "buildspec-publish.yml"
371+
buildspec = "${var.repo_path}/buildspec-publish.yml"
351372
}
352373

353374
vpc_config {
@@ -423,6 +444,11 @@ resource "aws_codebuild_project" "db_migrate" {
423444
value = "${jsonencode(var.task_role_arn)}"
424445
}
425446

447+
environment_variable {
448+
name = "REPO_PATH"
449+
value = "${jsonencode(var.repo_path)}"
450+
}
451+
426452
}
427453

428454
logs_config {
@@ -434,7 +460,7 @@ resource "aws_codebuild_project" "db_migrate" {
434460

435461
source {
436462
type = "CODEPIPELINE"
437-
buildspec = "buildspec-db_migrate.yml"
463+
buildspec = "${var.repo_path}/buildspec-db_migrate.yml"
438464
}
439465

440466
vpc_config {
@@ -510,6 +536,11 @@ resource "aws_codebuild_project" "update_service" {
510536
value = "${jsonencode(var.task_role_arn)}"
511537
}
512538

539+
environment_variable {
540+
name = "REPO_PATH"
541+
value = "${jsonencode(var.repo_path)}"
542+
}
543+
513544
}
514545

515546
logs_config {
@@ -521,7 +552,7 @@ resource "aws_codebuild_project" "update_service" {
521552

522553
source {
523554
type = "CODEPIPELINE"
524-
buildspec = "buildspec-update_service.yml"
555+
buildspec = "${var.repo_path}/buildspec-update_service.yml"
525556
}
526557

527558
vpc_config {

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,10 @@ variable "e2e_image" {
148148
type = string
149149
default = "cypress/browsers:chrome69"
150150
description = "Docker image for e2e stages"
151+
}
152+
153+
variable "repo_path" {
154+
type = string
155+
default = "."
156+
description = "Path in repository to look for Dockerfile and buildspecs"
151157
}

0 commit comments

Comments
 (0)