Class Webhook


  • public class Webhook
    extends com.pulumi.resources.CustomResource
    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](https://bitbucket.org) and [GitHub](https://github.com) 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](https://docs.aws.amazon.com/codebuild/latest/userguide/sample-bitbucket-pull-request.html) and [GitHub](https://docs.aws.amazon.com/codebuild/latest/userguide/sample-github-pull-request.html). > **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.
     
     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());
     
         }
     }
     
     
    ### GitHub Enterprise When working with [GitHub Enterprise](https://enterprise.github.com/) 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](https://docs.aws.amazon.com/codebuild/latest/userguide/sample-github-enterprise.html).
     
     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());
     
         }
     }
     
     
    ### 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](https://docs.aws.amazon.com/codebuild/latest/userguide/action-runner.html) for more information about CodeBuild Runner Projects.
     
     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());
     
         }
     }
     
     
    ## Import Using `pulumi import`, import CodeBuild Webhooks using the CodeBuild Project name. For example: ```sh $ pulumi import aws:codebuild/webhook:Webhook example MyProjectName ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      Webhook​(java.lang.String name)  
      Webhook​(java.lang.String name, WebhookArgs args)  
      Webhook​(java.lang.String name, WebhookArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> branchFilter()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> buildType()  
      com.pulumi.core.Output<java.util.Optional<java.util.List<WebhookFilterGroup>>> filterGroups()  
      static Webhook get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, WebhookState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> manualCreation()  
      com.pulumi.core.Output<java.lang.String> payloadUrl()  
      com.pulumi.core.Output<java.lang.String> projectName()  
      com.pulumi.core.Output<WebhookPullRequestBuildPolicy> pullRequestBuildPolicy()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.util.Optional<WebhookScopeConfiguration>> scopeConfiguration()  
      com.pulumi.core.Output<java.lang.String> secret()  
      com.pulumi.core.Output<java.lang.String> url()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Webhook

        public Webhook​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • Webhook

        public Webhook​(java.lang.String name,
                       WebhookArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • Webhook

        public Webhook​(java.lang.String name,
                       WebhookArgs args,
                       @Nullable
                       com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • branchFilter

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> branchFilter()
        Returns:
        A regular expression used to determine which branches get built. Default is all branches are built. We recommend using `filterGroup` over `branchFilter`.
      • buildType

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> buildType()
        Returns:
        The type of build this webhook will trigger. Valid values for this parameter are: `BUILD`, `BUILD_BATCH`.
      • filterGroups

        public com.pulumi.core.Output<java.util.Optional<java.util.List<WebhookFilterGroup>>> filterGroups()
        Returns:
        Information about the webhook's trigger. See filterGroup for details.
      • manualCreation

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> manualCreation()
        Returns:
        If true, CodeBuild doesn't create a webhook in GitHub and instead returns `payloadUrl` and `secret` values for the webhook. The `payloadUrl` and `secret` values in the output can be used to manually create a webhook within GitHub.
      • payloadUrl

        public com.pulumi.core.Output<java.lang.String> payloadUrl()
        Returns:
        The CodeBuild endpoint where webhook events are sent.
      • projectName

        public com.pulumi.core.Output<java.lang.String> projectName()
        Returns:
        The name of the build project.
      • pullRequestBuildPolicy

        public com.pulumi.core.Output<WebhookPullRequestBuildPolicy> pullRequestBuildPolicy()
        Returns:
        Defines comment-based approval requirements for triggering builds on pull requests. See pullRequestBuildPolicy for details.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • scopeConfiguration

        public com.pulumi.core.Output<java.util.Optional<WebhookScopeConfiguration>> scopeConfiguration()
        Returns:
        Scope configuration for global or organization webhooks. See scopeConfiguration for details.
      • secret

        public com.pulumi.core.Output<java.lang.String> secret()
        Returns:
        The secret token of the associated repository. Not returned by the CodeBuild API for all source types.
      • url

        public com.pulumi.core.Output<java.lang.String> url()
        Returns:
        The URL to the webhook.
      • get

        public static Webhook get​(java.lang.String name,
                                  com.pulumi.core.Output<java.lang.String> id,
                                  @Nullable
                                  WebhookState state,
                                  @Nullable
                                  com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.