I am trying to set AWS codepipeline and use github as the source by using cloudformation. The github repository is owned by an organization and I have admin access to it.
I was able to create webhook and successfully create entire service through codepipeline UI. But when I am trying to do same thing through Cloudformation Document, it returns error
Webhook could not be registered with GitHub. Error cause: Not found [StatusCode: 404, Body: {"message":"Not Found","documentation_url":"https://developer.github.com/v3/repos/hooks/#create-a-hook"}]
I used same credential both times (OAuth token in cloudformation and actual login popups in codepipeline UI), but when I do it through Cloudformation it failed.
I suspected my cloudformation document was the issue. But when I create my own repository, cloudformation successfully create webhook and created full codepipeline service.
Below is the summary of tests I did to understand where it went wrong.
repo
and admin:repo_hook
enabled. => Gave out error aboverepo
and admin:repo_hook
enabled => successfully created webhook and servicesThe following is portion of cloudformation document where I create Webhook.
AppPipelineWebhook:
Type: 'AWS::CodePipeline::Webhook'
Properties:
Authentication: GITHUB_HMAC
AuthenticationConfiguration:
SecretToken: !Ref GitHubSecret
Filters:
- JsonPath: $.ref
MatchEquals: 'refs/heads/{Branch}'
TargetPipeline: !Ref cfSSMAutomationDev
TargetAction: SourceAction
Name: AppPipelineWebhook
TargetPipelineVersion: !GetAtt cfSSMAutomationDev.Version
RegisterWithThirdParty: true
So I am not sure what is wrong. My suspicion is that OAuth token requires more privilege. Does anyone have similar experience with this? Any suggestion is much appreciated
The AWS::CodePipeline::Webhook resource creates and registers your webhook. After the webhook is created and registered, it triggers your pipeline to start every time an external event occurs. For more information, see Configure Your GitHub Pipelines to Use Webhooks for Change Detection in the AWS CodePipeline User Guide .
But when I create my own repository, cloudformation successfully create webhook and created full codepipeline service. Below is the summary of tests I did to understand where it went wrong. Codepipeline UI. Organization Github Repo. It asked to login the github. Logged in with my admin credential => successfully created webhook and services.
After the webhook is created and registered, it triggers your pipeline to start every time an external event occurs. For more information, see Configure Your GitHub Pipelines to Use Webhooks for Change Detection in the AWS CodePipeline User Guide . We strongly recommend that you use AWS Secrets Manager to store your credentials.
To use an AWS CloudFormation template to filter webhook events, use the AWS CodeBuild project's FilterGroups property. The following YAML-formatted portion of an AWS CloudFormation template creates two filter groups. Together, they trigger a build when one or both evaluate to true:
Even I was facing the same issue, by seeing codepipeline UI configuration's Repository I used
{
"Configuration": {
"Owner": "myUserName",
"Repo": "orgname/repository-name",
}
}
so cloudformation was checking for the repository myUserName/orgname/repository-name which wasn't exist.
It got solved after following the below solution:
{
"Configuration": {
"Owner": "orgname",
"Repo": "repository-name",
}
}
private repo -> ownerName: YourUserName
organisation repo -> ownerName: OrganisationName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With