This repository was archived by the owner on Apr 10, 2020. It is now read-only.
Open
Conversation
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.
Author
|
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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"
}
}
}
]
}