Webhook

Provides a CodePipeline Webhook.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;
using Github = Pulumi.Github;

class MyStack : Stack
{
    public MyStack()
    {
        var barPipeline = new Aws.CodePipeline.Pipeline("barPipeline", new Aws.CodePipeline.PipelineArgs
        {
            ArtifactStore = new Aws.CodePipeline.Inputs.PipelineArtifactStoreArgs
            {
                EncryptionKey = new Aws.CodePipeline.Inputs.PipelineArtifactStoreEncryptionKeyArgs
                {
                    Id = data.Aws_kms_alias.S3kmskey.Arn,
                    Type = "KMS",
                },
                Location = aws_s3_bucket.Bar.Bucket,
                Type = "S3",
            },
            RoleArn = aws_iam_role.Bar.Arn,
            Stages = 
            {
                new Aws.CodePipeline.Inputs.PipelineStageArgs
                {
                    Actions = 
                    {
                        new Aws.CodePipeline.Inputs.PipelineStageActionArgs
                        {
                            Category = "Source",
                            Configuration = 
                            {
                                { "Branch", "master" },
                                { "Owner", "my-organization" },
                                { "Repo", "test" },
                            },
                            Name = "Source",
                            OutputArtifacts = 
                            {
                                "test",
                            },
                            Owner = "ThirdParty",
                            Provider = "GitHub",
                            Version = "1",
                        },
                    },
                    Name = "Source",
                },
                new Aws.CodePipeline.Inputs.PipelineStageArgs
                {
                    Actions = 
                    {
                        new Aws.CodePipeline.Inputs.PipelineStageActionArgs
                        {
                            Category = "Build",
                            Configuration = 
                            {
                                { "ProjectName", "test" },
                            },
                            InputArtifacts = 
                            {
                                "test",
                            },
                            Name = "Build",
                            Owner = "AWS",
                            Provider = "CodeBuild",
                            Version = "1",
                        },
                    },
                    Name = "Build",
                },
            },
        });
        var webhookSecret = "super-secret";
        var barWebhook = new Aws.CodePipeline.Webhook("barWebhook", new Aws.CodePipeline.WebhookArgs
        {
            Authentication = "GITHUB_HMAC",
            AuthenticationConfiguration = new Aws.CodePipeline.Inputs.WebhookAuthenticationConfigurationArgs
            {
                SecretToken = webhookSecret,
            },
            Filters = 
            {
                new Aws.CodePipeline.Inputs.WebhookFilterArgs
                {
                    JsonPath = "$.ref",
                    MatchEquals = "refs/heads/{Branch}",
                },
            },
            TargetAction = "Source",
            TargetPipeline = barPipeline.Name,
        });
        // Wire the CodePipeline webhook into a GitHub repository.
        var barRepositoryWebhook = new Github.RepositoryWebhook("barRepositoryWebhook", new Github.RepositoryWebhookArgs
        {
            Configuration = new Github.Inputs.RepositoryWebhookConfigurationArgs
            {
                ContentType = "json",
                InsecureSsl = true,
                Secret = webhookSecret,
                Url = barWebhook.Url,
            },
            Events = 
            {
                "push",
            },
            Repository = github_repository.Repo.Name,
        });
    }

}
package main

