Skip to content

Instantly share code, notes, and snippets.

@shar1z
Created December 8, 2022 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shar1z/5b906bb009715c3d6a6d3ba10e356b08 to your computer and use it in GitHub Desktop.
Save shar1z/5b906bb009715c3d6a6d3ba10e356b08 to your computer and use it in GitHub Desktop.
Pulumi GIST
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/s3"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/sns"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Create an S3 bucket.
bucket, err := s3.NewBucket(ctx, "my-bucket", &s3.BucketArgs{
// Add other bucket configuration options here.
})
if err != nil {
return err
}
// Create an SNS topic for notifications.
topic, err := sns.NewTopic(ctx, "my-topic", &sns.TopicArgs{
// Add other topic configuration options here.
})
if err != nil {
return err
}
// Add an SNS topic subscription for the bucket.
_, err = s3.NewBucketNotification(ctx, "bucket-notification", &s3.BucketNotificationArgs{
Bucket: bucket.ID(),
TopicConfigurations: s3.BucketNotificationTopicConfigurationArray{
s3.BucketNotificationTopicConfigurationArgs{
TopicArn: topic.Arn,
// Add other topic configuration options here.
},
},
})
if err != nil {
return err
}
return nil
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment