Skip to content
This repository has been archived by the owner on Apr 10, 2020. It is now read-only.

Support S3 Create events #24

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

hmorch
Copy link

@hmorch hmorch commented Aug 27, 2015

We have a case where we can't use the SNS messages created by CloudTrail. But we can use events created by S3 when an object is created. This messages look different then the one from CloudTrail but contain all necessary data. So I convert this message to a CloudTrail one and go on.

AWS S3 Event reference: https://docs.aws.amazon.com/AmazonS3/latest/UG/SettingBucketNotifications.html

Example S3 message:
{
"Records": [
{
"eventVersion": "2.0",
"eventSource": "aws:s3",
"awsRegion": "eu-west-1",
"eventTime": "2015-08-27T08:48:40.124Z",
"eventName": "ObjectCreated:Copy",
"userIdentity": {
"principalId": ""
},
"requestParameters": {
"sourceIPAddress": "127.0.0.1"
},
"responseElements": {
"x-amz-request-id": "",
"x-amz-id-2": ""
},
"s3": {
"s3SchemaVersion": "1.0",
"configurationId": "CloudTrailAdded",
"bucket": {
"name": "MyCloudTrailLogs",
"ownerIdentity": {
"principalId": ""
},
"arn": "arn:aws:s3:::MyCloudTrailLogs"
},
"object": {
"key": "AWSLogs//CloudTrail/eu-west-1/2015/08/26/<accountId_CloudTrail_eu-west-1_20150826T0015Z_3HX7CI5fnU0uEUp6.json.gz",
"size": 14358,
"sequencer": "0055DECEE7B29D2D6A"
}
}
}
]
}

S3 can send SNS messages when an object is created. While containing the
same information as those from CloudTrail the structure is different. So
convert these messages into the known CloudTrail once.
@hmorch
Copy link
Author

hmorch commented Aug 27, 2015

Hi Traildash Team,

I'm less then a newbie to GO. I hope my pull request fits your needs and is not too bad style. At least my tests showed that it works.

Kind regards,
Holger

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant