Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nao1215 committed Feb 8, 2024
1 parent cdb986b commit 8cc7d06
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 37 deletions.
24 changes: 12 additions & 12 deletions cloudformation/lambda-batch/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,8 @@ Resources:
Principal:
Service: "lambda.amazonaws.com"
Action: "sts:AssumeRole"
Policies:
- PolicyName: "LambdaBatchPolicy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "logs:CreateLogGroup"
- "logs:CreateLogStream"
- "logs:PutLogEvents"
Resource: "*"
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"

LambdaLogGroup:
Type: "AWS::Logs::LogGroup"
Expand All @@ -62,4 +53,13 @@ Resources:
Properties:
LogGroupName: !Sub "/aws/lambda/${LambdaBatch}"
RetentionInDays: 7

KmsKeyId: !Ref LambdaLogGroupKMSKey

LambdaLogGroupKMSKey:
Type: AWS::KMS::Key
UpdateReplacePolicy: Retain
DeletionPolicy: Retain
Properties:
Description: "KMS key for encrypting CloudWatch Logs"
EnableKeyRotation: true

35 changes: 10 additions & 25 deletions cloudformation/static-web-site-distribution/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ Resources:
Bucket: !Ref ContentS3BucketReplica
Status: Enabled
Prefix: "replicated/"
LoggingConfiguration:
DestinationBucketName: !Ref ReplicationLogBucket
LogFilePrefix: "logs/"

ContentBucketPolicy:
Type: AWS::S3::BucketPolicy
Expand All @@ -57,6 +60,8 @@ Resources:
Condition:
Bool:
"aws:SecureTransport": false
NumericLessThan:
"s3:TlsVersion": "1.2"
Principal: "*"

ContentBucketReplicationRole:
Expand All @@ -74,31 +79,8 @@ Resources:
- s3.amazonaws.com
Action:
- sts:AssumeRole
Policies:
- PolicyName: "s3-replication-policy"
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:ListBucket
- s3:GetReplicationConfiguration
Resource:
- !Sub "arn:${AWS::Partition}:s3:::${ContentBucketName}"
- Effect: Allow
Action:
- s3:GetObjectVersionForReplication
- s3:GetObjectVersionAcl
- s3:GetObjectVersionTagging
Resource:
- !Sub "arn:${AWS::Partition}:s3:::${ContentBucketName}/*"
- Effect: Allow
Action:
- s3:ReplicateObject
- s3:ReplicateDelete
- s3:ReplicateTags
Resource:
- "arn:aws:s3:::content-s3-bucket-replica/*"
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/AmazonS3FullAccess"

ContentS3BucketReplica:
Type: "AWS::S3::Bucket"
Expand Down Expand Up @@ -131,6 +113,7 @@ Resources:
guard:
SuppressedRules:
- S3_BUCKET_REPLICATION_ENABLED
- S3_BUCKET_LOGGING_ENABLED


ContentBucketReplicaPolicy:
Expand All @@ -149,4 +132,6 @@ Resources:
Condition:
Bool:
"aws:SecureTransport": false
NumericLessThan:
"s3:TlsVersion": "1.2"
Principal: "*"

0 comments on commit 8cc7d06

Please sign in to comment.