Skip to content

Commit

Permalink
add log bucket policy
Browse files Browse the repository at this point in the history
  • Loading branch information
jtherrmann committed Jul 2, 2024
1 parent bfbfcc2 commit 6b09c32
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion cloudformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,37 @@ Resources:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub "${AWS::StackName}-logs"
AccessControl: LogDeliveryWrite
PublicAccessBlockConfiguration:
BlockPublicAcls: True
IgnorePublicAcls: True
BlockPublicPolicy: True
RestrictPublicBuckets: True
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
BucketKeyEnabled: true
OwnershipControls:
Rules:
- ObjectOwnership: BucketOwnerEnforced

LogBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref LogBucket
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: logging.s3.amazonaws.com
Action: s3:PutObject
Resource: !Sub "${LogBucket.Arn}/*"
Condition:
ArnLike:
"aws:SourceArn": !GetAtt ContentBucket.Arn
StringEquals:
"aws:SourceAccount": !Ref AWS::AccountId

ContentBucket:
Type: AWS::S3::Bucket
Expand All @@ -32,6 +57,9 @@ Resources:
IgnorePublicAcls: True
BlockPublicPolicy: False
RestrictPublicBuckets: False
OwnershipControls:
Rules:
- ObjectOwnership: BucketOwnerEnforced

BucketPolicy:
Type: AWS::S3::BucketPolicy
Expand Down

0 comments on commit 6b09c32

Please sign in to comment.