|
@@ -20,6 +20,8 @@ resource "aws_codebuild_project" "this_no_artifact" {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ source_version = var.source_version
|
|
|
+
|
|
|
environment {
|
|
|
compute_type = "BUILD_GENERAL1_SMALL"
|
|
|
image = var.codebuild_image
|
|
@@ -35,7 +37,11 @@ resource "aws_codebuild_project" "this_no_artifact" {
|
|
|
}
|
|
|
|
|
|
resource "aws_ecr_repository" "this" {
|
|
|
- name = var.name
|
|
|
+ name = var.name
|
|
|
+
|
|
|
+ image_scanning_configuration {
|
|
|
+ scan_on_push = true
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
data "aws_iam_policy_document" "ecr_cross_account_policy" {
|
|
@@ -60,6 +66,22 @@ data "aws_iam_policy_document" "ecr_cross_account_policy" {
|
|
|
identifiers = [ for a in var.responsible_accounts[var.environment]: "arn:${var.aws_partition}:iam::${a}:root" ]
|
|
|
}
|
|
|
}
|
|
|
+ # Allow codebuild access
|
|
|
+ statement {
|
|
|
+ sid = "CodeBuildAccessPrincipal"
|
|
|
+ effect = "Allow"
|
|
|
+
|
|
|
+ actions = [
|
|
|
+ "ecr:GetDownloadUrlForLayer",
|
|
|
+ "ecr:BatchGetImage",
|
|
|
+ "ecr:BatchCheckLayerAvailability",
|
|
|
+ ]
|
|
|
+
|
|
|
+ principals {
|
|
|
+ type = "Service"
|
|
|
+ identifiers = ["codebuild.amazonaws.com"]
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
resource "aws_ecr_repository_policy" "this" {
|
|
@@ -80,6 +102,8 @@ resource "aws_codebuild_webhook" "this" {
|
|
|
}
|
|
|
|
|
|
resource "github_repository_webhook" "this" {
|
|
|
+ count = var.enable_webhooks ? 1 : 0
|
|
|
+
|
|
|
active = true
|
|
|
events = ["push"]
|
|
|
repository = data.github_repository.this.name
|