
tested cdk versions
aws-cdk-build-badge
This an AWS CDK custom construct for get the status of a CodeBuild Project with has CodePipeline as source. That is currently not possible:
How the native badges are working you find in the AWS docs:
After you created the build badge construct you can use the api gateway url to get the badge picture. Additionally you can retrieve the url to to the CodeBuild build with adding ?url=true to the query parameter. See the example.
URL to Build
If you want your badge forwarding you to your build when you click on it use the url=true parameter:
Build succeeded: [](https://fktijpwdng.execute-api.eu-central-1.amazonaws.com/prod/?projectName=PipelineCustomStageprodTest-Fdei5bm2ulR6&url=true)
Default project name
You can use the defaultProjectName in the cdk construct to point the badge to a specific project. That way you don't need to write the projectName parameter in thr url.
new BuildBadge(stack, 'BuildBadge2', { defaultProjectName: 'Build123' });
Example
Build succeeded: 
Build failed: 
Build not found: 
Build in progress: 
Build stopped: 
There are more badges (see ./badges/) but I don't have build in that state atm.
app = cdk.App()
stack = cdk.Stack(app, "my-build-badge-demo-stack")
BuildBadge(stack, "BuildBadge")
BuildBadge(stack, "BuildBadge2", hide_account_iD="no")
BuildBadge(stack, "BuildBadge3", hide_account_iD="XX123356")
Thanks To