Webhook class
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
When working with Bitbucket and GitHub source CodeBuild webhooks, the CodeBuild service will automatically create (on aws.codebuild.Webhook resource creation) and delete (on aws.codebuild.Webhook resource deletion) the Bitbucket/GitHub repository webhook using its granted OAuth permissions. This behavior cannot be controlled by this provider.
> Note: The AWS account that this provider uses to create this resource must have authorized CodeBuild to access Bitbucket/GitHub's OAuth API in each applicable region. This is a manual step that must be done before creating webhooks with this resource. If OAuth is not configured, AWS will return an error similar to ResourceNotFoundException: Could not find access token for server type github. More information can be found in the CodeBuild User Guide for Bitbucket and GitHub.
> Note: Further managing the automatically created Bitbucket/GitHub webhook with the bitbucketHook/githubRepositoryWebhook resource is only possible with importing that resource after creation of the aws.codebuild.Webhook resource. The CodeBuild API does not ever provide the secret attribute for the aws.codebuild.Webhook resource in this scenario.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.codebuild.Webhook("example", {
filterGroups: [{
filters: [
{
type: "EVENT",
pattern: "PUSH",
},
{
type: "BASE_REF",
pattern: "master",
},
],
}],
projectName: exampleAwsCodebuildProject.name,
buildType: "BUILD",
});
import pulumi
import pulumi_aws as aws
example = aws.codebuild.Webhook("example",
filter_groups=[{
"filters": [
{
"type": "EVENT",
"pattern": "PUSH",
},
{
"type": "BASE_REF",
"pattern": "master",
},
],
}],
project_name=example_aws_codebuild_project["name"],
build_type="BUILD")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.CodeBuild.Webhook("example", new()
{
FilterGroups = new[]
{
new Aws.CodeBuild.Inputs.WebhookFilterGroupArgs
{
Filters = new[]
{
new Aws.CodeBuild.Inputs.WebhookFilterGroupFilterArgs
{
Type = "EVENT",
Pattern = "PUSH",
},
new Aws.CodeBuild.Inputs.WebhookFilterGroupFilterArgs
{
Type = "BASE_REF",
Pattern = "master",
},
},
},
},
ProjectName = exampleAwsCodebuildProject.Name,
BuildType = "BUILD",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/codebuild"
"github.com/pulumi/pulumi/sdk/v3/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{
Type: pulumi.String("EVENT"),
Pattern: pulumi.String("PUSH"),
},
&codebuild.WebhookFilterGroupFilterArgs{
Type: pulumi.String("BASE_REF"),
Pattern: pulumi.String("master"),
},
},
},
},
ProjectName: pulumi.Any(exampleAwsCodebuildProject.Name),
BuildType: pulumi.String("BUILD"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_codebuild_webhook" "example" {
filter_groups {
filters {
type = "EVENT"
pattern = "PUSH"
}
filters {
type = "BASE_REF"
pattern = "master"
}
}
project_name = exampleAwsCodebuildProject.name
build_type = "BUILD"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.codebuild.Webhook;
import com.pulumi.aws.codebuild.WebhookArgs;
import com.pulumi.aws.codebuild.inputs.WebhookFilterGroupArgs;
import com.pulumi.aws.codebuild.inputs.WebhookFilterGroupFilterArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Webhook("example", WebhookArgs.builder()
.filterGroups(WebhookFilterGroupArgs.builder()
.filters(
WebhookFilterGroupFilterArgs.builder()
.type("EVENT")
.pattern("PUSH")
.build(),
WebhookFilterGroupFilterArgs.builder()
.type("BASE_REF")
.pattern("master")
.build())
.build())
.projectName(exampleAwsCodebuildProject.name())
.buildType("BUILD")
.build());
}
}
resources:
example:
type: aws:codebuild:Webhook
properties:
filterGroups:
- filters:
- type: EVENT
pattern: PUSH
- type: BASE_REF
pattern: master
projectName: ${exampleAwsCodebuildProject.name}
buildType: BUILD
GitHub Enterprise
When working with GitHub Enterprise source CodeBuild webhooks, the GHE repository webhook must be separately managed (e.g., manually or with the githubRepositoryWebhook resource).
More information creating webhooks with GitHub Enterprise can be found in the CodeBuild User Guide.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as github from "@pulumi/github";
const example = new aws.codebuild.Webhook("example", {projectName: exampleAwsCodebuildProject.name});
const exampleRepositoryWebhook = new github.RepositoryWebhook("example", {
configuration: [{
url: example.payloadUrl,
secret: example.secret,
contentType: "json",
insecureSsl: false,
}],
active: true,
events: ["push"],
name: "example",
repository: exampleGithubRepository.name,
});
import pulumi
import pulumi_aws as aws
import pulumi_github as github
example = aws.codebuild.Webhook("example", project_name=example_aws_codebuild_project["name"])
example_repository_webhook = github.RepositoryWebhook("example",
configuration=[{
"url": example.payload_url,
"secret": example.secret,
"contentType": "json",
"insecureSsl": False,
}],
active=True,
events=["push"],
name="example",
repository=example_github_repository["name"])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
using Github = Pulumi.Github;
return await Deployment.RunAsync(() =>
{
var example = new Aws.CodeBuild.Webhook("example", new()
{
ProjectName = exampleAwsCodebuildProject.Name,
});
var exampleRepositoryWebhook = new Github.RepositoryWebhook("example", new()
{
Configuration = new[]
{
{
{ "url", example.PayloadUrl },
{ "secret", example.Secret },
{ "contentType", "json" },
{ "insecureSsl", false },
},
},
Active = true,
Events = new[]
{
"push",
},
Name = "example",
Repository = exampleGithubRepository.Name,
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/codebuild"
"github.com/pulumi/pulumi-github/sdk/v6/go/github"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := codebuild.NewWebhook(ctx, "example", &codebuild.WebhookArgs{
ProjectName: pulumi.Any(exampleAwsCodebuildProject.Name),
})
if err != nil {
return err
}
_, err = github.NewRepositoryWebhook(ctx, "example", &github.RepositoryWebhookArgs{
Configuration: github.RepositoryWebhookConfigurationArgs{
map[string]interface{}{
"url": example.PayloadUrl,
"secret": example.Secret,
"contentType": "json",
"insecureSsl": false,
},
},
Active: pulumi.Bool(true),
Events: pulumi.StringArray{
pulumi.String("push"),
},
Name: "example",
Repository: pulumi.Any(exampleGithubRepository.Name),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
github = {
source = "pulumi/github"
}
}
}
resource "aws_codebuild_webhook" "example" {
project_name = exampleAwsCodebuildProject.name
}
resource "github_repositorywebhook" "example" {
configuration = [{
"url" = aws_codebuild_webhook.example.payload_url
"secret" = aws_codebuild_webhook.example.secret
"contentType" = "json"
"insecureSsl" = false
}]
active = true
events = ["push"]
name = "example"
repository = exampleGithubRepository.name
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.codebuild.Webhook;
import com.pulumi.aws.codebuild.WebhookArgs;
import com.pulumi.github.RepositoryWebhook;
import com.pulumi.github.RepositoryWebhookArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Webhook("example", WebhookArgs.builder()
.projectName(exampleAwsCodebuildProject.name())
.build());
var exampleRepositoryWebhook = new RepositoryWebhook("exampleRepositoryWebhook", RepositoryWebhookArgs.builder()
.configuration(com.pulumi.github.inputs.RepositoryWebhookConfigurationArgs.builder()
.url(example.payloadUrl())
.secret(example.secret())
.contentType("json")
.insecureSsl(false)
.build())
.active(true)
.events("push")
.name("example")
.repository(exampleGithubRepository.name())
.build());
}
}
resources:
example:
type: aws:codebuild:Webhook
properties:
projectName: ${exampleAwsCodebuildProject.name}
exampleRepositoryWebhook:
type: github:RepositoryWebhook
name: example
properties:
configuration:
- url: ${example.payloadUrl}
secret: ${example.secret}
contentType: json
insecureSsl: false
active: true
events:
- push
name: example
repository: ${exampleGithubRepository.name}
For CodeBuild Runner Project
To create a CodeBuild project as a Runner Project, the following aws.codebuild.Webhook resource is required for the project.
See thr AWS Documentation for more information about CodeBuild Runner Projects.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.codebuild.Webhook("example", {
filterGroups: [{
filters: [{
type: "EVENT",
pattern: "WORKFLOW_JOB_QUEUED",
}],
}],
projectName: exampleAwsCodebuildProject.name,
buildType: "BUILD",
});
import pulumi
import pulumi_aws as aws
example = aws.codebuild.Webhook("example",
filter_groups=[{
"filters": [{
"type": "EVENT",
"pattern": "WORKFLOW_JOB_QUEUED",
}],
}],
project_name=example_aws_codebuild_project["name"],
build_type="BUILD")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.CodeBuild.Webhook("example", new()
{
FilterGroups = new[]
{
new Aws.CodeBuild.Inputs.WebhookFilterGroupArgs
{
Filters = new[]
{
new Aws.CodeBuild.Inputs.WebhookFilterGroupFilterArgs
{
Type = "EVENT",
Pattern = "WORKFLOW_JOB_QUEUED",
},
},
},
},
ProjectName = exampleAwsCodebuildProject.Name,
BuildType = "BUILD",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/codebuild"
"github.com/pulumi/pulumi/sdk/v3/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{
Type: pulumi.String("EVENT"),
Pattern: pulumi.String("WORKFLOW_JOB_QUEUED"),
},
},
},
},
ProjectName: pulumi.Any(exampleAwsCodebuildProject.Name),
BuildType: pulumi.String("BUILD"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_codebuild_webhook" "example" {
filter_groups {
filters {
type = "EVENT"
pattern = "WORKFLOW_JOB_QUEUED"
}
}
project_name = exampleAwsCodebuildProject.name
build_type = "BUILD"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.codebuild.Webhook;
import com.pulumi.aws.codebuild.WebhookArgs;
import com.pulumi.aws.codebuild.inputs.WebhookFilterGroupArgs;
import com.pulumi.aws.codebuild.inputs.WebhookFilterGroupFilterArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Webhook("example", WebhookArgs.builder()
.filterGroups(WebhookFilterGroupArgs.builder()
.filters(WebhookFilterGroupFilterArgs.builder()
.type("EVENT")
.pattern("WORKFLOW_JOB_QUEUED")
.build())
.build())
.projectName(exampleAwsCodebuildProject.name())
.buildType("BUILD")
.build());
}
}
resources:
example:
type: aws:codebuild:Webhook
properties:
filterGroups:
- filters:
- type: EVENT
pattern: WORKFLOW_JOB_QUEUED
projectName: ${exampleAwsCodebuildProject.name}
buildType: BUILD
Import
Using pulumi import, import CodeBuild Webhooks using the CodeBuild Project name. For example:
$ pulumi import aws:codebuild/webhook:Webhook example MyProjectName
Constructors
- Webhook(String name, {WebhookArgs? args, CustomResourceOptions? options})
-
Creates a new Webhook.
nameThe Pulumi resource name.argsArguments used to configure this Webhook. The set of arguments for Webhook.optionsResource options controlling this resource's behavior. - Webhook.reference(String urn)
- Creates a typed reference to an existing Webhook resource.
Properties
-
branchFilter
↔ Output<
String?> -
A regular expression used to determine which branches get built. Default is all branches are built. We recommend using
filterGroupoverbranchFilter.latefinal -
buildType
↔ Output<
String?> -
The type of build this webhook will trigger. Valid values for this parameter are:
BUILD,BUILD_BATCH.latefinal -
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
filterGroups
↔ Output<
List< WebhookFilterGroup> ?> -
Information about the webhook's trigger. See filterGroup for details.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
manualCreation
↔ Output<
bool?> -
If true, CodeBuild doesn't create a webhook in GitHub and instead returns
payloadUrlandsecretvalues for the webhook. ThepayloadUrlandsecretvalues in the output can be used to manually create a webhook within GitHub.latefinal -
payloadUrl
↔ Output<
String> -
The CodeBuild endpoint where webhook events are sent.
latefinal
-
projectName
↔ Output<
String> -
The name of the build project.
latefinal
-
pullRequestBuildPolicy
↔ Output<
WebhookPullRequestBuildPolicy> -
Defines comment-based approval requirements for triggering builds on pull requests. See pullRequestBuildPolicy for details.
latefinal
-
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
scopeConfiguration
↔ Output<
WebhookScopeConfiguration?> -
Scope configuration for global or organization webhooks. See scopeConfiguration for details.
latefinal
-
secret
↔ Output<
String> -
The secret token of the associated repository. Not returned by the CodeBuild API for all source types.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
url
↔ Output<
String> -
The URL to the webhook.
latefinal
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited