Hello!
I'm having a strange problem with CloudFormation not creating a GitHub Webhook on a specified repository. What makes it strange is that stack is getting created successfully with AWS::CodePipeline::Webhook resource marked as "CREATE_COMPLETE" without raising any errors. However, when I open the GitHub repository settings I can't see a webhook and CodePipeline is not getting triggered on commit.
The resource is defined this way:
PipelineHook:
Type: AWS::CodePipeline::Webhook
Properties:
Name: !Ref StackName
Authentication: GITHUB_HMAC
AuthenticationConfiguration:
SecretToken: !Ref GitHubWebhookSecretToken
Filters:
- JsonPath: $.ref
MatchEquals: refs/heads/{Branch}
TargetPipeline: !Ref Pipeline
TargetPipelineVersion: !GetAtt Pipeline.Version
TargetAction: github-clone
Pipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
Name: !Ref StackName
RoleArn: !GetAtt PipelineRole.Arn
ArtifactStore:
Location: !Ref ArtifactStoreBucket
Type: S3
Stages:
# Downloading source code from GitHub repository
- Name: source
Actions:
- Name: github-clone
RunOrder: 1
ActionTypeId:
Category: Source
Provider: GitHub
Owner: ThirdParty
Version: "1"
Configuration:
Owner: !Ref GitHubOwner
Repo: !Ref GitHubRepo
Branch: !Ref GitHubBranch
OAuthToken: !Ref GitHubAccessToken
PollForSourceChanges: false
OutputArtifacts:
- Name: source-code
# Building a Docker image and pushing it to ECR
- Name: stage
Actions:
- Name: stage-build
RunOrder: 1
InputArtifacts:
- Name: source-code
ActionTypeId:
Category: Build
Provider: CodeBuild
Owner: AWS
Version: "1"
Configuration:
ProjectName: !Ref BuildProject
I've tried to call GitHub's API directly to create a hook using the same AccessToken and it worked correctly:
Accept: application/vnd.github.v3+json
Content-Type: application/json
Authorization: token ...
{
"config": {
"url": "https://www.example.com",
"content_type": "json",
"secret": "..."
}
}
Also, the same exact configuration was working correctly in another stack.