Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::CodePipeline::Webhook

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.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::CodePipeline::Webhook", "Properties" : { "AuthenticationConfiguration" : WebhookAuthConfiguration, "Filters" : [ WebhookFilterRule, ... ], "Authentication" : String, "TargetPipeline" : String, "TargetAction" : String, "Name" : String, "TargetPipelineVersion" : Integer, "RegisterWithThirdParty" : Boolean } }

YAML

Type: "AWS::CodePipeline::Webhook" Properties: AuthenticationConfiguration: WebhookAuthConfiguration Filters: - WebhookFilterRule Authentication: String TargetPipeline: String TargetAction: String Name: String TargetPipelineVersion: Integer RegisterWithThirdParty: Boolean

Properties

Authentication

The type of authentication scheme that allows the trigger request to be accepted. For more information, see Webhook Definition in the AWS CodePipeline API Reference.

Required: Yes

Type: String

Update requires: No interruption

AuthenticationConfiguration

Properties that configure the authentication applied to incoming webhook trigger requests. For more information, see Webhook Definition in the AWS CodePipeline API Reference.

Required: Yes

Type: AWS CodePipeline Webhook WebhookAuthConfiguration

Update requires: No interruption

Filters

A list of rules applied to the body/payload sent in the POST request to a webhook URL. All defined rules must pass for the request to be accepted and the pipeline started.

Required: Yes

Type: List of AWS CodePipeline Webhook WebhookFilterRule property types

Update requires: No interruption

Name

The name of the webhook to be created and, if applicable, to register with a supported third party.

Required: No

Type: String

Update requires: Replacement

RegisterWithThirdParty

Indicates whether to register the webhook with a third party. Third party registration configures a connection between the webhook that was created and the external tool, such as GitHub, with events to be detected.

Required: No

Type: Boolean

Update requires: No interruption

TargetAction

The name of the action in a pipeline you want to connect to the webhook. The action must be from the source (first) stage of the pipeline.

Required: Yes

Type: String

Update requires: No interruption

TargetPipeline

The name of the pipeline you want to connect to the webhook.

Required: Yes

Type: String

Update requires: No interruption

TargetPipelineVersion

The version number of the pipeline to be connected to the trigger request.

Required: Yes

Type: Integer

Update requires: No interruption

Return Values

Ref

When you pass the logical ID of an AWS::CodePipeline::Webhook resource to the intrinsic Ref function, the function returns the webhook name, such as MyFirstPipeline-SourceAction1-Webhook-utb9LrOl24Kk.

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

Url

The webhook URL generated by AWS CodePipeline, such as https://eu-central-1.webhooks.aws/trigger123456.

For more information about using Fn::GetAtt, see Fn::GetAtt.

Example

The following example creates a webhook named MyWebhook and registers the webhook for the pipeline's GitHub source repository. In this example, WebhookPipeline is the logical ID of the pipeline to which you want to add the webhook.

JSON

{ "Webhook": { "Type": "AWS: : CodePipeline: : Webhook", "Properties": { "AuthenticationConfiguration": { "SecretToken": "secret" }, "Filters": [ { "JsonPath": "$.ref", "MatchEquals": "refs/heads/{Branch}" } ], "Authentication": "GITHUB_HMAC", "TargetPipeline": { "Ref" : "WebhookPipeline" }, "TargetAction": "Source", "Name": "MyWebhook", "TargetPipelineVersion": { "Fn::GetAtt" : [ "WebhookPipeline", "Version" ] }, "RegisterWithThirdParty": "true" } } }

YAML

Webhook: Type: 'AWS: : CodePipeline: : Webhook' Properties: AuthenticationConfiguration: SecretToken: secret Filters: - JsonPath: "$.ref" MatchEquals: refs/heads/{Branch} Authentication: GITHUB_HMAC TargetPipeline: !Ref WebhookPipeline TargetAction: Source Name: MyWebhook TargetPipelineVersion: !GetAtt WebhookPipeline.Version RegisterWithThirdParty: 'true'