aws_codebuild/Source: Allow Gitlab source (potentially using codestar connector)
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### 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
Contributor guide
Research direction
Start in packages/aws-cdk-lib/aws-codebuild/lib/source.ts, especially the Source.code_star_connection entry point, and compare its expected ISource shape with pipelines.CodePipelineSource.connection. Confirm how the GitLab repository, branch, and CodeStar connection ARN should be represented; done means CodeBuild can consume a GitLab connection through the public CDK API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100