Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_codebuild/Source: Allow Gitlab source (potentially using codestar connector) #31138

Open
2 tasks
nidal123 opened this issue Aug 18, 2024 · 2 comments
Open
2 tasks
Labels
@aws-cdk/aws-codestar Related to AWS CodeStar effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@nidal123
Copy link

nidal123 commented Aug 18, 2024

Describe the feature

CodeBuild is supposed to now start allowing GitLab connections to be used as source input: https://aws.amazon.com/about-aws/whats-new/2024/03/aws-codebuild-gitlab-gitlab-self-managed/

However there's no way to do this with CDK code. Here is the relevant module: https://github.com/aws/aws-cdk/blob/c159e77ab34701fc6780b9501f1692fbf2366b04/packages/aws-cdk-lib/aws-codebuild/lib/source.ts

My best attempt at doing it in Python looks like this:

gitlabConnection = aws_codeconnections.CfnConnection(
    self,
    "myrepo-gitlab",
    connection_name="GitLabMyConnection",
    provider_type="GitLab")
gitlab_repo = "myCompany/path/myRepo"
buildproject = codebuild.Project(self, pipeline_name_prefix+repository_name+"CodeCommitProject",
    source=codebuild.Source.code_star_connection()  # here is where the problem lies
    connection_arn=gitlabConnection.attr_connection_arn,
    repo_string=gitlab_repo,
    branch=repository_ref), 
    project_name=pipeline_name_prefix+"-"+repository_name,
    environment=codebuild.BuildEnvironment(build_image=codebuild.LinuxBuildImage.STANDARD_6_0))

But that does not work because is expecting an ISource.

On the other hand, self mutating pipelines can take CodeStar connections as inputs. For example to see the contrast I was successfully able to use this code:

gitLabRepository ="myCompany/path/myRepo"
gitlabConnection = aws_codeconnections.CfnConnection(
      self,
      "myconnection-gitlab",
      connection_name="GitlabConnection",
      provider_type="GitLab")
pipeline_input = pipelines.CodePipelineSource.connection(
      gitLabRepository, 
      MAIN_BRANCH, 
      connection_arn=gitlabConnection.attr_connection_arn)
pipeline = pipelines.CodePipeline(self, "Pipeline",
      cross_account_keys=True,
      pipeline_name="SchemaManagementToolPipeline", 
      synth=pipelines.ShellStep("Synth",
          input=pipeline_input,
          commands=["zip -r code.zip *", "pip install -r requirements.txt", "npm install -g aws-cdk", "cdk synth"],))

In the second successful case, the CodePipeline consumes a IFileSetProducer as an input. So I am able to pass in the GitLab connection. I wish I could do something like that for CodeBuild. Maybe there's a different way to use CDK to let CodeBuild consume a GitLab connection but I don't see it anywhere.

Use Case

I want CodeBuild to consume a GitLab CodeStar connection as input source like gitHub here https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.Source.html.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.152.0

Environment details (OS name and version, etc.)

CDK

@nidal123 nidal123 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 18, 2024
@github-actions github-actions bot added the @aws-cdk/aws-codestar Related to AWS CodeStar label Aug 18, 2024
@pahud pahud self-assigned this Aug 19, 2024
@pahud
Copy link
Contributor

pahud commented Aug 19, 2024

Yes we should implement something like GitLabSource class that extends CommonGithubSource.

Making this a p2 and we welcome 👍 to help us prioritize. Any PRs are welcome and appreciated as always.

@pahud pahud added p2 effort/medium Medium work item – several days of effort labels Aug 19, 2024
@pahud pahud removed their assignment Aug 19, 2024
@pahud pahud removed the needs-triage This issue or PR still needs to be triaged. label Aug 19, 2024
@suhas38222
Copy link

Hi @pahud,

If this issue is not picked up by the team, I would like to work on it.

Suhas Jangoan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codestar Related to AWS CodeStar effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

3 participants