pulumi-aws icon indicating copy to clipboard operation
pulumi-aws copied to clipboard

Does pulumi support creating a pipeline that was triggered by git tag? Specifically using CodeStarSourceConnection?

Open renodesper opened this issue 10 months ago • 1 comments

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

Last year, AWS CodePipeline announced support for starting a pipeline execution on git tags pushed to repositories in GitHub, GitHub Enterprise Server, GitLab Cloud and Bitbucket Cloud using CodeStarSourceConnection source actions. Do we have support for this as well? Or is it already in the timeline?

In terraform, this is the most simple way to use it:

resource "aws_codepipeline" "pipeline" {
  name           = "${var.env}-${var.service_name}"
  pipeline_type  = "V2"
  execution_mode = "QUEUED"
  role_arn       = var.codepipeline_role_arn

  stage {
    name = "Source"

    action {
      name             = "Source"
      category         = "Source"
      owner            = "AWS"
      provider         = "CodeStarSourceConnection"
      version          = "1"
      output_artifacts = ["SourceArtifact"]
      region           = var.region

      configuration = {
        ConnectionArn        = var.codestar_connection
        FullRepositoryId     = "${var.team_name}/${var.repo_name}"
        BranchName           = var.repo_branch
        OutputArtifactFormat = "CODEBUILD_CLONE_REF"
        DetectChanges        = false
      }
    }
  }

  trigger {
    provider_type = "CodeStarSourceConnection"
    git_configuration {
      source_action_name = "Source"
      push {
        tags {
          includes = ["prod-*"]
        }
      }
    }
  }
}

There are a few things to note:

  1. There is a new field called "pipeline_type" which should be set to "V2"
  2. There is a new field called "execution_mode" which has multiple values, one of them is "QUEUED"
  3. "DetectChanges" field on "stage > action > configuration" should be set to false to avoid triggering the pipeline on every push
  4. There is a new section called "trigger" to set our trigger

Affected area/feature

renodesper avatar Mar 27 '24 04:03 renodesper

@renodesper is there a reason that you think pulumi doesn't support this feature? I don't see anything in the linked documentation that indicates that we do not support it. If you are having an issue can you provide us an example of a pulumi app where this is not working?

You can also use this tool to convert your Terraform configuration to pulumi https://www.pulumi.com/blog/converting-full-terraform-programs-to-pulumi/

corymhall avatar Mar 27 '24 14:03 corymhall

@renodesper is there a reason that you think pulumi doesn't support this feature? I don't see anything in the linked documentation that indicates that we do not support it. If you are having an issue can you provide us an example of a pulumi app where this is not working?

You can also use this tool to convert your Terraform configuration to pulumi https://www.pulumi.com/blog/converting-full-terraform-programs-to-pulumi/

I don't see the trigger section on the documentation. This one:

trigger {
    provider_type = "CodeStarSourceConnection"
    git_configuration {
      source_action_name = "Source"
      push {
        tags {
          includes = ["prod-*"]
        }
      }
    }
  }

I also tried using pulumi convert and the trigger section is nowhere to be found. It looks like convert didn't warn me about the missing section and just tried its best to convert what it knows.

renodesper avatar Mar 28 '24 06:03 renodesper

@renodesper it looks like in pulumi this is called triggers.

https://www.pulumi.com/registry/packages/aws/api-docs/codepipeline/pipeline/#triggers_nodejs

corymhall avatar Mar 28 '24 12:03 corymhall

I'll go ahead and close the issue as responded. @renodesper If you still have troubles using the triggers property, please let us know.

mikhailshilkov avatar Apr 01 '24 09:04 mikhailshilkov