UNPKG

@pulumi/aws

Version:

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

136 lines 6.67 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Webhook = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * 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", * }, * ], * }], * }); * ``` * * ### 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 * ``` */ 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, id, state, opts) { return new Webhook(name, state, { ...opts, id: id }); } /** * 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) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Webhook.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["branchFilter"] = state?.branchFilter; resourceInputs["buildType"] = state?.buildType; resourceInputs["filterGroups"] = state?.filterGroups; resourceInputs["manualCreation"] = state?.manualCreation; resourceInputs["payloadUrl"] = state?.payloadUrl; resourceInputs["projectName"] = state?.projectName; resourceInputs["region"] = state?.region; resourceInputs["scopeConfiguration"] = state?.scopeConfiguration; resourceInputs["secret"] = state?.secret; resourceInputs["url"] = state?.url; } else { const args = argsOrState; if (args?.projectName === undefined && !opts.urn) { throw new Error("Missing required property 'projectName'"); } resourceInputs["branchFilter"] = args?.branchFilter; resourceInputs["buildType"] = args?.buildType; resourceInputs["filterGroups"] = args?.filterGroups; resourceInputs["manualCreation"] = args?.manualCreation; resourceInputs["projectName"] = args?.projectName; resourceInputs["region"] = args?.region; resourceInputs["scopeConfiguration"] = args?.scopeConfiguration; resourceInputs["payloadUrl"] = undefined /*out*/; resourceInputs["secret"] = undefined /*out*/; resourceInputs["url"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["secret"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Webhook.__pulumiType, name, resourceInputs, opts); } } exports.Webhook = Webhook; /** @internal */ Webhook.__pulumiType = 'aws:codebuild/webhook:Webhook'; //# sourceMappingURL=webhook.js.map