정적 페이지를 만들기 위한 CloudFormation 템플릿(사용자 지정 도메인 없음)
11390 단어 CloudFormationAWS
맞춤 도메인은 설정하지 않으므로
xxxxx.cloudfront.net
와 같은 URL 액세스만 가능합니다.프로덕션 이용은 상정하고 있지 않기 때문에 일시적으로 동작 확인하고 싶을 때라든지 사용하기 위한 것입니다.
S3의 버킷 정책은 CloudFront를 통한 액세스를 허용하기 위한 설정입니다.
S3 버킷 이름과 CloudFront TTL은 필요에 따라 변경하고 싶기 때문에 매개 변수화합니다.
AWS::WAF::IPSet
에 관해서는 허가하고 싶은 IP가 매번 다르기 때문에 베타 쓰기.주의점
이 사이트에 쓰여졌지만 제작 후 기장에 1 시간 정도 기다려야하는 데스
템플릿
AWSTemplateFormatVersion: 2010-09-09
Description: Web Site Hosting Stack
Parameters:
BucketName:
Type: String
CloudFrontTTL:
Type: Number
Default: 0
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
AccessControl: Private
BucketName: !Ref BucketName
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: error.html
S3BucketPolicy:
Type: AWS::S3::BucketPolicy
DependsOn:
- S3Bucket
- CloudFrontOriginAccessIdentity
Properties:
Bucket: !Ref S3Bucket
PolicyDocument:
Version: 2008-10-17
Statement:
- Action:
- s3:GetObject
Effect: Allow
Resource: !Join ["/", [!GetAtt S3Bucket.Arn, "*"]]
Principal:
AWS: !Sub "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ${CloudFrontOriginAccessIdentity}"
CloudFrontOriginAccessIdentity:
Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
Properties:
CloudFrontOriginAccessIdentityConfig:
Comment: !Sub "${BucketName} access identity"
CloudFrontDistribution:
Type: AWS::CloudFront::Distribution
DependsOn:
- S3Bucket
- CloudFrontOriginAccessIdentity
- WebACL
Properties:
DistributionConfig:
Enabled: true
DefaultCacheBehavior:
AllowedMethods:
- HEAD
- GET
CachedMethods:
- HEAD
- GET
DefaultTTL: !Ref CloudFrontTTL
MaxTTL: !Ref CloudFrontTTL
MinTTL: !Ref CloudFrontTTL
TargetOriginId: !Sub "${BucketName}-Origin"
ViewerProtocolPolicy: redirect-to-https
ForwardedValues:
QueryString: false
IPV6Enabled: true
HttpVersion: http2
DefaultRootObject: index.html
WebACLId: !Ref WebACL
Origins:
- Id: !Sub "${BucketName}-Origin"
DomainName: !Sub "${BucketName}.s3.amazonaws.com"
S3OriginConfig:
OriginAccessIdentity: !Sub "origin-access-identity/cloudfront/${CloudFrontOriginAccessIdentity}"
WebACL:
Type: AWS::WAF::WebACL
DependsOn:
- IPSetRule
Properties:
DefaultAction:
Type: BLOCK
MetricName: WebACLMetric
Name: !Sub "${BucketName} WebACL"
Rules:
- Action:
Type: ALLOW
Priority: 0
RuleId: !Ref IPSetRule
IPSetRule:
Type: AWS::WAF::Rule
Properties:
Name: !Sub "${BucketName} IPSetRule"
MetricName: IPSetRuleMetric
Predicates:
- DataId: !Ref IPSet
Negated: false
Type: IPMatch
IPSet:
Type: AWS::WAF::IPSet
Properties:
IPSetDescriptors:
- Type: IPV4
# ここは書き換える
Value: aaa.bbb.ccc.ddd/32
Name: !Sub "${BucketName} IPSet"
Reference
이 문제에 관하여(정적 페이지를 만들기 위한 CloudFormation 템플릿(사용자 지정 도메인 없음)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/masakurapa/items/6b55ecdd9f241de4cc46텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)