Skip to content

Commit

Permalink
cloudtrail to cloudwatch
Browse files Browse the repository at this point in the history
  • Loading branch information
omenking committed Mar 9, 2024
1 parent 253a209 commit 7eb41c2
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions cloudtrail/basic/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Create a bucket for cloudtrail logs

aws s3 mb s3://my-cloudtrail-ab-1212

# Create bucket policy to allow cloud trail to put to bucket

aws s3api put-bucket-policy --bucket my-cloudtrail-ab-1212 --policy file://bucket-policy.json

# Create Trail
aws cloudtrail create-trail \
--name MyTrail \
--s3-bucket-name my-cloudtrail-ab-1212 \
--region ca-central-1

# Start Logging

aws cloudtrail start-logging --name MyTrail
18 changes: 18 additions & 0 deletions cloudtrail/basic/bucket-policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AWSCloudTrailWrite20150319",
"Effect": "Allow",
"Principal": {"Service": "cloudtrail.amazonaws.com"},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::my-cloudtrail-ab-1212/AWSLogs/myAccountID/*",
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control",
"aws:SourceArn": "arn:aws:cloudtrail:ca-central-1:982383527471:trail/MyTrail"
}
}
}
]
}
9 changes: 9 additions & 0 deletions cloudtrail/cloudwatch/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Create CloudWatch Log and Stream

aws logs create-log-group --log-group-name mycloudtrail

# Update trail for CloudWatch Logs
aws cloudtrail update-trail \
--name MyTrail \
--cloud-watch-logs-log-group-arn arn:aws:logs:ca-central-1:982383527471:log-group:mycloudtrail:* \
--cloud-watch-logs-role-arn arn:aws:iam::982383527471:role/MyCloudTrail2CloudWatchRole
27 changes: 27 additions & 0 deletions cloudtrail/cloudwatch/cloud-watch-policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"Version": "2012-10-17",
"Statement": [
{

"Sid": "AWSCloudTrailCreateLogStream2014110",
"Effect": "Allow",
"Action": [
"logs:CreateLogStream"
],
"Resource": [
"arn:aws:logs:ca-central-1:982383527471:log-group:mycloudtrail:log-stream:*"
]

},
{
"Sid": "AWSCloudTrailPutLogEvents20141101",
"Effect": "Allow",
"Action": [
"logs:PutLogEvents"
],
"Resource": [
"arn:aws:logs:ca-central-1:982383527471:log-group:mycloudtrail:log-stream:*"
]
}
]
}

0 comments on commit 7eb41c2

Please sign in to comment.