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, orUNAUTHENTICATED.- Filters
List<Webhook
Filter Args> One or more
filterblocks. Filter blocks are documented below.- Target
Action 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.
- Target
Pipeline string The name of the pipeline.
- Authentication
Configuration WebhookAuthentication Configuration Args An
authblock. Required forIPandGITHUB_HMAC. Auth blocks are documented below.- Name string
The name of the webhook.
- 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, orUNAUTHENTICATED.- Filters
[]Webhook
Filter One or more
filterblocks. Filter blocks are documented below.- Target
Action 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.
- Target
Pipeline string The name of the pipeline.
- Authentication
Configuration WebhookAuthentication Configuration An
authblock. Required forIPandGITHUB_HMAC. Auth blocks are documented below.- Name string
The name of the webhook.
- 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, orUNAUTHENTICATED.- filters
Webhook
Filter[] One or more
filterblocks. Filter blocks are documented below.- target
Action 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.
- target
Pipeline string The name of the pipeline.
- authentication
Configuration WebhookAuthentication Configuration An
authblock. Required forIPandGITHUB_HMAC. Auth blocks are documented below.- name string
The name of the webhook.
- {[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, orUNAUTHENTICATED.- filters
List[Webhook
Filter] One or more
filterblocks. 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[WebhookAuthentication Configuration] An
authblock. Required forIPandGITHUB_HMAC. Auth blocks are documented below.- name str
The name of the webhook.
- 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:
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): Webhookstatic 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, orUNAUTHENTICATED.- Authentication
Configuration WebhookAuthentication Configuration Args An
authblock. Required forIPandGITHUB_HMAC. Auth blocks are documented below.- Filters
List<Webhook
Filter Args> One or more
filterblocks. Filter blocks are documented below.- Name string
The name of the webhook.
- Dictionary<string, string>
A map of tags to assign to the resource.
- Target
Action 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.
- Target
Pipeline 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, orUNAUTHENTICATED.- Authentication
Configuration WebhookAuthentication Configuration An
authblock. Required forIPandGITHUB_HMAC. Auth blocks are documented below.- Filters
[]Webhook
Filter One or more
filterblocks. Filter blocks are documented below.- Name string
The name of the webhook.
- map[string]string
A map of tags to assign to the resource.
- Target
Action 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.
- Target
Pipeline 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, orUNAUTHENTICATED.- authentication
Configuration WebhookAuthentication Configuration An
authblock. Required forIPandGITHUB_HMAC. Auth blocks are documented below.- filters
Webhook
Filter[] One or more
filterblocks. Filter blocks are documented below.- name string
The name of the webhook.
- {[key: string]: string}
A map of tags to assign to the resource.
- target
Action 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.
- target
Pipeline 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, orUNAUTHENTICATED.- authentication_
configuration Dict[WebhookAuthentication Configuration] An
authblock. Required forIPandGITHUB_HMAC. Auth blocks are documented below.- filters
List[Webhook
Filter] One or more
filterblocks. Filter blocks are documented below.- name str
The name of the webhook.
- 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
- Allowed
Ip stringRange A valid CIDR block for
IPfiltering. Required forIP.- Secret
Token string The shared secret for the GitHub repository webhook. Set this as
secretin yourgithub_repository_webhook’sconfigurationblock. Required forGITHUB_HMAC.
- Allowed
Ip stringRange A valid CIDR block for
IPfiltering. Required forIP.- Secret
Token string The shared secret for the GitHub repository webhook. Set this as
secretin yourgithub_repository_webhook’sconfigurationblock. Required forGITHUB_HMAC.
- allowed
Ip stringRange A valid CIDR block for
IPfiltering. Required forIP.- secret
Token string The shared secret for the GitHub repository webhook. Set this as
secretin yourgithub_repository_webhook’sconfigurationblock. Required forGITHUB_HMAC.
- allowed
Ip strRange A valid CIDR block for
IPfiltering. Required forIP.- secret
Token str The shared secret for the GitHub repository webhook. Set this as
secretin yourgithub_repository_webhook’sconfigurationblock. Required forGITHUB_HMAC.
WebhookFilter
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.