Webhook Args
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 thebitbucket_hook
/github_repository_webhook
resource is only possible with importing that resource after creation of theaws.codebuild.Webhook
resource. The CodeBuild API does not ever provide thesecret
attribute for theaws.codebuild.Webhook
resource in this scenario.
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 java.util.List;
import java.util.ArrayList;
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(aws_codebuild_project.example().name())
.buildType("BUILD")
.filterGroups(WebhookFilterGroupArgs.builder()
.filters(
WebhookFilterGroupFilterArgs.builder()
.type("EVENT")
.pattern("PUSH")
.build(),
WebhookFilterGroupFilterArgs.builder()
.type("BASE_REF")
.pattern("master")
.build())
.build())
.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 github_repository_webhook
resource). More information creating webhooks with GitHub Enterprise can be found in the CodeBuild User Guide.
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 com.pulumi.github.inputs.RepositoryWebhookConfigurationArgs;
import java.util.List;
import java.util.ArrayList;
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 exampleWebhook = new Webhook("exampleWebhook", WebhookArgs.builder()
.projectName(aws_codebuild_project.example().name())
.build());
var exampleRepositoryWebhook = new RepositoryWebhook("exampleRepositoryWebhook", RepositoryWebhookArgs.builder()
.active(true)
.events("push")
.repository(github_repository.example().name())
.configuration(RepositoryWebhookConfigurationArgs.builder()
.url(exampleWebhook.payloadUrl())
.secret(exampleWebhook.secret())
.contentType("json")
.insecureSsl(false)
.build())
.build());
}
}
Import
CodeBuild Webhooks can be imported using the CodeBuild Project name, e.g.,
$ pulumi import aws:codebuild/webhook:Webhook example MyProjectName
Constructors
Properties
A regular expression used to determine which branches get built. Default is all branches are built. We recommend using filter_group
over branch_filter
.
Information about the webhook's trigger. Filter group blocks are documented below.
The name of the build project.