Skip to content

Commit

Permalink
converted JSON templates to YAML templates
Browse files Browse the repository at this point in the history
  • Loading branch information
sergej-brazdeikis committed Mar 30, 2017
1 parent 8c3ba29 commit 83dc3ff
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 183 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -10,10 +10,10 @@ Building parts:

## How to

- Apply `route53-zone.template` for the domain.
- Apply `s3-static-website-with-cloudfront-and-route-53.template` for each subdomain need:
- Apply `route53-zone.yaml` for the domain.
- Apply `s3-static-website-with-cloudfront-and-route-53.yaml` for each subdomain need:
- www.jevsejev.io
- perfect-blog.jevsejev.io
- blog.jevsejev.io
- Upload your `index.html` to the S3 bucket

Your website is provisioned.
Expand Down
1 change: 1 addition & 0 deletions index.html
@@ -0,0 +1 @@
<h1>Hello world!</h1>
27 changes: 0 additions & 27 deletions route53-zone.template

This file was deleted.

18 changes: 18 additions & 0 deletions route53-zone.yaml
@@ -0,0 +1,18 @@
AWSTemplateFormatVersion: '2010-09-09'
Description: Creates an Amazon Route 53 hosted zone
Parameters:
DomainName:
Type: String
Description: The DNS name of an Amazon Route 53 hosted zone e.g. jevsejev.io
AllowedPattern: (?!-)[a-zA-Z0-9-.]{1,63}(?<!-)
ConstraintDescription: must be a valid DNS zone name.
Resources:
DNS:
Type: AWS::Route53::HostedZone
Properties:
HostedZoneConfig:
Comment: !Join ['', ['Hosted zone for ', !Ref 'DomainName']]
Name: !Ref 'DomainName'
HostedZoneTags:
- Key: Application
Value: Blog
153 changes: 0 additions & 153 deletions s3-static-website-with-cloudfront-and-route-53.template

This file was deleted.

114 changes: 114 additions & 0 deletions s3-static-website-with-cloudfront-and-route-53.yaml
@@ -0,0 +1,114 @@
AWSTemplateFormatVersion: '2010-09-09'
Description: Creates an S3 bucket configured for hosting a static website, and a Route
53 DNS record pointing to the bucket
Parameters:
DomainName:
Type: String
Description: The DNS name of an existing Amazon Route 53 hosted zone e.g. jevsejev.io
AllowedPattern: (?!-)[a-zA-Z0-9-.]{1,63}(?<!-)
ConstraintDescription: must be a valid DNS zone name.
FullDomainName:
Type: String
Description: The full domain name e.g. www.jevsejev.io
AllowedPattern: (?!-)[a-zA-Z0-9-.]{1,63}(?<!-)
ConstraintDescription: must be a valid DNS zone name.
Mappings:
RegionMap:
us-east-1:
S3HostedZoneId: Z3AQBSTGFYJSTF
S3WebsiteEndpoint: s3-website-us-east-1.amazonaws.com
us-west-1:
S3HostedZoneId: Z2F56UZL2M1ACD
S3WebsiteEndpoint: s3-website-us-west-1.amazonaws.com
us-west-2:
S3HostedZoneId: Z3BJ6K6RIION7M
S3WebsiteEndpoint: s3-website-us-west-2.amazonaws.com
eu-west-1:
S3HostedZoneId: Z1BKCTXD74EZPE
S3WebsiteEndpoint: s3-website-eu-west-1.amazonaws.com
ap-southeast-1:
S3HostedZoneId: Z3O0J2DXBE1FTB
S3WebsiteEndpoint: s3-website-ap-southeast-1.amazonaws.com
ap-southeast-2:
S3HostedZoneId: Z1WCIGYICN2BYD
S3WebsiteEndpoint: s3-website-ap-southeast-2.amazonaws.com
ap-northeast-1:
S3HostedZoneId: Z2M4EHUR26P7ZW
S3WebsiteEndpoint: s3-website-ap-northeast-1.amazonaws.com
sa-east-1:
S3HostedZoneId: Z31GFT0UA1I2HV
S3WebsiteEndpoint: s3-website-sa-east-1.amazonaws.com
Resources:
WebsiteBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref 'FullDomainName'
AccessControl: PublicRead
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: 404.html
DeletionPolicy: Retain
WebsiteBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref 'WebsiteBucket'
PolicyDocument:
Statement:
- Sid: PublicReadForGetBucketObjects
Effect: Allow
Principal: '*'
Action: s3:GetObject
Resource: !Join ['', ['arn:aws:s3:::', !Ref 'WebsiteBucket', /*]]
WebsiteCloudfront:
Type: AWS::CloudFront::Distribution
DependsOn:
- WebsiteBucket
Properties:
DistributionConfig:
Comment: Cloudfront Distribution pointing to S3 bucket
Origins:
- DomainName: !Join [., [!Ref 'FullDomainName', !FindInMap [RegionMap, !Ref 'AWS::Region',
S3WebsiteEndpoint]]]
Id: S3Origin
CustomOriginConfig:
HTTPPort: '80'
HTTPSPort: '443'
OriginProtocolPolicy: http-only
Enabled: 'true'
DefaultRootObject: index.html
Aliases:
- !Ref 'FullDomainName'
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
Compress: 'true'
TargetOriginId: S3Origin
ForwardedValues:
QueryString: 'true'
Cookies:
Forward: none
ViewerProtocolPolicy: allow-all
PriceClass: PriceClass_200
ViewerCertificate:
CloudFrontDefaultCertificate: 'true'
WebsiteDNSName:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneName: !Join ['', [!Ref 'DomainName', .]]
RecordSets:
- Name: !Ref 'FullDomainName'
Type: A
AliasTarget:
HostedZoneId: Z2FDTNDATAQYW2
DNSName: !GetAtt [WebsiteCloudfront, DomainName]
Outputs:
BucketName:
Value: !Ref 'WebsiteBucket'
Description: Name of S3 bucket to hold website content
CloudfrontEndpoint:
Value: !GetAtt [WebsiteCloudfront, DomainName]
Description: Endpoint for Cloudfront distribution
FullDomain:
Value: !Ref 'FullDomainName'
Description: Full DomainName

0 comments on commit 83dc3ff

Please sign in to comment.