pulumi / pulumi-aws

An Amazon Web Services (AWS) Pulumi resource package, providing multi-language access to AWS
Apache License 2.0
466 stars 156 forks source link

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

Closed renodesper closed 8 months ago

renodesper commented 8 months ago

Hello!

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

corymhall commented 8 months ago

@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/

renodesper commented 8 months ago

@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.

corymhall commented 8 months ago

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

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

mikhailshilkov commented 8 months ago

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