import (
    "fmt"

    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/codepipeline"
    "github.com/pulumi/pulumi-github/sdk/go/github"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        barPipeline, err := codepipeline.NewPipeline(ctx, "barPipeline", &codepipeline.PipelineArgs{
            ArtifactStore: &codepipeline.PipelineArtifactStoreArgs{
                EncryptionKey: &codepipeline.PipelineArtifactStoreEncryptionKeyArgs{
                    Id:   pulumi.String(data.Aws_kms_alias.S3kmskey.Arn),
                    Type: pulumi.String("KMS"),
                },
                Location: pulumi.String(aws_s3_bucket.Bar.Bucket),
                Type:     pulumi.String("S3"),
            },
            RoleArn: pulumi.String(aws_iam_role.Bar.Arn),
            Stages: codepipeline.PipelineStageArray{
                &codepipeline.PipelineStageArgs{
                    Actions: codepipeline.PipelineStageActionArray{
                        &codepipeline.PipelineStageActionArgs{
                            Category: pulumi.String("Source"),
                            Configuration: pulumi.StringMap{
                                "Branch": pulumi.String("master"),
                                "Owner":  pulumi.String("my-organization"),
                                "Repo":   pulumi.String("test"),
                            },
                            Name: pulumi.String("Source"),
                            OutputArtifacts: pulumi.StringArray{
                                pulumi.String("test"),
                            },
                            Owner:    pulumi.String("ThirdParty"),
                            Provider: pulumi.String("GitHub"),
                            Version:  pulumi.String("1"),
                        },
                    },
                    Name: pulumi.String("Source"),
                },
                &codepipeline.PipelineStageArgs{
                    Actions: codepipeline.PipelineStageActionArray{
                        &codepipeline.PipelineStageActionArgs{
                            Category: pulumi.String("Build"),
                            Configuration: pulumi.StringMap{
                                "ProjectName": pulumi.String("test"),
                            },
                            InputArtifacts: pulumi.StringArray{
                                pulumi.String("test"),
                            },
                            Name:     pulumi.String("Build"),
                            Owner:    pulumi.String("AWS"),
                            Provider: pulumi.String("CodeBuild"),
                            Version:  pulumi.String("1"),
                        },
                    },
                    Name: pulumi.String("Build"),
                },
            },
        })
        if err != nil {
            return err
        }
        webhookSecret := "super-secret"
        barWebhook, err := codepipeline.NewWebhook(ctx, "barWebhook", &codepipeline.WebhookArgs{
            Authentication: pulumi.String("GITHUB_HMAC"),
            AuthenticationConfiguration: &codepipeline.WebhookAuthenticationConfigurationArgs{
                SecretToken: pulumi.String(webhookSecret),
            },
            Filters: codepipeline.WebhookFilterArray{
                &codepipeline.WebhookFilterArgs{
                    JsonPath:    pulumi.String(fmt.Sprintf("%v%v", "$", ".ref")),
                    MatchEquals: pulumi.String("refs/heads/{Branch}"),
                },
            },
            TargetAction:   pulumi.String("Source"),
            TargetPipeline: barPipeline.Name,
        })
        if err != nil {
            return err
        }
        _, err = github.NewRepositoryWebhook(ctx, "barRepositoryWebhook", &github.RepositoryWebhookArgs{
            Configuration: &github.RepositoryWebhookConfigurationArgs{
                ContentType: pulumi.String("json"),
                InsecureSsl: pulumi.Bool(true),
                Secret:      pulumi.String(webhookSecret),
                Url:         barWebhook.Url,
            },
            Events: pulumi.StringArray{
                pulumi.String("push"),
            },
            Repository: pulumi.String(github_repository.Repo.Name),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws
import pulumi_github as github

bar_pipeline = aws.codepipeline.Pipeline("barPipeline",
    artifact_store={
        "encryption_key": {
            "id": data["aws_kms_alias"]["s3kmskey"]["arn"],
            "type": "KMS",
        },
        "location": aws_s3_bucket["bar"]["bucket"],
        "type": "S3",
    },
    role_arn=aws_iam_role["bar"]["arn"],
    stages=[
        {
            "actions": [{
                "category": "Source",
                "configuration": {
                    "Branch": "master",
                    "Owner": "my-organization",
                    "Repo": "test",
                },
                "name": "Source",
                "outputArtifacts": ["test"],
                "owner": "ThirdParty",
                "provider": "GitHub",
                "version": "1",
            }],
            "name": "Source",
        },
        {
            "actions": [{
                "category": "Build",
                "configuration": {
                    "ProjectName": "test",
                },
                "inputArtifacts": ["test"],
                "name": "Build",
                "owner": "AWS",
                "provider": "CodeBuild",
                "version": "1",
            }],
            "name": "Build",
        },
    ])
webhook_secret = "super-secret"
bar_webhook = aws.codepipeline.Webhook("barWebhook",
    authentication="GITHUB_HMAC",
    authentication_configuration={
        "secretToken": webhook_secret,
    },
    filters=[{
        "jsonPath": "$.ref",
        "matchEquals": "refs/heads/{Branch}",
    }],
    target_action="Source",
    target_pipeline=bar_pipeline.name)
# Wire the CodePipeline webhook into a GitHub repository.
bar_repository_webhook = github.RepositoryWebhook("barRepositoryWebhook",
    configuration={
        "contentType": "json",
        "insecureSsl": True,
        "secret": webhook_secret,
        "url": bar_webhook.url,
    },
    events=["push"],
    repository=github_repository["repo"]["name"])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as github from "@pulumi/github";

const barPipeline = new aws.codepipeline.Pipeline("bar", {
    artifactStores: {
        encryptionKey: {
            id: aws_kms_alias_s3kmskey.arn,
            type: "KMS",
        },
        location: aws_s3_bucket_bar.bucket,
        type: "S3",
    },
    roleArn: aws_iam_role_bar.arn,
    stages: [
        {
            actions: [{
                category: "Source",
                configuration: {
                    Branch: "master",
                    Owner: "my-organization",
                    Repo: "test",
                },
                name: "Source",
                outputArtifacts: ["test"],
                owner: "ThirdParty",
                provider: "GitHub",
                version: "1",
            }],
            name: "Source",
        },
        {
            actions: [{
                category: "Build",
                configuration: {
                    ProjectName: "test",
                },
                inputArtifacts: ["test"],
                name: "Build",
                owner: "AWS",
                provider: "CodeBuild",
                version: "1",
            }],
            name: "Build",
        },
    ],
});
const webhookSecret = "super-secret";
const barWebhook = new aws.codepipeline.Webhook("bar", {
    authentication: "GITHUB_HMAC",
    authenticationConfiguration: {
        secretToken: webhookSecret,
    },
    filters: [{
        jsonPath: "$.ref",
        matchEquals: "refs/heads/{Branch}",
    }],
    targetAction: "Source",
    targetPipeline: barPipeline.name,
});
// Wire the CodePipeline webhook into a GitHub repository.
const barRepositoryWebhook = new github.RepositoryWebhook("bar", {
    configuration: {
        contentType: "json",
        insecureSsl: true,
        secret: webhookSecret,
        url: barWebhook.url,
    },
    events: ["push"],
    repository: github_repository_repo.name,
});

Create a Webhook Resource

new Webhook(name: string, args: WebhookArgs, opts?: CustomResourceOptions);
def Webhook(resource_name, opts=None, authentication=None, authentication_configuration=None, filters=None, name=None, tags=None, target_action=None, target_pipeline=None, __props__=None);
func NewWebhook(ctx *Context, name string, args WebhookArgs, opts ...ResourceOption) (*Webhook, error)
public Webhook(string name, WebhookArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args WebhookArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args WebhookArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args WebhookArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Webhook Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The Webhook resource accepts the following input properties:

Authentication string

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

Filters List<WebhookFilterArgs>

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

TargetAction 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.

TargetPipeline string

The name of the pipeline.

AuthenticationConfiguration WebhookAuthenticationConfigurationArgs

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

Name string

The name of the webhook.

Tags Dictionary<string, string>

A map of tags to assign to the resource.

Authentication string

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

Filters []WebhookFilter

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

TargetAction 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.

TargetPipeline string

The name of the pipeline.

AuthenticationConfiguration WebhookAuthenticationConfiguration

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

Name string

The name of the webhook.

Tags map[string]string

A map of tags to assign to the resource.

authentication string

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

filters WebhookFilter[]

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

targetAction 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.

targetPipeline string

The name of the pipeline.

authenticationConfiguration WebhookAuthenticationConfiguration

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

name string

The name of the webhook.

tags {[key: string]: string}

A map of tags to assign to the resource.

authentication str

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

filters List[WebhookFilter]

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

target_action str

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.

target_pipeline str

The name of the pipeline.

authentication_configuration Dict[WebhookAuthenticationConfiguration]

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

name str

The name of the webhook.

tags Dict[str, str]

A map of tags to assign to the resource.

Outputs

All input properties are implicitly available as output properties. Additionally, the Webhook resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Url string

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

Id string
The provider-assigned unique ID for this managed resource.
Url string

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

id string
The provider-assigned unique ID for this managed resource.
url string

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

id str
The provider-assigned unique ID for this managed resource.
url str

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

Look up an Existing Webhook Resource

Get an existing Webhook resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: WebhookState, opts?: CustomResourceOptions): Webhook
static get(resource_name, id, opts=None, authentication=None, authentication_configuration=None, filters=None, name=None, tags=None, target_action=None, target_pipeline=None, url=None, __props__=None);
func GetWebhook(ctx *Context, name string, id IDInput, state *WebhookState, opts ...ResourceOption) (*Webhook, error)
public static Webhook Get(string name, Input<string> id, WebhookState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Authentication string

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

AuthenticationConfiguration WebhookAuthenticationConfigurationArgs

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

Filters List<WebhookFilterArgs>

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

Name string

The name of the webhook.

Tags Dictionary<string, string>

A map of tags to assign to the resource.

TargetAction 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.

TargetPipeline string

The name of the pipeline.

Url string

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

Authentication string

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

AuthenticationConfiguration WebhookAuthenticationConfiguration

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

Filters []WebhookFilter

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

Name string

The name of the webhook.

Tags map[string]string

A map of tags to assign to the resource.

TargetAction 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.

TargetPipeline string

The name of the pipeline.

Url string

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

authentication string

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

authenticationConfiguration WebhookAuthenticationConfiguration

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

filters WebhookFilter[]

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

name string

The name of the webhook.

tags {[key: string]: string}

A map of tags to assign to the resource.

targetAction 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.

targetPipeline string

The name of the pipeline.

url string

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

authentication str

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

authentication_configuration Dict[WebhookAuthenticationConfiguration]

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

filters List[WebhookFilter]

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

name str

The name of the webhook.

tags Dict[str, str]

A map of tags to assign to the resource.

target_action str

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.

target_pipeline str

The name of the pipeline.

url str

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

Supporting Types

WebhookAuthenticationConfiguration

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

AllowedIpRange string

A valid CIDR block for IP filtering. Required for IP.

SecretToken string

The shared secret for the GitHub repository webhook. Set this as secret in your github_repository_webhook’s configuration block. Required for GITHUB_HMAC.

AllowedIpRange string

A valid CIDR block for IP filtering. Required for IP.

SecretToken string

The shared secret for the GitHub repository webhook. Set this as secret in your github_repository_webhook’s configuration block. Required for GITHUB_HMAC.

allowedIpRange string

A valid CIDR block for IP filtering. Required for IP.

secretToken string

The shared secret for the GitHub repository webhook. Set this as secret in your github_repository_webhook’s configuration block. Required for GITHUB_HMAC.

allowedIpRange str

A valid CIDR block for IP filtering. Required for IP.

secretToken str

The shared secret for the GitHub repository webhook. Set this as secret in your github_repository_webhook’s configuration block. Required for GITHUB_HMAC.

WebhookFilter

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

JsonPath string

The JSON path to filter on.

MatchEquals string

The value to match on (e.g. refs/heads/{Branch}). See AWS docs for details.

JsonPath string

The JSON path to filter on.

MatchEquals string

The value to match on (e.g. refs/heads/{Branch}). See AWS docs for details.

jsonPath string

The JSON path to filter on.

matchEquals string

The value to match on (e.g. refs/heads/{Branch}). See AWS docs for details.

jsonPath str

The JSON path to filter on.

matchEquals str

The value to match on (e.g. refs/heads/{Branch}). See AWS docs for details.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.