Skip to content

Commit

Permalink
Rewrite SNS/Eventbridge chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
richarvey committed Mar 21, 2022
1 parent 6517461 commit a5a10ea
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 265 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: "Enabling Event Bridge"
title: "Enabling EventBridge"
date: 2022-01-01
weight: 1
description: >
SNS, SQS and EventBridge Triggers.
EventBridge Triggers.
---
<span class=opex-off>OpEx</span>
<span class=sec-off>Sec</span>
Expand All @@ -21,28 +21,19 @@ To enable EventBridge event delivery in the S3 console.
- In the Buckets list, choose the name of the bucket that you want to enable events for.
- Choose Properties.
- Navigate to the Event Notifications section and find the Amazon EventBridge subsection. Choose Edit.

![Enabling EventBridge](../eventbridge-s3-1.png)

- Under Send notifications to Amazon EventBridge for all events in this bucket choose On.

__Note__
After you enable EventBridge, it takes around five minutes for the changes to take effect.

## Using the AWS CLI
The following example creates a bucket notification configuration for bucket DOC-EXAMPLE-BUCKET1 with Amazon EventBridge enabled.

```
aws s3api put-bucket-notification-configuration --bucket DOC-EXAMPLE-BUCKET1 --notification-configuration '{ "EventBridgeConfiguration": {} }'
```

## Using the REST API
You can programmatically enable Amazon EventBridge on a bucket by calling the Amazon S3 REST API. For more information see, see PutBucketNotificationConfiguration in the Amazon Simple Storage Service API Reference.

The following example shows the XML used to create a bucket notification configuration with Amazon EventBridge enabled.
The following example creates a bucket notification configuration for bucket <BUCKET-NAME> with Amazon EventBridge enabled.

```
<NotificationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<EventBridgeConfiguration>
</EventBridgeConfiguration>
</NotificationConfiguration>
aws s3api put-bucket-notification-configuration --bucket <BUCKET-NAME> --notification-configuration '{ "EventBridgeConfiguration": {} }'
```

## Creating EventBridge rules
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: "SNS Topic Notifications"
date: 2022-01-01
weight: 1
description: >
SNS Triggers.
---
<span class=opex-off>OpEx</span>
<span class=sec-off>Sec</span>
<span class=rel-sec>Rel</span>
<span class=perf-on>Perf</span>
<span class=cost-off>Cost</span>
<span class=sus-off>Sus</span>


## Configuring event notifications via the console

### Publish event messages to an SNS Topic

- Head to the SNS console and create a new topic, Just set the name and leave everything else as standard.
- Make a note of the ARN you'll need this in a second
- Now edit the SNS topic and edit the Acess Policy. We are going to narrow the policy down to SNS:Publish from your bucket only. Make sure your replace <SNS-ARN>, <BUCKET-NAME> and <ACCOUNT-ID> with your details:

```
{
"Version": "2012-10-17",
"Id": "example-ID",
"Statement": [
{
"Sid": "Example SNS topic policy",
"Effect": "Allow",
"Principal": {
"Service": "s3.amazonaws.com"
},
"Action": [
"SNS:Publish"
],
"Resource": "<SNS-ARN>",
"Condition": {
"ArnLike": {
"aws:SourceArn": "arn:aws:s3:*:*:<BUCKET-NAME>"
},
"StringEquals": {
"aws:SourceAccount": "<ACCOUNT-ID>"
}
}
}
]
}
```

- Save your settings
- Now back on the S3 console select your bucket and click edit
- Click on the __Properties__ tab and scroll down to __Notifications__

![Enable Notifications](./sns-s3-1.png)

- Create a new notification and follow the settings in the following screen shot and be sure to select the correct SNS Topic!

![Add The configuration](./sns-s3-2.png)



Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: "SNS and EventBridge"
date: 2022-01-01
weight: 1
description: >
SNS and EventBridge Triggers.
---
<span class=opex-off>OpEx</span>
<span class=sec-off>Sec</span>
<span class=rel-sec>Rel</span>
<span class=perf-on>Perf</span>
<span class=cost-off>Cost</span>
<span class=sus-off>Sus</span>

Enabling notifications is a bucket-level operation. You store notification configuration information in the notification subresource that's associated with a bucket. After you create or change the bucket notification configuration, it usually takes about five minutes for the changes to take effect. When the notification is first enabled, an s3:TestEvent occurs. Amazon S3 stores the notification configuration as XML in the notification subresource that's associated with a bucket.

### Technical Considerations

Using SNS or eventbridge can give you great flexibility to have actions performed when a file is upload/deleted/updated in S3. During this guide you'll also see you can additionally use SQS or trigger Lambda directly and you may wonder why not use these approaches instead, and you'd be right, It's more efficient to go direct to Lambda, however, SNS can deliver to multiple subscribers (lambda, email, etc) So it gives you a few more options. Eventbridge is also an enhancement over direct to Lambda as it allows you to filter which messages will actually triger Lambda running and potentially save you 1000's of unneeded invocations.

### Business Considerations

Using cheaper storage such as S3 has a real potential to lower your bill, but you'll probably want to do something with that data. This chapter shows that S3 can be a power hub allowing your data to be automatically processed on update or other operations. This way of working can help your business transform to a micro-services style of working, which will help you gain speed in rolling out new features and updates without affecting the entire business, thus you can innovate faster.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion content/en/docs/s3/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ menu:
weight: 20
---

Welcome to the first book in the "Well-Architected Guide" series. I'd like to say a big thank you to all who have supported me whilst I've created this completion of guides and howto's that help you use S3 in a Well-Architected way. We'll work our way through the 6 pillars of the well architected framework with recipes you can try out for your self to help your standing when scoring your AWS Well Architected Review.
Welcome to the first book in the "Well-Architected Guide" series, which brings you a collection of features and articles created for this series and some adopted from the AWS documentation and blogs. I'd like to say a big thank you to all who have supported me whilst I've created this completion of guides and howto's that help you use S3 in a Well-Architected way. We'll work our way through the 6 pillars of the well architected framework with recipes you can try out for your self to help your standing when scoring your AWS Well Architected Review.

0 comments on commit a5a10ea

Please sign in to comment.