diff --git a/cloudformation.yml b/cloudformation.yml index 874375d..08544f6 100644 --- a/cloudformation.yml +++ b/cloudformation.yml @@ -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 @@ -32,6 +57,9 @@ Resources: IgnorePublicAcls: True BlockPublicPolicy: False RestrictPublicBuckets: False + OwnershipControls: + Rules: + - ObjectOwnership: BucketOwnerEnforced BucketPolicy: Type: AWS::S3::BucketPolicy