From d341b81ed3c71f5856eaf5af3e3b5f54b435d831 Mon Sep 17 00:00:00 2001 From: Decfox Date: Sun, 19 May 2024 12:19:25 +0530 Subject: [PATCH] add trigger filters to ooniapi pipeline --- tf/environments/dev/main.tf | 5 ++++- tf/modules/ooniapi_service_deployer/main.tf | 18 ++++++++++++++++++ .../ooniapi_service_deployer/variables.tf | 4 ++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tf/environments/dev/main.tf b/tf/environments/dev/main.tf index 75ec2c6c..f7219004 100644 --- a/tf/environments/dev/main.tf +++ b/tf/environments/dev/main.tf @@ -67,6 +67,7 @@ module "adm_iam_roles" { source = "../../modules/adm_iam_roles" authorized_accounts = [ + "arn:aws:iam::${local.ooni_main_org_id}:user/mehul", "arn:aws:iam::${local.ooni_dev_org_id}:user/mehul", "arn:aws:iam::${local.ooni_dev_org_id}:user/art", "arn:aws:iam::${local.ooni_main_org_id}:user/art" @@ -317,6 +318,7 @@ module "ooniapi_ooniprobe_deployer" { repo = "ooni/backend" branch_name = "master" buildspec_path = "ooniapi/services/ooniprobe/buildspec.yml" + trigger_path = "ooniapi/services/ooniprobe/**" codestar_connection_arn = aws_codestarconnections_connection.oonidevops.arn codepipeline_bucket = aws_s3_bucket.ooniapi_codepipeline_bucket.bucket @@ -358,7 +360,6 @@ module "ooniapi_ooniprobe" { ) } - #### OONI Run service module "ooniapi_oonirun_deployer" { @@ -368,6 +369,7 @@ module "ooniapi_oonirun_deployer" { repo = "ooni/backend" branch_name = "master" buildspec_path = "ooniapi/services/oonirun/buildspec.yml" + trigger_path = "ooniapi/services/oonirun/**" codestar_connection_arn = aws_codestarconnections_connection.oonidevops.arn codepipeline_bucket = aws_s3_bucket.ooniapi_codepipeline_bucket.bucket @@ -415,6 +417,7 @@ module "ooniapi_ooniauth_deployer" { repo = "ooni/backend" branch_name = "master" buildspec_path = "ooniapi/services/ooniauth/buildspec.yml" + trigger_path = "ooniapi/services/ooniauth/**" codestar_connection_arn = aws_codestarconnections_connection.oonidevops.arn codepipeline_bucket = aws_s3_bucket.ooniapi_codepipeline_bucket.bucket diff --git a/tf/modules/ooniapi_service_deployer/main.tf b/tf/modules/ooniapi_service_deployer/main.tf index 15e8c429..a4b36200 100755 --- a/tf/modules/ooniapi_service_deployer/main.tf +++ b/tf/modules/ooniapi_service_deployer/main.tf @@ -201,6 +201,24 @@ resource "aws_codepipeline" "ooniapi" { aws_codebuild_project.ooniapi ] + trigger { + provider_type = "CodeStarSourceConnection" + + git_configuration { + source_action_name = "Source" + + push { + branches { + includes = ["master"] + } + file_paths { + includes = [var.trigger_path] + excludes = ["**/README.md"] + } + } + } + } + stage { action { diff --git a/tf/modules/ooniapi_service_deployer/variables.tf b/tf/modules/ooniapi_service_deployer/variables.tf index ff2b7c4c..f35a57bc 100644 --- a/tf/modules/ooniapi_service_deployer/variables.tf +++ b/tf/modules/ooniapi_service_deployer/variables.tf @@ -26,6 +26,10 @@ variable "repo" { default = "ooni/backend" } +variable "trigger_path" { + description = "path filter for push changes which trigger the codepipeline eg. ooniapi/services/oonirun/**" +} + variable "ecs_cluster_name" { description = "id of the cluster to deploy into" }