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:
- Project
Name string The name of the build project.
- Branch
Filter string A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use
filter_groupoverbranch_filter.- Filter
Groups List<WebhookFilter Group Args> Information about the webhook’s trigger. Filter group blocks are documented below.
- Project
Name string The name of the build project.
- Branch
Filter string A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use
filter_groupoverbranch_filter.- Filter
Groups []WebhookFilter Group Information about the webhook’s trigger. Filter group blocks are documented below.
- project
Name string The name of the build project.
- branch
Filter string A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use
filter_groupoverbranch_filter.- filter
Groups WebhookFilter Group[] 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_groupoverbranch_filter.- filter_
groups List[WebhookFilter Group] 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:
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): Webhookstatic 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:
- Branch
Filter string A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use
filter_groupoverbranch_filter.- Filter
Groups List<WebhookFilter Group Args> Information about the webhook’s trigger. Filter group blocks are documented below.
- Payload
Url string The CodeBuild endpoint where webhook events are sent.
- Project
Name 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 string A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use
filter_groupoverbranch_filter.- Filter
Groups []WebhookFilter Group Information about the webhook’s trigger. Filter group blocks are documented below.
- Payload
Url string The CodeBuild endpoint where webhook events are sent.
- Project
Name 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 string A regular expression used to determine which branches get built. Default is all branches are built. It is recommended to use
filter_groupoverbranch_filter.- filter
Groups WebhookFilter Group[] Information about the webhook’s trigger. Filter group blocks are documented below.
- payload
Url string The CodeBuild endpoint where webhook events are sent.
- project
Name 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_groupoverbranch_filter.- filter_
groups List[WebhookFilter Group] 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
- Filters
List<Webhook
Filter Group Filter Args> A webhook filter for the group. Filter blocks are documented below.
- Filters
[]Webhook
Filter Group Filter A webhook filter for the group. Filter blocks are documented below.
- filters
Webhook
Filter Group Filter[] A webhook filter for the group. Filter blocks are documented below.
- filters
List[Webhook
Filter Group Filter] A webhook filter for the group. Filter blocks are documented below.
WebhookFilterGroupFilter
- Pattern string
For a filter that uses
EVENTtype, a comma-separated string that specifies one event:PUSH,PULL_REQUEST_CREATED,PULL_REQUEST_UPDATED,PULL_REQUEST_REOPENED.PULL_REQUEST_MERGEDworks 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 specifyEVENTas its type.- Exclude
Matched boolPattern If set to
true, the specified filter does not trigger a build. Defaults tofalse.
- Pattern string
For a filter that uses
EVENTtype, a comma-separated string that specifies one event:PUSH,PULL_REQUEST_CREATED,PULL_REQUEST_UPDATED,PULL_REQUEST_REOPENED.PULL_REQUEST_MERGEDworks 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 specifyEVENTas its type.- Exclude
Matched boolPattern If set to
true, the specified filter does not trigger a build. Defaults tofalse.
- pattern string
For a filter that uses
EVENTtype, a comma-separated string that specifies one event:PUSH,PULL_REQUEST_CREATED,PULL_REQUEST_UPDATED,PULL_REQUEST_REOPENED.PULL_REQUEST_MERGEDworks 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 specifyEVENTas its type.- exclude
Matched booleanPattern If set to
true, the specified filter does not trigger a build. Defaults tofalse.
- pattern str
For a filter that uses
EVENTtype, a comma-separated string that specifies one event:PUSH,PULL_REQUEST_CREATED,PULL_REQUEST_UPDATED,PULL_REQUEST_REOPENED.PULL_REQUEST_MERGEDworks 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 specifyEVENTas its type.- exclude
Matched boolPattern If set to
true, the specified filter does not trigger a build. Defaults tofalse.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.