Skip to content

Commit

Permalink
Merge pull request #52 from rrigato/dev
Browse files Browse the repository at this point in the history
s3 bucket for cloudfront logging
  • Loading branch information
rrigato authored May 18, 2024
2 parents 97e3d17 + 5f3a315 commit e43881a
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions templates/prod_resource_import.yml → templates/prod_homepage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Parameters:
Default: Z2FDTNDATAQYW2
Description: Route 53 Hosted Zone id

ProjectName:
Type: String
Default: homepage




Expand All @@ -28,6 +32,15 @@ Conditions:
!Equals [ !Ref BucketName, ryanrigato.com ]

Resources:
ApplicationLogBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub '${ProjectName}-logging'
OwnershipControls:
Rules:
- ObjectOwnership: BucketOwnerPreferred


WebsiteBucket:
Condition: RetainResourcesCreated
Properties:
Expand All @@ -43,7 +56,7 @@ Resources:
Tags:
-
Key: accessType
Value: bucketPolicyWithOAI
Value: bucketPolicyWithOAI
-
Key: use
Value: website
Expand All @@ -69,7 +82,7 @@ Resources:
Action: s3:GetObject
# ensuring that the static s3 bucket can only be accessed
# through cloudfront
Principal:
Principal:
CanonicalUser:
!GetAtt CloudFrontOai.S3CanonicalUserId
Resource: !Sub "arn:aws:s3:::${BucketName}/*"
Expand Down Expand Up @@ -117,7 +130,6 @@ Resources:
###########################
#Content delivery network
#for the static (html/css/js) content
#
##########################
StaticWebpageCdn:
DependsOn: CloudFrontOai
Expand All @@ -137,6 +149,10 @@ Resources:
- - 'www'
- !Ref BucketName
Enabled: true
Logging:
Bucket: !GetAtt ApplicationLogBucket.DomainName
IncludeCookies: false
Prefix: cdnlogs/
DefaultCacheBehavior:
ForwardedValues:
QueryString: true
Expand Down Expand Up @@ -185,7 +201,7 @@ Resources:
Outputs:
OaiS3CanonicalUserId:
Description: |
Canonical ID which can be used to restrict s3 bucket access to go
Canonical ID which can be used to restrict s3 bucket access to go
through cloudfront
Value: !GetAtt CloudFrontOai.S3CanonicalUserId

0 comments on commit e43881a

Please sign in to comment.