Created
June 16, 2020 06:46
-
-
Save StanGenchev/957a38599c73495aa0ce0a5a3407071f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: 2010-09-09 | |
Transform: | |
- AWS::Serverless-2016-10-31 | |
Parameters: | |
RootDomainName: | |
Description: Domain name for your website | |
Type: String | |
Mappings: | |
RegionMap: | |
us-east-1: | |
S3hostedzoneID: Z3AQBSTGFYJSTF | |
websiteendpoint: s3-website-us-east-1.amazonaws.com | |
us-west-1: | |
S3hostedzoneID: Z2F56UZL2M1ACD | |
websiteendpoint: s3-website-us-west-1.amazonaws.com | |
us-west-2: | |
S3hostedzoneID: Z3BJ6K6RIION7M | |
websiteendpoint: s3-website-us-west-2.amazonaws.com | |
eu-west-1: | |
S3hostedzoneID: Z1BKCTXD74EZPE | |
websiteendpoint: s3-website-eu-west-1.amazonaws.com | |
ap-southeast-1: | |
S3hostedzoneID: Z3O0J2DXBE1FTB | |
websiteendpoint: s3-website-ap-southeast-1.amazonaws.com | |
ap-southeast-2: | |
S3hostedzoneID: Z1WCIGYICN2BYD | |
websiteendpoint: s3-website-ap-southeast-2.amazonaws.com | |
ap-northeast-1: | |
S3hostedzoneID: Z2M4EHUR26P7ZW | |
websiteendpoint: s3-website-ap-northeast-1.amazonaws.com | |
sa-east-1: | |
S3hostedzoneID: Z31GFT0UA1I2HV | |
websiteendpoint: s3-website-sa-east-1.amazonaws.com | |
Resources: | |
RootBucket: | |
Type: AWS::S3::Bucket | |
Properties: | |
BucketName: !Sub "admin.${RootDomainName}" | |
AccessControl: PublicRead | |
WebsiteConfiguration: | |
IndexDocument: index.html | |
ErrorDocument: index.html | |
RootBucketPolicy: | |
Type: AWS::S3::BucketPolicy | |
DependsOn: | |
- RootBucket | |
Properties: | |
Bucket: !Ref RootBucket | |
PolicyDocument: | |
Id: "RootBucket-Policy" | |
Version: 2012-10-17 | |
Statement: | |
- Sid: PublicReadForGetBucketObjects | |
Effect: Allow | |
Principal: "*" | |
Action: "s3:GetObject" | |
Resource: | |
!Join [ | |
"", | |
[!Sub "arn:${AWS::Partition}:s3:::", !Ref RootBucket, "/*"], | |
] | |
DNSAdminRecord: | |
Type: AWS::Route53::RecordSet | |
Properties: | |
HostedZoneName: !Sub "${RootDomainName}." | |
Name: !Sub "admin.${RootDomainName}." | |
Type: A | |
AliasTarget: | |
HostedZoneId: !FindInMap [RegionMap, !Ref "AWS::Region", S3hostedzoneID] | |
DNSName: !FindInMap [RegionMap, !Ref "AWS::Region", websiteendpoint] | |
Outputs: | |
WebsiteURL: | |
Value: !GetAtt RootBucket.WebsiteURL | |
Description: URL for website hosted on S3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment