Webhook

Manages a CodeBuild webhook, which is an endpoint accepted by the CodeBuild service to trigger builds from source code repositories. Depending on the source type of the CodeBuild project, the CodeBuild service may also automatically create and delete the actual repository webhook as well.

Example Usage

Bitbucket and GitHub

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var example = new Aws.CodeBuild.Webhook("example", new Aws.CodeBuild.WebhookArgs
        {
            FilterGroups = 
            {
                new Aws.CodeBuild.Inputs.WebhookFilterGroupArgs
                {
                    Filters = 
                    {
                        new Aws.CodeBuild.Inputs.WebhookFilterGroupFilterArgs
                        {
                            Pattern = "PUSH",
                            Type = "EVENT",
                        },
                        new Aws.CodeBuild.Inputs.WebhookFilterGroupFilterArgs
                        {
                            Pattern = "master",
                            Type = "HEAD_REF",
                        },
                    },
                },
            },
            ProjectName = aws_codebuild_project.Example.Name,
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/codebuild"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        _, err := codebuild.NewWebhook(ctx, "example", &codebuild.WebhookArgs{
            FilterGroups: codebuild.WebhookFilterGroupArray{
                &codebuild.WebhookFilterGroupArgs{
                    Filters: codebuild.WebhookFilterGroupFilterArray{
                        &codebuild.WebhookFilterGroupFilterArgs{
                            Pattern: pulumi.String("PUSH"),
                            Type:    pulumi.String("EVENT"),
                        },
                        &codebuild.WebhookFilterGroupFilterArgs{
                            Pattern: pulumi.String("master"),
                            Type:    pulumi.String("HEAD_REF"),
                        },
                    },
                },
            },
            ProjectName: pulumi.String(aws_codebuild_project.Example.Name),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

example = aws.codebuild.Webhook("example",
    filter_groups=[{
        "filters": [
            {
                "pattern": "PUSH",
                "type": "EVENT",
            },
            {
                "pattern": "master",
                "type": "HEAD_REF",
            },
        ],
    }],
    project_name=aws_codebuild_project["example"]["name"])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.codebuild.Webhook("example", {
    filterGroups: [{
        filters: [
            {
                pattern: "PUSH",
                type: "EVENT",
            },
            {
                pattern: "master",
                type: "HEAD_REF",
            },
        ],
    }],
    projectName: aws_codebuild_project_example.name,
});

GitHub Enterprise

using Pulumi;
using Aws = Pulumi.Aws;
using Github = Pulumi.Github;

class MyStack : Stack
{
    public MyStack()
    {
        var exampleWebhook = new Aws.CodeBuild.Webhook("exampleWebhook", new Aws.CodeBuild.WebhookArgs
        {
            ProjectName = aws_codebuild_project.Example.Name,
        });
        var exampleRepositoryWebhook = new Github.RepositoryWebhook("exampleRepositoryWebhook", new Github.RepositoryWebhookArgs
        {
            Active = true,
            Configuration = new Github.Inputs.RepositoryWebhookConfigurationArgs
            {
                ContentType = "json",
                InsecureSsl = false,
                Secret = exampleWebhook.Secret,
                Url = exampleWebhook.PayloadUrl,
            },
            Events = 
            {
                "push",
            },
            Repository = github_repository.Example.Name,
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/codebuild"
    "github.com/pulumi/pulumi-github/sdk/go/github"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        exampleWebhook, err := codebuild.NewWebhook(ctx, "exampleWebhook", &codebuild.WebhookArgs{
            ProjectName: pulumi.String(aws_codebuild_project.Example.Name),
        })
        if err != nil {
            return err
        }
        _, err = github.NewRepositoryWebhook(ctx, "exampleRepositoryWebhook", &github.RepositoryWebhookArgs{
            Active: pulumi.Bool(true),
            Configuration: &github.RepositoryWebhookConfigurationArgs{
                ContentType: pulumi.String("json"),
                InsecureSsl: pulumi.Bool(false),
                Secret:      exampleWebhook.Secret,
                Url:         exampleWebhook.PayloadUrl,
            },
            Events: pulumi.StringArray{
                pulumi.String("push"),
            },
            Repository: pulumi.String(github_repository.Example.Name),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws
import pulumi_github as github

example_webhook = aws.codebuild.Webhook("exampleWebhook", project_name=aws_codebuild_project["example"]["name"])
example_repository_webhook = github.RepositoryWebhook("exampleRepositoryWebhook",
    active=True,
    configuration={
        "contentType": "json",
        "insecureSsl": False,
        "secret": example_webhook.secret,
        "url": example_webhook.payload_url,
    },
    events=["push"],
    repository=github_repository["example"]["name"])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as github from "@pulumi/github";

const exampleWebhook = new aws.codebuild.Webhook("example", {
    projectName: aws_codebuild_project_example.name,
});
const exampleRepositoryWebhook = new github.RepositoryWebhook("example", {
    active: true,
    configuration: {
        contentType: "json",
        insecureSsl: false,
        secret: exampleWebhook.secret,
        url: exampleWebhook.payloadUrl,
    },
    events: ["push"],
    repository: github_repository_example.name,
});

Create a Webhook Resource

new Webhook(name: string, args: WebhookArgs, opts?: CustomResourceOptions);
def Webhook(resource_name, opts=None, branch_filter=None, filter_groups=None, project_name=None, __props__=None);
func NewWebhook(ctx *Context, name string, args WebhookArgs, opts ...ResourceOption) (*Webhook, error)
public Webhook(string name, WebhookArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args WebhookArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args WebhookArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args WebhookArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Webhook Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The Webhook resource accepts the following input properties:

ProjectName string

The name of the build project.

BranchFilter string

A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use filter_group over branch_filter.

FilterGroups List<WebhookFilterGroupArgs>

Information about the webhook’s trigger. Filter group blocks are documented below.

ProjectName string

The name of the build project.

BranchFilter string

A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use filter_group over branch_filter.

FilterGroups []WebhookFilterGroup

Information about the webhook’s trigger. Filter group blocks are documented below.

projectName string

The name of the build project.

branchFilter string

A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use filter_group over branch_filter.

filterGroups WebhookFilterGroup[]

Information about the webhook’s trigger. Filter group blocks are documented below.

project_name str

The name of the build project.

branch_filter str

A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use filter_group over branch_filter.

filter_groups List[WebhookFilterGroup]

Information about the webhook’s trigger. Filter group blocks are documented below.

Outputs

All input properties are implicitly available as output properties. Additionally, the Webhook resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
PayloadUrl string

The CodeBuild endpoint where webhook events are sent.

Secret string

The secret token of the associated repository. Not returned by the CodeBuild API for all source types.

Url string

The URL to the webhook.

Id string
The provider-assigned unique ID for this managed resource.
PayloadUrl string

The CodeBuild endpoint where webhook events are sent.

Secret string

The secret token of the associated repository. Not returned by the CodeBuild API for all source types.

Url string

The URL to the webhook.

id string
The provider-assigned unique ID for this managed resource.
payloadUrl string

The CodeBuild endpoint where webhook events are sent.

secret string

The secret token of the associated repository. Not returned by the CodeBuild API for all source types.

url string

The URL to the webhook.

id str
The provider-assigned unique ID for this managed resource.
payload_url str

The CodeBuild endpoint where webhook events are sent.

secret str

The secret token of the associated repository. Not returned by the CodeBuild API for all source types.

url str

The URL to the webhook.

Look up an Existing Webhook Resource

Get an existing Webhook resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: WebhookState, opts?: CustomResourceOptions): Webhook
static get(resource_name, id, opts=None, branch_filter=None, filter_groups=None, payload_url=None, project_name=None, secret=None, url=None, __props__=None);
func GetWebhook(ctx *Context, name string, id IDInput, state *WebhookState, opts ...ResourceOption) (*Webhook, error)
public static Webhook Get(string name, Input<string> id, WebhookState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

BranchFilter string

A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use filter_group over branch_filter.

FilterGroups List<WebhookFilterGroupArgs>

Information about the webhook’s trigger. Filter group blocks are documented below.

PayloadUrl string

The CodeBuild endpoint where webhook events are sent.

ProjectName string

The name of the build project.

Secret string

The secret token of the associated repository. Not returned by the CodeBuild API for all source types.

Url string

The URL to the webhook.

BranchFilter string

A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use filter_group over branch_filter.

FilterGroups []WebhookFilterGroup

Information about the webhook’s trigger. Filter group blocks are documented below.

PayloadUrl string

The CodeBuild endpoint where webhook events are sent.

ProjectName string

The name of the build project.

Secret string

The secret token of the associated repository. Not returned by the CodeBuild API for all source types.

Url string

The URL to the webhook.

branchFilter string

A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use filter_group over branch_filter.

filterGroups WebhookFilterGroup[]

Information about the webhook’s trigger. Filter group blocks are documented below.

payloadUrl string

The CodeBuild endpoint where webhook events are sent.

projectName string

The name of the build project.

secret string

The secret token of the associated repository. Not returned by the CodeBuild API for all source types.

url string

The URL to the webhook.

branch_filter str

A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use filter_group over branch_filter.

filter_groups List[WebhookFilterGroup]

Information about the webhook’s trigger. Filter group blocks are documented below.

payload_url str

The CodeBuild endpoint where webhook events are sent.

project_name str

The name of the build project.

secret str

The secret token of the associated repository. Not returned by the CodeBuild API for all source types.

url str

The URL to the webhook.

Supporting Types

WebhookFilterGroup

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Filters List<WebhookFilterGroupFilterArgs>

A webhook filter for the group. Filter blocks are documented below.

Filters []WebhookFilterGroupFilter

A webhook filter for the group. Filter blocks are documented below.

filters WebhookFilterGroupFilter[]

A webhook filter for the group. Filter blocks are documented below.

filters List[WebhookFilterGroupFilter]

A webhook filter for the group. Filter blocks are documented below.

WebhookFilterGroupFilter

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Pattern string

For a filter that uses EVENT type, a comma-separated string that specifies one event: PUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_REOPENED. PULL_REQUEST_MERGED works with GitHub & GitHub Enterprise only. For a filter that uses any of the other filter types, a regular expression.

Type string

The webhook filter group’s type. Valid values for this parameter are: EVENT, BASE_REF, HEAD_REF, ACTOR_ACCOUNT_ID, FILE_PATH. At least one filter group must specify EVENT as its type.

ExcludeMatchedPattern bool

If set to true, the specified filter does not trigger a build. Defaults to false.

Pattern string

For a filter that uses EVENT type, a comma-separated string that specifies one event: PUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_REOPENED. PULL_REQUEST_MERGED works with GitHub & GitHub Enterprise only. For a filter that uses any of the other filter types, a regular expression.

Type string

The webhook filter group’s type. Valid values for this parameter are: EVENT, BASE_REF, HEAD_REF, ACTOR_ACCOUNT_ID, FILE_PATH. At least one filter group must specify EVENT as its type.

ExcludeMatchedPattern bool

If set to true, the specified filter does not trigger a build. Defaults to false.

pattern string

For a filter that uses EVENT type, a comma-separated string that specifies one event: PUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_REOPENED. PULL_REQUEST_MERGED works with GitHub & GitHub Enterprise only. For a filter that uses any of the other filter types, a regular expression.

type string

The webhook filter group’s type. Valid values for this parameter are: EVENT, BASE_REF, HEAD_REF, ACTOR_ACCOUNT_ID, FILE_PATH. At least one filter group must specify EVENT as its type.

excludeMatchedPattern boolean

If set to true, the specified filter does not trigger a build. Defaults to false.

pattern str

For a filter that uses EVENT type, a comma-separated string that specifies one event: PUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_REOPENED. PULL_REQUEST_MERGED works with GitHub & GitHub Enterprise only. For a filter that uses any of the other filter types, a regular expression.

type str

The webhook filter group’s type. Valid values for this parameter are: EVENT, BASE_REF, HEAD_REF, ACTOR_ACCOUNT_ID, FILE_PATH. At least one filter group must specify EVENT as its type.

excludeMatchedPattern bool

If set to true, the specified filter does not trigger a build. Defaults to false.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.