published on Tuesday, Mar 10, 2026 by Pulumi
published on Tuesday, Mar 10, 2026 by Pulumi
Manages a S3 Bucket Notification Configuration. For additional information, see the Configuring S3 Event Notifications section in the Amazon S3 Developer Guide.
NOTE: S3 Buckets only support a single notification configuration. Declaring multiple
aws.s3.BucketNotificationresources to the same S3 Bucket will cause a perpetual difference in configuration. See the example “Trigger multiple Lambda functions” for an option.
Example Usage
Add notification configuration to SNS Topic
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var bucket = new Aws.S3.BucketV2("bucket");
var topicPolicyDocument = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Effect = "Allow",
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "Service",
Identifiers = new[]
{
"s3.amazonaws.com",
},
},
},
Actions = new[]
{
"SNS:Publish",
},
Resources = new[]
{
"arn:aws:sns:*:*:s3-event-notification-topic",
},
Conditions = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
{
Test = "ArnLike",
Variable = "aws:SourceArn",
Values = new[]
{
bucket.Arn,
},
},
},
},
},
});
var topicTopic = new Aws.Sns.Topic("topicTopic", new()
{
Policy = topicPolicyDocument.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
});
var bucketNotification = new Aws.S3.BucketNotification("bucketNotification", new()
{
Bucket = bucket.Id,
Topics = new[]
{
new Aws.S3.Inputs.BucketNotificationTopicArgs
{
TopicArn = topicTopic.Arn,
Events = new[]
{
"s3:ObjectCreated:*",
},
FilterSuffix = ".log",
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/sns"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
bucket, err := s3.NewBucketV2(ctx, "bucket", nil)
if err != nil {
return err
}
topicPolicyDocument := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
Statements: iam.GetPolicyDocumentStatementArray{
&iam.GetPolicyDocumentStatementArgs{
Effect: pulumi.String("Allow"),
Principals: iam.GetPolicyDocumentStatementPrincipalArray{
&iam.GetPolicyDocumentStatementPrincipalArgs{
Type: pulumi.String("Service"),
Identifiers: pulumi.StringArray{
pulumi.String("s3.amazonaws.com"),
},
},
},
Actions: pulumi.StringArray{
pulumi.String("SNS:Publish"),
},
Resources: pulumi.StringArray{
pulumi.String("arn:aws:sns:*:*:s3-event-notification-topic"),
},
Conditions: iam.GetPolicyDocumentStatementConditionArray{
&iam.GetPolicyDocumentStatementConditionArgs{
Test: pulumi.String("ArnLike"),
Variable: pulumi.String("aws:SourceArn"),
Values: pulumi.StringArray{
bucket.Arn,
},
},
},
},
},
}, nil)
topicTopic, err := sns.NewTopic(ctx, "topicTopic", &sns.TopicArgs{
Policy: topicPolicyDocument.ApplyT(func(topicPolicyDocument iam.GetPolicyDocumentResult) (*string, error) {
return &topicPolicyDocument.Json, nil
}).(pulumi.StringPtrOutput),
})
if err != nil {
return err
}
_, err = s3.NewBucketNotification(ctx, "bucketNotification", &s3.BucketNotificationArgs{
Bucket: bucket.ID(),
Topics: s3.BucketNotificationTopicArray{
&s3.BucketNotificationTopicArgs{
TopicArn: topicTopic.Arn,
Events: pulumi.StringArray{
pulumi.String("s3:ObjectCreated:*"),
},
FilterSuffix: pulumi.String(".log"),
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.sns.Topic;
import com.pulumi.aws.sns.TopicArgs;
import com.pulumi.aws.s3.BucketNotification;
import com.pulumi.aws.s3.BucketNotificationArgs;
import com.pulumi.aws.s3.inputs.BucketNotificationTopicArgs;
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 bucket = new BucketV2("bucket");
final var topicPolicyDocument = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.effect("Allow")
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("Service")
.identifiers("s3.amazonaws.com")
.build())
.actions("SNS:Publish")
.resources("arn:aws:sns:*:*:s3-event-notification-topic")
.conditions(GetPolicyDocumentStatementConditionArgs.builder()
.test("ArnLike")
.variable("aws:SourceArn")
.values(bucket.arn())
.build())
.build())
.build());
var topicTopic = new Topic("topicTopic", TopicArgs.builder()
.policy(topicPolicyDocument.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult).applyValue(topicPolicyDocument -> topicPolicyDocument.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json())))
.build());
var bucketNotification = new BucketNotification("bucketNotification", BucketNotificationArgs.builder()
.bucket(bucket.id())
.topics(BucketNotificationTopicArgs.builder()
.topicArn(topicTopic.arn())
.events("s3:ObjectCreated:*")
.filterSuffix(".log")
.build())
.build());
}
}
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const bucket = new aws.s3.BucketV2("bucket", {});
const topicPolicyDocument = aws.iam.getPolicyDocumentOutput({
statements: [{
effect: "Allow",
principals: [{
type: "Service",
identifiers: ["s3.amazonaws.com"],
}],
actions: ["SNS:Publish"],
resources: ["arn:aws:sns:*:*:s3-event-notification-topic"],
conditions: [{
test: "ArnLike",
variable: "aws:SourceArn",
values: [bucket.arn],
}],
}],
});
const topicTopic = new aws.sns.Topic("topicTopic", {policy: topicPolicyDocument.apply(topicPolicyDocument => topicPolicyDocument.json)});
const bucketNotification = new aws.s3.BucketNotification("bucketNotification", {
bucket: bucket.id,
topics: [{
topicArn: topicTopic.arn,
events: ["s3:ObjectCreated:*"],
filterSuffix: ".log",
}],
});
import pulumi
import pulumi_aws as aws
bucket = aws.s3.BucketV2("bucket")
topic_policy_document = aws.iam.get_policy_document_output(statements=[aws.iam.GetPolicyDocumentStatementArgs(
effect="Allow",
principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
type="Service",
identifiers=["s3.amazonaws.com"],
)],
actions=["SNS:Publish"],
resources=["arn:aws:sns:*:*:s3-event-notification-topic"],
conditions=[aws.iam.GetPolicyDocumentStatementConditionArgs(
test="ArnLike",
variable="aws:SourceArn",
values=[bucket.arn],
)],
)])
topic_topic = aws.sns.Topic("topicTopic", policy=topic_policy_document.json)
bucket_notification = aws.s3.BucketNotification("bucketNotification",
bucket=bucket.id,
topics=[aws.s3.BucketNotificationTopicArgs(
topic_arn=topic_topic.arn,
events=["s3:ObjectCreated:*"],
filter_suffix=".log",
)])
resources:
topicTopic:
type: aws:sns:Topic
properties:
policy: ${topicPolicyDocument.json}
bucket:
type: aws:s3:BucketV2
bucketNotification:
type: aws:s3:BucketNotification
properties:
bucket: ${bucket.id}
topics:
- topicArn: ${topicTopic.arn}
events:
- s3:ObjectCreated:*
filterSuffix: .log
variables:
topicPolicyDocument:
fn::invoke:
Function: aws:iam:getPolicyDocument
Arguments:
statements:
- effect: Allow
principals:
- type: Service
identifiers:
- s3.amazonaws.com
actions:
- SNS:Publish
resources:
- arn:aws:sns:*:*:s3-event-notification-topic
conditions:
- test: ArnLike
variable: aws:SourceArn
values:
- ${bucket.arn}
Add notification configuration to SQS Queue
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var bucket = new Aws.S3.BucketV2("bucket");
var queuePolicyDocument = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Effect = "Allow",
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "*",
Identifiers = new[]
{
"*",
},
},
},
Actions = new[]
{
"sqs:SendMessage",
},
Resources = new[]
{
"arn:aws:sqs:*:*:s3-event-notification-queue",
},
Conditions = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
{
Test = "ArnEquals",
Variable = "aws:SourceArn",
Values = new[]
{
bucket.Arn,
},
},
},
},
},
});
var queueQueue = new Aws.Sqs.Queue("queueQueue", new()
{
Policy = queuePolicyDocument.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
});
var bucketNotification = new Aws.S3.BucketNotification("bucketNotification", new()
{
Bucket = bucket.Id,
Queues = new[]
{
new Aws.S3.Inputs.BucketNotificationQueueArgs
{
QueueArn = queueQueue.Arn,
Events = new[]
{
"s3:ObjectCreated:*",
},
FilterSuffix = ".log",
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/sqs"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
bucket, err := s3.NewBucketV2(ctx, "bucket", nil)
if err != nil {
return err
}
queuePolicyDocument := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
Statements: iam.GetPolicyDocumentStatementArray{
&iam.GetPolicyDocumentStatementArgs{
Effect: pulumi.String("Allow"),
Principals: iam.GetPolicyDocumentStatementPrincipalArray{
&iam.GetPolicyDocumentStatementPrincipalArgs{
Type: pulumi.String("*"),
Identifiers: pulumi.StringArray{
pulumi.String("*"),
},
},
},
Actions: pulumi.StringArray{
pulumi.String("sqs:SendMessage"),
},
Resources: pulumi.StringArray{
pulumi.String("arn:aws:sqs:*:*:s3-event-notification-queue"),
},
Conditions: iam.GetPolicyDocumentStatementConditionArray{
&iam.GetPolicyDocumentStatementConditionArgs{
Test: pulumi.String("ArnEquals"),
Variable: pulumi.String("aws:SourceArn"),
Values: pulumi.StringArray{
bucket.Arn,
},
},
},
},
},
}, nil)
queueQueue, err := sqs.NewQueue(ctx, "queueQueue", &sqs.QueueArgs{
Policy: queuePolicyDocument.ApplyT(func(queuePolicyDocument iam.GetPolicyDocumentResult) (*string, error) {
return &queuePolicyDocument.Json, nil
}).(pulumi.StringPtrOutput),
})
if err != nil {
return err
}
_, err = s3.NewBucketNotification(ctx, "bucketNotification", &s3.BucketNotificationArgs{
Bucket: bucket.ID(),
Queues: s3.BucketNotificationQueueArray{
&s3.BucketNotificationQueueArgs{
QueueArn: queueQueue.Arn,
Events: pulumi.StringArray{
pulumi.String("s3:ObjectCreated:*"),
},
FilterSuffix: pulumi.String(".log"),
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.sqs.Queue;
import com.pulumi.aws.sqs.QueueArgs;
import com.pulumi.aws.s3.BucketNotification;
import com.pulumi.aws.s3.BucketNotificationArgs;
import com.pulumi.aws.s3.inputs.BucketNotificationQueueArgs;
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 bucket = new BucketV2("bucket");
final var queuePolicyDocument = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.effect("Allow")
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("*")
.identifiers("*")
.build())
.actions("sqs:SendMessage")
.resources("arn:aws:sqs:*:*:s3-event-notification-queue")
.conditions(GetPolicyDocumentStatementConditionArgs.builder()
.test("ArnEquals")
.variable("aws:SourceArn")
.values(bucket.arn())
.build())
.build())
.build());
var queueQueue = new Queue("queueQueue", QueueArgs.builder()
.policy(queuePolicyDocument.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult).applyValue(queuePolicyDocument -> queuePolicyDocument.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json())))
.build());
var bucketNotification = new BucketNotification("bucketNotification", BucketNotificationArgs.builder()
.bucket(bucket.id())
.queues(BucketNotificationQueueArgs.builder()
.queueArn(queueQueue.arn())
.events("s3:ObjectCreated:*")
.filterSuffix(".log")
.build())
.build());
}
}
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const bucket = new aws.s3.BucketV2("bucket", {});
const queuePolicyDocument = aws.iam.getPolicyDocumentOutput({
statements: [{
effect: "Allow",
principals: [{
type: "*",
identifiers: ["*"],
}],
actions: ["sqs:SendMessage"],
resources: ["arn:aws:sqs:*:*:s3-event-notification-queue"],
conditions: [{
test: "ArnEquals",
variable: "aws:SourceArn",
values: [bucket.arn],
}],
}],
});
const queueQueue = new aws.sqs.Queue("queueQueue", {policy: queuePolicyDocument.apply(queuePolicyDocument => queuePolicyDocument.json)});
const bucketNotification = new aws.s3.BucketNotification("bucketNotification", {
bucket: bucket.id,
queues: [{
queueArn: queueQueue.arn,
events: ["s3:ObjectCreated:*"],
filterSuffix: ".log",
}],
});
import pulumi
import pulumi_aws as aws
bucket = aws.s3.BucketV2("bucket")
queue_policy_document = aws.iam.get_policy_document_output(statements=[aws.iam.GetPolicyDocumentStatementArgs(
effect="Allow",
principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
type="*",
identifiers=["*"],
)],
actions=["sqs:SendMessage"],
resources=["arn:aws:sqs:*:*:s3-event-notification-queue"],
conditions=[aws.iam.GetPolicyDocumentStatementConditionArgs(
test="ArnEquals",
variable="aws:SourceArn",
values=[bucket.arn],
)],
)])
queue_queue = aws.sqs.Queue("queueQueue", policy=queue_policy_document.json)
bucket_notification = aws.s3.BucketNotification("bucketNotification",
bucket=bucket.id,
queues=[aws.s3.BucketNotificationQueueArgs(
queue_arn=queue_queue.arn,
events=["s3:ObjectCreated:*"],
filter_suffix=".log",
)])
resources:
queueQueue:
type: aws:sqs:Queue
properties:
policy: ${queuePolicyDocument.json}
bucket:
type: aws:s3:BucketV2
bucketNotification:
type: aws:s3:BucketNotification
properties:
bucket: ${bucket.id}
queues:
- queueArn: ${queueQueue.arn}
events:
- s3:ObjectCreated:*
filterSuffix: .log
variables:
queuePolicyDocument:
fn::invoke:
Function: aws:iam:getPolicyDocument
Arguments:
statements:
- effect: Allow
principals:
- type: '*'
identifiers:
- '*'
actions:
- sqs:SendMessage
resources:
- arn:aws:sqs:*:*:s3-event-notification-queue
conditions:
- test: ArnEquals
variable: aws:SourceArn
values:
- ${bucket.arn}
Add notification configuration to Lambda Function
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var assumeRole = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Effect = "Allow",
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "Service",
Identifiers = new[]
{
"lambda.amazonaws.com",
},
},
},
Actions = new[]
{
"sts:AssumeRole",
},
},
},
});
var iamForLambda = new Aws.Iam.Role("iamForLambda", new()
{
AssumeRolePolicy = assumeRole.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
});
var func = new Aws.Lambda.Function("func", new()
{
Code = new FileArchive("your-function.zip"),
Role = iamForLambda.Arn,
Handler = "exports.example",
Runtime = "go1.x",
});
var bucket = new Aws.S3.BucketV2("bucket");
var allowBucket = new Aws.Lambda.Permission("allowBucket", new()
{
Action = "lambda:InvokeFunction",
Function = func.Arn,
Principal = "s3.amazonaws.com",
SourceArn = bucket.Arn,
});
var bucketNotification = new Aws.S3.BucketNotification("bucketNotification", new()
{
Bucket = bucket.Id,
LambdaFunctions = new[]
{
new Aws.S3.Inputs.BucketNotificationLambdaFunctionArgs
{
LambdaFunctionArn = func.Arn,
Events = new[]
{
"s3:ObjectCreated:*",
},
FilterPrefix = "AWSLogs/",
FilterSuffix = ".log",
},
},
}, new CustomResourceOptions
{
DependsOn = new[]
{
allowBucket,
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lambda"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
Statements: []iam.GetPolicyDocumentStatement{
{
Effect: pulumi.StringRef("Allow"),
Principals: []iam.GetPolicyDocumentStatementPrincipal{
{
Type: "Service",
Identifiers: []string{
"lambda.amazonaws.com",
},
},
},
Actions: []string{
"sts:AssumeRole",
},
},
},
}, nil)
if err != nil {
return err
}
iamForLambda, err := iam.NewRole(ctx, "iamForLambda", &iam.RoleArgs{
AssumeRolePolicy: *pulumi.String(assumeRole.Json),
})
if err != nil {
return err
}
_, err = lambda.NewFunction(ctx, "func", &lambda.FunctionArgs{
Code: pulumi.NewFileArchive("your-function.zip"),
Role: iamForLambda.Arn,
Handler: pulumi.String("exports.example"),
Runtime: pulumi.String("go1.x"),
})
if err != nil {
return err
}
bucket, err := s3.NewBucketV2(ctx, "bucket", nil)
if err != nil {
return err
}
allowBucket, err := lambda.NewPermission(ctx, "allowBucket", &lambda.PermissionArgs{
Action: pulumi.String("lambda:InvokeFunction"),
Function: _func.Arn,
Principal: pulumi.String("s3.amazonaws.com"),
SourceArn: bucket.Arn,
})
if err != nil {
return err
}
_, err = s3.NewBucketNotification(ctx, "bucketNotification", &s3.BucketNotificationArgs{
Bucket: bucket.ID(),
LambdaFunctions: s3.BucketNotificationLambdaFunctionArray{
&s3.BucketNotificationLambdaFunctionArgs{
LambdaFunctionArn: _func.Arn,
Events: pulumi.StringArray{
pulumi.String("s3:ObjectCreated:*"),
},
FilterPrefix: pulumi.String("AWSLogs/"),
FilterSuffix: pulumi.String(".log"),
},
},
}, pulumi.DependsOn([]pulumi.Resource{
allowBucket,
}))
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.lambda.Function;
import com.pulumi.aws.lambda.FunctionArgs;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.lambda.Permission;
import com.pulumi.aws.lambda.PermissionArgs;
import com.pulumi.aws.s3.BucketNotification;
import com.pulumi.aws.s3.BucketNotificationArgs;
import com.pulumi.aws.s3.inputs.BucketNotificationLambdaFunctionArgs;
import com.pulumi.resources.CustomResourceOptions;
import com.pulumi.asset.FileArchive;
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) {
final var assumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.effect("Allow")
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("Service")
.identifiers("lambda.amazonaws.com")
.build())
.actions("sts:AssumeRole")
.build())
.build());
var iamForLambda = new Role("iamForLambda", RoleArgs.builder()
.assumeRolePolicy(assumeRole.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))
.build());
var func = new Function("func", FunctionArgs.builder()
.code(new FileArchive("your-function.zip"))
.role(iamForLambda.arn())
.handler("exports.example")
.runtime("go1.x")
.build());
var bucket = new BucketV2("bucket");
var allowBucket = new Permission("allowBucket", PermissionArgs.builder()
.action("lambda:InvokeFunction")
.function(func.arn())
.principal("s3.amazonaws.com")
.sourceArn(bucket.arn())
.build());
var bucketNotification = new BucketNotification("bucketNotification", BucketNotificationArgs.builder()
.bucket(bucket.id())
.lambdaFunctions(BucketNotificationLambdaFunctionArgs.builder()
.lambdaFunctionArn(func.arn())
.events("s3:ObjectCreated:*")
.filterPrefix("AWSLogs/")
.filterSuffix(".log")
.build())
.build(), CustomResourceOptions.builder()
.dependsOn(allowBucket)
.build());
}
}
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const assumeRole = aws.iam.getPolicyDocument({
statements: [{
effect: "Allow",
principals: [{
type: "Service",
identifiers: ["lambda.amazonaws.com"],
}],
actions: ["sts:AssumeRole"],
}],
});
const iamForLambda = new aws.iam.Role("iamForLambda", {assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json)});
const func = new aws.lambda.Function("func", {
code: new pulumi.asset.FileArchive("your-function.zip"),
role: iamForLambda.arn,
handler: "exports.example",
runtime: "go1.x",
});
const bucket = new aws.s3.BucketV2("bucket", {});
const allowBucket = new aws.lambda.Permission("allowBucket", {
action: "lambda:InvokeFunction",
"function": func.arn,
principal: "s3.amazonaws.com",
sourceArn: bucket.arn,
});
const bucketNotification = new aws.s3.BucketNotification("bucketNotification", {
bucket: bucket.id,
lambdaFunctions: [{
lambdaFunctionArn: func.arn,
events: ["s3:ObjectCreated:*"],
filterPrefix: "AWSLogs/",
filterSuffix: ".log",
}],
}, {
dependsOn: [allowBucket],
});
import pulumi
import pulumi_aws as aws
assume_role = aws.iam.get_policy_document(statements=[aws.iam.GetPolicyDocumentStatementArgs(
effect="Allow",
principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
type="Service",
identifiers=["lambda.amazonaws.com"],
)],
actions=["sts:AssumeRole"],
)])
iam_for_lambda = aws.iam.Role("iamForLambda", assume_role_policy=assume_role.json)
func = aws.lambda_.Function("func",
code=pulumi.FileArchive("your-function.zip"),
role=iam_for_lambda.arn,
handler="exports.example",
runtime="go1.x")
bucket = aws.s3.BucketV2("bucket")
allow_bucket = aws.lambda_.Permission("allowBucket",
action="lambda:InvokeFunction",
function=func.arn,
principal="s3.amazonaws.com",
source_arn=bucket.arn)
bucket_notification = aws.s3.BucketNotification("bucketNotification",
bucket=bucket.id,
lambda_functions=[aws.s3.BucketNotificationLambdaFunctionArgs(
lambda_function_arn=func.arn,
events=["s3:ObjectCreated:*"],
filter_prefix="AWSLogs/",
filter_suffix=".log",
)],
opts=pulumi.ResourceOptions(depends_on=[allow_bucket]))
resources:
iamForLambda:
type: aws:iam:Role
properties:
assumeRolePolicy: ${assumeRole.json}
allowBucket:
type: aws:lambda:Permission
properties:
action: lambda:InvokeFunction
function: ${func.arn}
principal: s3.amazonaws.com
sourceArn: ${bucket.arn}
func:
type: aws:lambda:Function
properties:
code:
fn::FileArchive: your-function.zip
role: ${iamForLambda.arn}
handler: exports.example
runtime: go1.x
bucket:
type: aws:s3:BucketV2
bucketNotification:
type: aws:s3:BucketNotification
properties:
bucket: ${bucket.id}
lambdaFunctions:
- lambdaFunctionArn: ${func.arn}
events:
- s3:ObjectCreated:*
filterPrefix: AWSLogs/
filterSuffix: .log
options:
dependson:
- ${allowBucket}
variables:
assumeRole:
fn::invoke:
Function: aws:iam:getPolicyDocument
Arguments:
statements:
- effect: Allow
principals:
- type: Service
identifiers:
- lambda.amazonaws.com
actions:
- sts:AssumeRole
Trigger multiple Lambda functions
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var bucket = new Aws.S3.BucketV2("bucket");
var queuePolicyDocument = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Effect = "Allow",
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "*",
Identifiers = new[]
{
"*",
},
},
},
Actions = new[]
{
"sqs:SendMessage",
},
Resources = new[]
{
"arn:aws:sqs:*:*:s3-event-notification-queue",
},
Conditions = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
{
Test = "ArnEquals",
Variable = "aws:SourceArn",
Values = new[]
{
bucket.Arn,
},
},
},
},
},
});
var queueQueue = new Aws.Sqs.Queue("queueQueue", new()
{
Policy = queuePolicyDocument.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
});
var bucketNotification = new Aws.S3.BucketNotification("bucketNotification", new()
{
Bucket = bucket.Id,
Queues = new[]
{
new Aws.S3.Inputs.BucketNotificationQueueArgs
{
Id = "image-upload-event",
QueueArn = queueQueue.Arn,
Events = new[]
{
"s3:ObjectCreated:*",
},
FilterPrefix = "images/",
},
new Aws.S3.Inputs.BucketNotificationQueueArgs
{
Id = "video-upload-event",
QueueArn = queueQueue.Arn,
Events = new[]
{
"s3:ObjectCreated:*",
},
FilterPrefix = "videos/",
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/sqs"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
bucket, err := s3.NewBucketV2(ctx, "bucket", nil)
if err != nil {
return err
}
queuePolicyDocument := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
Statements: iam.GetPolicyDocumentStatementArray{
&iam.GetPolicyDocumentStatementArgs{
Effect: pulumi.String("Allow"),
Principals: iam.GetPolicyDocumentStatementPrincipalArray{
&iam.GetPolicyDocumentStatementPrincipalArgs{
Type: pulumi.String("*"),
Identifiers: pulumi.StringArray{
pulumi.String("*"),
},
},
},
Actions: pulumi.StringArray{
pulumi.String("sqs:SendMessage"),
},
Resources: pulumi.StringArray{
pulumi.String("arn:aws:sqs:*:*:s3-event-notification-queue"),
},
Conditions: iam.GetPolicyDocumentStatementConditionArray{
&iam.GetPolicyDocumentStatementConditionArgs{
Test: pulumi.String("ArnEquals"),
Variable: pulumi.String("aws:SourceArn"),
Values: pulumi.StringArray{
bucket.Arn,
},
},
},
},
},
}, nil)
queueQueue, err := sqs.NewQueue(ctx, "queueQueue", &sqs.QueueArgs{
Policy: queuePolicyDocument.ApplyT(func(queuePolicyDocument iam.GetPolicyDocumentResult) (*string, error) {
return &queuePolicyDocument.Json, nil
}).(pulumi.StringPtrOutput),
})
if err != nil {
return err
}
_, err = s3.NewBucketNotification(ctx, "bucketNotification", &s3.BucketNotificationArgs{
Bucket: bucket.ID(),
Queues: s3.BucketNotificationQueueArray{
&s3.BucketNotificationQueueArgs{
Id: pulumi.String("image-upload-event"),
QueueArn: queueQueue.Arn,
Events: pulumi.StringArray{
pulumi.String("s3:ObjectCreated:*"),
},
FilterPrefix: pulumi.String("images/"),
},
&s3.BucketNotificationQueueArgs{
Id: pulumi.String("video-upload-event"),
QueueArn: queueQueue.Arn,
Events: pulumi.StringArray{
pulumi.String("s3:ObjectCreated:*"),
},
FilterPrefix: pulumi.String("videos/"),
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.lambda.Function;
import com.pulumi.aws.lambda.FunctionArgs;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.lambda.Permission;
import com.pulumi.aws.lambda.PermissionArgs;
import com.pulumi.aws.s3.BucketNotification;
import com.pulumi.aws.s3.BucketNotificationArgs;
import com.pulumi.aws.s3.inputs.BucketNotificationLambdaFunctionArgs;
import com.pulumi.resources.CustomResourceOptions;
import com.pulumi.asset.FileArchive;
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) {
final var assumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.effect("Allow")
.principals(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference))
.actions("sts:AssumeRole")
.build());
var iamForLambda = new Role("iamForLambda", RoleArgs.builder()
.assumeRolePolicy(assumeRole.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))
.build());
var func1 = new Function("func1", FunctionArgs.builder()
.code(new FileArchive("your-function1.zip"))
.role(iamForLambda.arn())
.handler("exports.example")
.runtime("go1.x")
.build());
var bucket = new BucketV2("bucket");
var allowBucket1 = new Permission("allowBucket1", PermissionArgs.builder()
.action("lambda:InvokeFunction")
.function(func1.arn())
.principal("s3.amazonaws.com")
.sourceArn(bucket.arn())
.build());
var func2 = new Function("func2", FunctionArgs.builder()
.code(new FileArchive("your-function2.zip"))
.role(iamForLambda.arn())
.handler("exports.example")
.build());
var allowBucket2 = new Permission("allowBucket2", PermissionArgs.builder()
.action("lambda:InvokeFunction")
.function(func2.arn())
.principal("s3.amazonaws.com")
.sourceArn(bucket.arn())
.build());
var bucketNotification = new BucketNotification("bucketNotification", BucketNotificationArgs.builder()
.bucket(bucket.id())
.lambdaFunctions(
BucketNotificationLambdaFunctionArgs.builder()
.lambdaFunctionArn(func1.arn())
.events("s3:ObjectCreated:*")
.filterPrefix("AWSLogs/")
.filterSuffix(".log")
.build(),
BucketNotificationLambdaFunctionArgs.builder()
.lambdaFunctionArn(func2.arn())
.events("s3:ObjectCreated:*")
.filterPrefix("OtherLogs/")
.filterSuffix(".log")
.build())
.build(), CustomResourceOptions.builder()
.dependsOn(
allowBucket1,
allowBucket2)
.build());
}
}
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const bucket = new aws.s3.BucketV2("bucket", {});
const queuePolicyDocument = aws.iam.getPolicyDocumentOutput({
statements: [{
effect: "Allow",
principals: [{
type: "*",
identifiers: ["*"],
}],
actions: ["sqs:SendMessage"],
resources: ["arn:aws:sqs:*:*:s3-event-notification-queue"],
conditions: [{
test: "ArnEquals",
variable: "aws:SourceArn",
values: [bucket.arn],
}],
}],
});
const queueQueue = new aws.sqs.Queue("queueQueue", {policy: queuePolicyDocument.apply(queuePolicyDocument => queuePolicyDocument.json)});
const bucketNotification = new aws.s3.BucketNotification("bucketNotification", {
bucket: bucket.id,
queues: [
{
id: "image-upload-event",
queueArn: queueQueue.arn,
events: ["s3:ObjectCreated:*"],
filterPrefix: "images/",
},
{
id: "video-upload-event",
queueArn: queueQueue.arn,
events: ["s3:ObjectCreated:*"],
filterPrefix: "videos/",
},
],
});
import pulumi
import pulumi_aws as aws
bucket = aws.s3.BucketV2("bucket")
queue_policy_document = aws.iam.get_policy_document_output(statements=[aws.iam.GetPolicyDocumentStatementArgs(
effect="Allow",
principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
type="*",
identifiers=["*"],
)],
actions=["sqs:SendMessage"],
resources=["arn:aws:sqs:*:*:s3-event-notification-queue"],
conditions=[aws.iam.GetPolicyDocumentStatementConditionArgs(
test="ArnEquals",
variable="aws:SourceArn",
values=[bucket.arn],
)],
)])
queue_queue = aws.sqs.Queue("queueQueue", policy=queue_policy_document.json)
bucket_notification = aws.s3.BucketNotification("bucketNotification",
bucket=bucket.id,
queues=[
aws.s3.BucketNotificationQueueArgs(
id="image-upload-event",
queue_arn=queue_queue.arn,
events=["s3:ObjectCreated:*"],
filter_prefix="images/",
),
aws.s3.BucketNotificationQueueArgs(
id="video-upload-event",
queue_arn=queue_queue.arn,
events=["s3:ObjectCreated:*"],
filter_prefix="videos/",
),
])
resources:
iamForLambda:
type: aws:iam:Role
properties:
assumeRolePolicy: ${assumeRole.json}
allowBucket1:
type: aws:lambda:Permission
properties:
action: lambda:InvokeFunction
function: ${func1.arn}
principal: s3.amazonaws.com
sourceArn: ${bucket.arn}
func1:
type: aws:lambda:Function
properties:
code:
fn::FileArchive: your-function1.zip
role: ${iamForLambda.arn}
handler: exports.example
runtime: go1.x
allowBucket2:
type: aws:lambda:Permission
properties:
action: lambda:InvokeFunction
function: ${func2.arn}
principal: s3.amazonaws.com
sourceArn: ${bucket.arn}
func2:
type: aws:lambda:Function
properties:
code:
fn::FileArchive: your-function2.zip
role: ${iamForLambda.arn}
handler: exports.example
bucket:
type: aws:s3:BucketV2
bucketNotification:
type: aws:s3:BucketNotification
properties:
bucket: ${bucket.id}
lambdaFunctions:
- lambdaFunctionArn: ${func1.arn}
events:
- s3:ObjectCreated:*
filterPrefix: AWSLogs/
filterSuffix: .log
- lambdaFunctionArn: ${func2.arn}
events:
- s3:ObjectCreated:*
filterPrefix: OtherLogs/
filterSuffix: .log
options:
dependson:
- ${allowBucket1}
- ${allowBucket2}
variables:
assumeRole:
fn::invoke:
Function: aws:iam:getPolicyDocument
Arguments:
effect: Allow
principals:
- type: Service
identifiers:
- lambda.amazonaws.com
actions:
- sts:AssumeRole
Add multiple notification configurations to SQS Queue
using System.Collections.Generic;
using System.Linq;
using Pulumi;
return await Deployment.RunAsync(() =>
{
});
package main
import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.sqs.Queue;
import com.pulumi.aws.sqs.QueueArgs;
import com.pulumi.aws.s3.BucketNotification;
import com.pulumi.aws.s3.BucketNotificationArgs;
import com.pulumi.aws.s3.inputs.BucketNotificationQueueArgs;
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 bucket = new BucketV2("bucket");
final var queuePolicyDocument = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.effect("Allow")
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("*")
.identifiers("*")
.build())
.actions("sqs:SendMessage")
.resources("arn:aws:sqs:*:*:s3-event-notification-queue")
.conditions(GetPolicyDocumentStatementConditionArgs.builder()
.test("ArnEquals")
.variable("aws:SourceArn")
.values(bucket.arn())
.build())
.build())
.build());
var queueQueue = new Queue("queueQueue", QueueArgs.builder()
.policy(queuePolicyDocument.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult).applyValue(queuePolicyDocument -> queuePolicyDocument.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json())))
.build());
var bucketNotification = new BucketNotification("bucketNotification", BucketNotificationArgs.builder()
.bucket(bucket.id())
.queues(
BucketNotificationQueueArgs.builder()
.id("image-upload-event")
.queueArn(queueQueue.arn())
.events("s3:ObjectCreated:*")
.filterPrefix("images/")
.build(),
BucketNotificationQueueArgs.builder()
.id("video-upload-event")
.queueArn(queueQueue.arn())
.events("s3:ObjectCreated:*")
.filterPrefix("videos/")
.build())
.build());
}
}
import * as pulumi from "@pulumi/pulumi";
import pulumi
resources:
queueQueue:
type: aws:sqs:Queue
properties:
policy: ${queuePolicyDocument.json}
bucket:
type: aws:s3:BucketV2
bucketNotification:
type: aws:s3:BucketNotification
properties:
bucket: ${bucket.id}
queues:
- id: image-upload-event
queueArn: ${queueQueue.arn}
events:
- s3:ObjectCreated:*
filterPrefix: images/
- id: video-upload-event
queueArn: ${queueQueue.arn}
events:
- s3:ObjectCreated:*
filterPrefix: videos/
variables:
queuePolicyDocument:
fn::invoke:
Function: aws:iam:getPolicyDocument
Arguments:
statements:
- effect: Allow
principals:
- type: '*'
identifiers:
- '*'
actions:
- sqs:SendMessage
resources:
- arn:aws:sqs:*:*:s3-event-notification-queue
conditions:
- test: ArnEquals
variable: aws:SourceArn
values:
- ${bucket.arn}
key twice.
Example coming soon!
Example coming soon!
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
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) {
}
}
Example coming soon!
Example coming soon!
{}
Create BucketNotification Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new BucketNotification(name: string, args: BucketNotificationArgs, opts?: CustomResourceOptions);@overload
def BucketNotification(resource_name: str,
args: BucketNotificationArgs,
opts: Optional[ResourceOptions] = None)
@overload
def BucketNotification(resource_name: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
eventbridge: Optional[bool] = None,
lambda_functions: Optional[Sequence[BucketNotificationLambdaFunctionArgs]] = None,
queues: Optional[Sequence[BucketNotificationQueueArgs]] = None,
topics: Optional[Sequence[BucketNotificationTopicArgs]] = None)func NewBucketNotification(ctx *Context, name string, args BucketNotificationArgs, opts ...ResourceOption) (*BucketNotification, error)public BucketNotification(string name, BucketNotificationArgs args, CustomResourceOptions? opts = null)
public BucketNotification(String name, BucketNotificationArgs args)
public BucketNotification(String name, BucketNotificationArgs args, CustomResourceOptions options)
type: aws:s3:BucketNotification
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args BucketNotificationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args BucketNotificationArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args BucketNotificationArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args BucketNotificationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args BucketNotificationArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var bucketNotificationResource = new Aws.S3.BucketNotification("bucketNotificationResource", new()
{
Bucket = "string",
Eventbridge = false,
LambdaFunctions = new[]
{
new Aws.S3.Inputs.BucketNotificationLambdaFunctionArgs
{
Events = new[]
{
"string",
},
FilterPrefix = "string",
FilterSuffix = "string",
Id = "string",
LambdaFunctionArn = "string",
},
},
Queues = new[]
{
new Aws.S3.Inputs.BucketNotificationQueueArgs
{
Events = new[]
{
"string",
},
QueueArn = "string",
FilterPrefix = "string",
FilterSuffix = "string",
Id = "string",
},
},
Topics = new[]
{
new Aws.S3.Inputs.BucketNotificationTopicArgs
{
Events = new[]
{
"string",
},
TopicArn = "string",
FilterPrefix = "string",
FilterSuffix = "string",
Id = "string",
},
},
});
example, err := s3.NewBucketNotification(ctx, "bucketNotificationResource", &s3.BucketNotificationArgs{
Bucket: pulumi.String("string"),
Eventbridge: pulumi.Bool(false),
LambdaFunctions: s3.BucketNotificationLambdaFunctionArray{
&s3.BucketNotificationLambdaFunctionArgs{
Events: pulumi.StringArray{
pulumi.String("string"),
},
FilterPrefix: pulumi.String("string"),
FilterSuffix: pulumi.String("string"),
Id: pulumi.String("string"),
LambdaFunctionArn: pulumi.String("string"),
},
},
Queues: s3.BucketNotificationQueueArray{
&s3.BucketNotificationQueueArgs{
Events: pulumi.StringArray{
pulumi.String("string"),
},
QueueArn: pulumi.String("string"),
FilterPrefix: pulumi.String("string"),
FilterSuffix: pulumi.String("string"),
Id: pulumi.String("string"),
},
},
Topics: s3.BucketNotificationTopicArray{
&s3.BucketNotificationTopicArgs{
Events: pulumi.StringArray{
pulumi.String("string"),
},
TopicArn: pulumi.String("string"),
FilterPrefix: pulumi.String("string"),
FilterSuffix: pulumi.String("string"),
Id: pulumi.String("string"),
},
},
})
var bucketNotificationResource = new BucketNotification("bucketNotificationResource", BucketNotificationArgs.builder()
.bucket("string")
.eventbridge(false)
.lambdaFunctions(BucketNotificationLambdaFunctionArgs.builder()
.events("string")
.filterPrefix("string")
.filterSuffix("string")
.id("string")
.lambdaFunctionArn("string")
.build())
.queues(BucketNotificationQueueArgs.builder()
.events("string")
.queueArn("string")
.filterPrefix("string")
.filterSuffix("string")
.id("string")
.build())
.topics(BucketNotificationTopicArgs.builder()
.events("string")
.topicArn("string")
.filterPrefix("string")
.filterSuffix("string")
.id("string")
.build())
.build());
bucket_notification_resource = aws.s3.BucketNotification("bucketNotificationResource",
bucket="string",
eventbridge=False,
lambda_functions=[{
"events": ["string"],
"filter_prefix": "string",
"filter_suffix": "string",
"id": "string",
"lambda_function_arn": "string",
}],
queues=[{
"events": ["string"],
"queue_arn": "string",
"filter_prefix": "string",
"filter_suffix": "string",
"id": "string",
}],
topics=[{
"events": ["string"],
"topic_arn": "string",
"filter_prefix": "string",
"filter_suffix": "string",
"id": "string",
}])
const bucketNotificationResource = new aws.s3.BucketNotification("bucketNotificationResource", {
bucket: "string",
eventbridge: false,
lambdaFunctions: [{
events: ["string"],
filterPrefix: "string",
filterSuffix: "string",
id: "string",
lambdaFunctionArn: "string",
}],
queues: [{
events: ["string"],
queueArn: "string",
filterPrefix: "string",
filterSuffix: "string",
id: "string",
}],
topics: [{
events: ["string"],
topicArn: "string",
filterPrefix: "string",
filterSuffix: "string",
id: "string",
}],
});
type: aws:s3:BucketNotification
properties:
bucket: string
eventbridge: false
lambdaFunctions:
- events:
- string
filterPrefix: string
filterSuffix: string
id: string
lambdaFunctionArn: string
queues:
- events:
- string
filterPrefix: string
filterSuffix: string
id: string
queueArn: string
topics:
- events:
- string
filterPrefix: string
filterSuffix: string
id: string
topicArn: string
BucketNotification Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The BucketNotification resource accepts the following input properties:
- Bucket string
Name of the bucket for notification configuration.
The following arguments are optional:
- Eventbridge bool
- Whether to enable Amazon EventBridge notifications.
- Lambda
Functions List<BucketNotification Lambda Function> - Used to configure notifications to a Lambda Function. See below.
- Queues
List<Bucket
Notification Queue> - Notification configuration to SQS Queue. See below.
- Topics
List<Bucket
Notification Topic> - Notification configuration to SNS Topic. See below.
- Bucket string
Name of the bucket for notification configuration.
The following arguments are optional:
- Eventbridge bool
- Whether to enable Amazon EventBridge notifications.
- Lambda
Functions []BucketNotification Lambda Function Args - Used to configure notifications to a Lambda Function. See below.
- Queues
[]Bucket
Notification Queue Args - Notification configuration to SQS Queue. See below.
- Topics
[]Bucket
Notification Topic Args - Notification configuration to SNS Topic. See below.
- bucket String
Name of the bucket for notification configuration.
The following arguments are optional:
- eventbridge Boolean
- Whether to enable Amazon EventBridge notifications.
- lambda
Functions List<BucketNotification Lambda Function> - Used to configure notifications to a Lambda Function. See below.
- queues
List<Bucket
Notification Queue> - Notification configuration to SQS Queue. See below.
- topics
List<Bucket
Notification Topic> - Notification configuration to SNS Topic. See below.
- bucket string
Name of the bucket for notification configuration.
The following arguments are optional:
- eventbridge boolean
- Whether to enable Amazon EventBridge notifications.
- lambda
Functions BucketNotification Lambda Function[] - Used to configure notifications to a Lambda Function. See below.
- queues
Bucket
Notification Queue[] - Notification configuration to SQS Queue. See below.
- topics
Bucket
Notification Topic[] - Notification configuration to SNS Topic. See below.
- bucket str
Name of the bucket for notification configuration.
The following arguments are optional:
- eventbridge bool
- Whether to enable Amazon EventBridge notifications.
- lambda_
functions Sequence[BucketNotification Lambda Function Args] - Used to configure notifications to a Lambda Function. See below.
- queues
Sequence[Bucket
Notification Queue Args] - Notification configuration to SQS Queue. See below.
- topics
Sequence[Bucket
Notification Topic Args] - Notification configuration to SNS Topic. See below.
- bucket String
Name of the bucket for notification configuration.
The following arguments are optional:
- eventbridge Boolean
- Whether to enable Amazon EventBridge notifications.
- lambda
Functions List<Property Map> - Used to configure notifications to a Lambda Function. See below.
- queues List<Property Map>
- Notification configuration to SQS Queue. See below.
- topics List<Property Map>
- Notification configuration to SNS Topic. See below.
Outputs
All input properties are implicitly available as output properties. Additionally, the BucketNotification resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing BucketNotification Resource
Get an existing BucketNotification 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?: BucketNotificationState, opts?: CustomResourceOptions): BucketNotification@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
eventbridge: Optional[bool] = None,
lambda_functions: Optional[Sequence[BucketNotificationLambdaFunctionArgs]] = None,
queues: Optional[Sequence[BucketNotificationQueueArgs]] = None,
topics: Optional[Sequence[BucketNotificationTopicArgs]] = None) -> BucketNotificationfunc GetBucketNotification(ctx *Context, name string, id IDInput, state *BucketNotificationState, opts ...ResourceOption) (*BucketNotification, error)public static BucketNotification Get(string name, Input<string> id, BucketNotificationState? state, CustomResourceOptions? opts = null)public static BucketNotification get(String name, Output<String> id, BucketNotificationState state, CustomResourceOptions options)resources: _: type: aws:s3:BucketNotification get: id: ${id}- 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.
- 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.
- Bucket string
Name of the bucket for notification configuration.
The following arguments are optional:
- Eventbridge bool
- Whether to enable Amazon EventBridge notifications.
- Lambda
Functions List<BucketNotification Lambda Function> - Used to configure notifications to a Lambda Function. See below.
- Queues
List<Bucket
Notification Queue> - Notification configuration to SQS Queue. See below.
- Topics
List<Bucket
Notification Topic> - Notification configuration to SNS Topic. See below.
- Bucket string
Name of the bucket for notification configuration.
The following arguments are optional:
- Eventbridge bool
- Whether to enable Amazon EventBridge notifications.
- Lambda
Functions []BucketNotification Lambda Function Args - Used to configure notifications to a Lambda Function. See below.
- Queues
[]Bucket
Notification Queue Args - Notification configuration to SQS Queue. See below.
- Topics
[]Bucket
Notification Topic Args - Notification configuration to SNS Topic. See below.
- bucket String
Name of the bucket for notification configuration.
The following arguments are optional:
- eventbridge Boolean
- Whether to enable Amazon EventBridge notifications.
- lambda
Functions List<BucketNotification Lambda Function> - Used to configure notifications to a Lambda Function. See below.
- queues
List<Bucket
Notification Queue> - Notification configuration to SQS Queue. See below.
- topics
List<Bucket
Notification Topic> - Notification configuration to SNS Topic. See below.
- bucket string
Name of the bucket for notification configuration.
The following arguments are optional:
- eventbridge boolean
- Whether to enable Amazon EventBridge notifications.
- lambda
Functions BucketNotification Lambda Function[] - Used to configure notifications to a Lambda Function. See below.
- queues
Bucket
Notification Queue[] - Notification configuration to SQS Queue. See below.
- topics
Bucket
Notification Topic[] - Notification configuration to SNS Topic. See below.
- bucket str
Name of the bucket for notification configuration.
The following arguments are optional:
- eventbridge bool
- Whether to enable Amazon EventBridge notifications.
- lambda_
functions Sequence[BucketNotification Lambda Function Args] - Used to configure notifications to a Lambda Function. See below.
- queues
Sequence[Bucket
Notification Queue Args] - Notification configuration to SQS Queue. See below.
- topics
Sequence[Bucket
Notification Topic Args] - Notification configuration to SNS Topic. See below.
- bucket String
Name of the bucket for notification configuration.
The following arguments are optional:
- eventbridge Boolean
- Whether to enable Amazon EventBridge notifications.
- lambda
Functions List<Property Map> - Used to configure notifications to a Lambda Function. See below.
- queues List<Property Map>
- Notification configuration to SQS Queue. See below.
- topics List<Property Map>
- Notification configuration to SNS Topic. See below.
Supporting Types
BucketNotificationLambdaFunction, BucketNotificationLambdaFunctionArgs
- Events List<string>
- Event for which to send notifications.
- Filter
Prefix string - Object key name prefix.
- Filter
Suffix string - Object key name suffix.
- Id string
- Unique identifier for each of the notification configurations.
- Lambda
Function stringArn - Lambda function ARN.
- Events []string
- Event for which to send notifications.
- Filter
Prefix string - Object key name prefix.
- Filter
Suffix string - Object key name suffix.
- Id string
- Unique identifier for each of the notification configurations.
- Lambda
Function stringArn - Lambda function ARN.
- events List<String>
- Event for which to send notifications.
- filter
Prefix String - Object key name prefix.
- filter
Suffix String - Object key name suffix.
- id String
- Unique identifier for each of the notification configurations.
- lambda
Function StringArn - Lambda function ARN.
- events string[]
- Event for which to send notifications.
- filter
Prefix string - Object key name prefix.
- filter
Suffix string - Object key name suffix.
- id string
- Unique identifier for each of the notification configurations.
- lambda
Function stringArn - Lambda function ARN.
- events Sequence[str]
- Event for which to send notifications.
- filter_
prefix str - Object key name prefix.
- filter_
suffix str - Object key name suffix.
- id str
- Unique identifier for each of the notification configurations.
- lambda_
function_ strarn - Lambda function ARN.
- events List<String>
- Event for which to send notifications.
- filter
Prefix String - Object key name prefix.
- filter
Suffix String - Object key name suffix.
- id String
- Unique identifier for each of the notification configurations.
- lambda
Function StringArn - Lambda function ARN.
BucketNotificationQueue, BucketNotificationQueueArgs
- Events List<string>
- Specifies event for which to send notifications.
- Queue
Arn string - SQS queue ARN.
- Filter
Prefix string - Object key name prefix.
- Filter
Suffix string - Object key name suffix.
- Id string
- Unique identifier for each of the notification configurations.
- Events []string
- Specifies event for which to send notifications.
- Queue
Arn string - SQS queue ARN.
- Filter
Prefix string - Object key name prefix.
- Filter
Suffix string - Object key name suffix.
- Id string
- Unique identifier for each of the notification configurations.
- events List<String>
- Specifies event for which to send notifications.
- queue
Arn String - SQS queue ARN.
- filter
Prefix String - Object key name prefix.
- filter
Suffix String - Object key name suffix.
- id String
- Unique identifier for each of the notification configurations.
- events string[]
- Specifies event for which to send notifications.
- queue
Arn string - SQS queue ARN.
- filter
Prefix string - Object key name prefix.
- filter
Suffix string - Object key name suffix.
- id string
- Unique identifier for each of the notification configurations.
- events Sequence[str]
- Specifies event for which to send notifications.
- queue_
arn str - SQS queue ARN.
- filter_
prefix str - Object key name prefix.
- filter_
suffix str - Object key name suffix.
- id str
- Unique identifier for each of the notification configurations.
- events List<String>
- Specifies event for which to send notifications.
- queue
Arn String - SQS queue ARN.
- filter
Prefix String - Object key name prefix.
- filter
Suffix String - Object key name suffix.
- id String
- Unique identifier for each of the notification configurations.
BucketNotificationTopic, BucketNotificationTopicArgs
- Events List<string>
- Event for which to send notifications.
- Topic
Arn string - SNS topic ARN.
- Filter
Prefix string - Object key name prefix.
- Filter
Suffix string - Object key name suffix.
- Id string
- Unique identifier for each of the notification configurations.
- Events []string
- Event for which to send notifications.
- Topic
Arn string - SNS topic ARN.
- Filter
Prefix string - Object key name prefix.
- Filter
Suffix string - Object key name suffix.
- Id string
- Unique identifier for each of the notification configurations.
- events List<String>
- Event for which to send notifications.
- topic
Arn String - SNS topic ARN.
- filter
Prefix String - Object key name prefix.
- filter
Suffix String - Object key name suffix.
- id String
- Unique identifier for each of the notification configurations.
- events string[]
- Event for which to send notifications.
- topic
Arn string - SNS topic ARN.
- filter
Prefix string - Object key name prefix.
- filter
Suffix string - Object key name suffix.
- id string
- Unique identifier for each of the notification configurations.
- events Sequence[str]
- Event for which to send notifications.
- topic_
arn str - SNS topic ARN.
- filter_
prefix str - Object key name prefix.
- filter_
suffix str - Object key name suffix.
- id str
- Unique identifier for each of the notification configurations.
- events List<String>
- Event for which to send notifications.
- topic
Arn String - SNS topic ARN.
- filter
Prefix String - Object key name prefix.
- filter
Suffix String - Object key name suffix.
- id String
- Unique identifier for each of the notification configurations.
Import
S3 bucket notification can be imported using the bucket, e.g.,
$ pulumi import aws:s3/bucketNotification:BucketNotification bucket_notification bucket-name
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.
published on Tuesday, Mar 10, 2026 by Pulumi
