Restructure project layout and add ECR repository CloudFormation template
- Move application entrypoint to cmd/lambda/ - Move Dockerfile to docker/ for clearer build context separation - Promote go.mod/go.sum to project root - Move CloudFormation templates under infra/cfn/ for consistent infra layout - Add new template-container-repository.yaml defining ECR repository (blog-deployment) - Move Lambda test files to test/ directory
This commit is contained in:
parent
aa1f4a91bf
commit
0b67765510
11 changed files with 21 additions and 0 deletions
79
infra/cfn/template-cloudfront.yaml
Normal file
79
infra/cfn/template-cloudfront.yaml
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
AWSTemplateFormatVersion: '2010-09-09'
|
||||
|
||||
Parameters:
|
||||
WebsiteBucketName:
|
||||
Type: String
|
||||
Description: "The name for the S3 bucket to be used for public website hosting (must be globally unique)"
|
||||
Default: "naputo-blog-public"
|
||||
|
||||
Resources:
|
||||
|
||||
AddIndexFunction:
|
||||
Type: AWS::CloudFront::Function
|
||||
Properties:
|
||||
Name: "AddIndexFunction"
|
||||
AutoPublish: true
|
||||
FunctionConfig:
|
||||
Comment: "Appends index.html for directory URIs"
|
||||
Runtime: cloudfront-js-1.0
|
||||
FunctionCode: |
|
||||
function handler(event) {
|
||||
var request = event.request;
|
||||
var uri = request.uri;
|
||||
if (uri.endsWith("/")) {
|
||||
request.uri += "index.html";
|
||||
} else if (uri === "") {
|
||||
request.uri = "/index.html";
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
BlogOriginAccessControl:
|
||||
Type: AWS::CloudFront::OriginAccessControl
|
||||
Properties:
|
||||
OriginAccessControlConfig:
|
||||
Name: "MyBlogOAC"
|
||||
OriginAccessControlOriginType: s3
|
||||
SigningBehavior: always
|
||||
SigningProtocol: sigv4
|
||||
|
||||
BlogCloudFrontDistribution:
|
||||
Type: AWS::CloudFront::Distribution
|
||||
Properties:
|
||||
DistributionConfig:
|
||||
Enabled: true
|
||||
DefaultRootObject: index.html
|
||||
Origins:
|
||||
- Id: S3WebsiteOrigin
|
||||
DomainName: !Sub "${WebsiteBucketName}.s3.amazonaws.com"
|
||||
OriginAccessControlId: !Ref BlogOriginAccessControl
|
||||
S3OriginConfig: {}
|
||||
DefaultCacheBehavior:
|
||||
TargetOriginId: S3WebsiteOrigin
|
||||
ViewerProtocolPolicy: redirect-to-https
|
||||
AllowedMethods:
|
||||
- GET
|
||||
- HEAD
|
||||
CachedMethods:
|
||||
- GET
|
||||
- HEAD
|
||||
ForwardedValues:
|
||||
QueryString: false
|
||||
Cookies:
|
||||
Forward: none
|
||||
FunctionAssociations:
|
||||
- EventType: viewer-request
|
||||
FunctionARN: !GetAtt AddIndexFunction.FunctionARN
|
||||
Aliases:
|
||||
- blog.n-daisuke897.com
|
||||
ViewerCertificate:
|
||||
AcmCertificateArn: !Sub "arn:aws:acm:us-east-1:${AWS::AccountId}:certificate/4d3e8182-71e0-4ccb-a437-36523f61a6c0"
|
||||
SslSupportMethod: sni-only
|
||||
MinimumProtocolVersion: TLSv1.2_2021
|
||||
PriceClass: PriceClass_200
|
||||
|
||||
Outputs:
|
||||
IdBlogCloudFrontDistribution:
|
||||
Value: !Ref BlogCloudFrontDistribution
|
||||
Export:
|
||||
Name: BlogCloudFrontDistribution-ID
|
||||
Loading…
Add table
Add a link
Reference in a new issue