Webhook

class Webhook : KotlinCustomResource

Provides a CodePipeline Webhook.

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.codepipeline.Pipeline;
import com.pulumi.aws.codepipeline.PipelineArgs;
import com.pulumi.aws.codepipeline.inputs.PipelineArtifactStoreArgs;
import com.pulumi.aws.codepipeline.inputs.PipelineArtifactStoreEncryptionKeyArgs;
import com.pulumi.aws.codepipeline.inputs.PipelineStageArgs;
import com.pulumi.aws.codepipeline.Webhook;
import com.pulumi.aws.codepipeline.WebhookArgs;
import com.pulumi.aws.codepipeline.inputs.WebhookAuthenticationConfigurationArgs;
import com.pulumi.aws.codepipeline.inputs.WebhookFilterArgs;
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 bar = new Pipeline("bar", PipelineArgs.builder()
.name("tf-test-pipeline")
.roleArn(barAwsIamRole.arn())
.artifactStores(PipelineArtifactStoreArgs.builder()
.location(barAwsS3Bucket.bucket())
.type("S3")
.encryptionKey(PipelineArtifactStoreEncryptionKeyArgs.builder()
.id(s3kmskey.arn())
.type("KMS")
.build())
.build())
.stages(
PipelineStageArgs.builder()
.name("Source")
.actions(PipelineStageActionArgs.builder()
.name("Source")
.category("Source")
.owner("ThirdParty")
.provider("GitHub")
.version("1")
.outputArtifacts("test")
.configuration(Map.ofEntries(
Map.entry("Owner", "my-organization"),
Map.entry("Repo", "test"),
Map.entry("Branch", "master")
))
.build())
.build(),
PipelineStageArgs.builder()
.name("Build")
.actions(PipelineStageActionArgs.builder()
.name("Build")
.category("Build")
.owner("AWS")
.provider("CodeBuild")
.inputArtifacts("test")
.version("1")
.configuration(Map.of("ProjectName", "test"))
.build())
.build())
.build());
final var webhookSecret = "super-secret";
var barWebhook = new Webhook("barWebhook", WebhookArgs.builder()
.name("test-webhook-github-bar")
.authentication("GITHUB_HMAC")
.targetAction("Source")
.targetPipeline(bar.name())
.authenticationConfiguration(WebhookAuthenticationConfigurationArgs.builder()
.secretToken(webhookSecret)
.build())
.filters(WebhookFilterArgs.builder()
.jsonPath("$.ref")
.matchEquals("refs/heads/{Branch}")
.build())
.build());
// Wire the CodePipeline webhook into a GitHub repository.
var barRepositoryWebhook = new RepositoryWebhook("barRepositoryWebhook", RepositoryWebhookArgs.builder()
.repository(repo.name())
.name("web")
.configuration(RepositoryWebhookConfigurationArgs.builder()
.url(barWebhook.url())
.contentType("json")
.insecureSsl(true)
.secret(webhookSecret)
.build())
.events("push")
.build());
}
}
resources:
bar:
type: aws:codepipeline:Pipeline
properties:
name: tf-test-pipeline
roleArn: ${barAwsIamRole.arn}
artifactStores:
- location: ${barAwsS3Bucket.bucket}
type: S3
encryptionKey:
id: ${s3kmskey.arn}
type: KMS
stages:
- name: Source
actions:
- name: Source
category: Source
owner: ThirdParty
provider: GitHub
version: '1'
outputArtifacts:
- test
configuration:
Owner: my-organization
Repo: test
Branch: master
- name: Build
actions:
- name: Build
category: Build
owner: AWS
provider: CodeBuild
inputArtifacts:
- test
version: '1'
configuration:
ProjectName: test
barWebhook:
type: aws:codepipeline:Webhook
name: bar
properties:
name: test-webhook-github-bar
authentication: GITHUB_HMAC
targetAction: Source
targetPipeline: ${bar.name}
authenticationConfiguration:
secretToken: ${webhookSecret}
filters:
- jsonPath: $.ref
matchEquals: refs/heads/{Branch}
# Wire the CodePipeline webhook into a GitHub repository.
barRepositoryWebhook:
type: github:RepositoryWebhook
name: bar
properties:
repository: ${repo.name}
name: web
configuration:
url: ${barWebhook.url}
contentType: json
insecureSsl: true
secret: ${webhookSecret}
events:
- push
variables:
webhookSecret: super-secret

Import

Using pulumi import, import CodePipeline Webhooks using their ARN. For example:

$ pulumi import aws:codepipeline/webhook:Webhook example arn:aws:codepipeline:us-west-2:123456789012:webhook:example

Properties

Link copied to clipboard
val arn: Output<String>

The CodePipeline webhook's ARN.

Link copied to clipboard
val authentication: Output<String>

The type of authentication to use. One of IP, GITHUB_HMAC, or UNAUTHENTICATED.

Link copied to clipboard

An auth block. Required for IP and GITHUB_HMAC. Auth blocks are documented below.

Link copied to clipboard
val filters: Output<List<WebhookFilter>>

One or more filter blocks. Filter blocks are documented below.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val name: Output<String>

The name of the webhook.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val tags: Output<Map<String, String>>?

A map of tags to assign to the resource. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Link copied to clipboard
val tagsAll: Output<Map<String, String>>

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

Link copied to clipboard
val targetAction: Output<String>

The name of the action in a pipeline you want to connect to the webhook. The action must be from the source (first) stage of the pipeline.

Link copied to clipboard
val targetPipeline: Output<String>

The name of the pipeline.

Link copied to clipboard
val url: Output<String>

The CodePipeline webhook's URL. POST events to this endpoint to trigger the target.

Link copied to clipboard
val urn: Output<String>