UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

249 lines (248 loc) • 11.8 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * 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. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.codebuild.Webhook("example", { * projectName: exampleAwsCodebuildProject.name, * buildType: "BUILD", * filterGroups: [{ * filters: [ * { * type: "EVENT", * pattern: "PUSH", * }, * { * type: "BASE_REF", * pattern: "master", * }, * ], * }], * }); * ``` * * ### 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). * * ```typescript * 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", { * active: true, * events: ["push"], * name: "example", * repository: exampleGithubRepository.name, * configuration: [{ * url: example.payloadUrl, * secret: example.secret, * contentType: "json", * insecureSsl: false, * }], * }); * ``` * * ### 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. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.codebuild.Webhook("example", { * projectName: exampleAwsCodebuildProject.name, * buildType: "BUILD", * filterGroups: [{ * filters: [{ * type: "EVENT", * pattern: "WORKFLOW_JOB_QUEUED", * }], * }], * }); * ``` * * ## Import * * Using `pulumi import`, import CodeBuild Webhooks using the CodeBuild Project name. For example: * * ```sh * $ pulumi import aws:codebuild/webhook:Webhook example MyProjectName * ``` */ export declare class Webhook extends pulumi.CustomResource { /** * Get an existing Webhook resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input<pulumi.ID>, state?: WebhookState, opts?: pulumi.CustomResourceOptions): Webhook; /** * Returns true if the given object is an instance of Webhook. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is Webhook; /** * A regular expression used to determine which branches get built. Default is all branches are built. We recommend using `filterGroup` over `branchFilter`. */ readonly branchFilter: pulumi.Output<string | undefined>; /** * The type of build this webhook will trigger. Valid values for this parameter are: `BUILD`, `BUILD_BATCH`. */ readonly buildType: pulumi.Output<string | undefined>; /** * Information about the webhook's trigger. See filterGroup for details. */ readonly filterGroups: pulumi.Output<outputs.codebuild.WebhookFilterGroup[] | undefined>; /** * 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. */ readonly manualCreation: pulumi.Output<boolean | undefined>; /** * The CodeBuild endpoint where webhook events are sent. */ readonly payloadUrl: pulumi.Output<string>; /** * The name of the build project. */ readonly projectName: pulumi.Output<string>; /** * Defines comment-based approval requirements for triggering builds on pull requests. See pullRequestBuildPolicy for details. */ readonly pullRequestBuildPolicy: pulumi.Output<outputs.codebuild.WebhookPullRequestBuildPolicy>; /** * 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. */ readonly region: pulumi.Output<string>; /** * Scope configuration for global or organization webhooks. See scopeConfiguration for details. */ readonly scopeConfiguration: pulumi.Output<outputs.codebuild.WebhookScopeConfiguration | undefined>; /** * The secret token of the associated repository. Not returned by the CodeBuild API for all source types. */ readonly secret: pulumi.Output<string>; /** * The URL to the webhook. */ readonly url: pulumi.Output<string>; /** * Create a Webhook resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: WebhookArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Webhook resources. */ export interface WebhookState { /** * A regular expression used to determine which branches get built. Default is all branches are built. We recommend using `filterGroup` over `branchFilter`. */ branchFilter?: pulumi.Input<string>; /** * The type of build this webhook will trigger. Valid values for this parameter are: `BUILD`, `BUILD_BATCH`. */ buildType?: pulumi.Input<string>; /** * Information about the webhook's trigger. See filterGroup for details. */ filterGroups?: pulumi.Input<pulumi.Input<inputs.codebuild.WebhookFilterGroup>[]>; /** * 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. */ manualCreation?: pulumi.Input<boolean>; /** * The CodeBuild endpoint where webhook events are sent. */ payloadUrl?: pulumi.Input<string>; /** * The name of the build project. */ projectName?: pulumi.Input<string>; /** * Defines comment-based approval requirements for triggering builds on pull requests. See pullRequestBuildPolicy for details. */ pullRequestBuildPolicy?: pulumi.Input<inputs.codebuild.WebhookPullRequestBuildPolicy>; /** * 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. */ region?: pulumi.Input<string>; /** * Scope configuration for global or organization webhooks. See scopeConfiguration for details. */ scopeConfiguration?: pulumi.Input<inputs.codebuild.WebhookScopeConfiguration>; /** * The secret token of the associated repository. Not returned by the CodeBuild API for all source types. */ secret?: pulumi.Input<string>; /** * The URL to the webhook. */ url?: pulumi.Input<string>; } /** * The set of arguments for constructing a Webhook resource. */ export interface WebhookArgs { /** * A regular expression used to determine which branches get built. Default is all branches are built. We recommend using `filterGroup` over `branchFilter`. */ branchFilter?: pulumi.Input<string>; /** * The type of build this webhook will trigger. Valid values for this parameter are: `BUILD`, `BUILD_BATCH`. */ buildType?: pulumi.Input<string>; /** * Information about the webhook's trigger. See filterGroup for details. */ filterGroups?: pulumi.Input<pulumi.Input<inputs.codebuild.WebhookFilterGroup>[]>; /** * 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. */ manualCreation?: pulumi.Input<boolean>; /** * The name of the build project. */ projectName: pulumi.Input<string>; /** * Defines comment-based approval requirements for triggering builds on pull requests. See pullRequestBuildPolicy for details. */ pullRequestBuildPolicy?: pulumi.Input<inputs.codebuild.WebhookPullRequestBuildPolicy>; /** * 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. */ region?: pulumi.Input<string>; /** * Scope configuration for global or organization webhooks. See scopeConfiguration for details. */ scopeConfiguration?: pulumi.Input<inputs.codebuild.WebhookScopeConfiguration>; }