-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3-webhosting.yaml
54 lines (51 loc) · 1.5 KB
/
s3-webhosting.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
AWSTemplateFormatVersion: 2010-09-09
Description: The CloudFormation template that creates a public open S3 bucket.
# ------------------------------------------------------------#
# Input Parameters
# ------------------------------------------------------------#
Parameters:
BucketName:
Type: String
Description: S3 Bucket name.
Default: koseizakio-public-bucket
MaxLength: 50
MinLength: 3
Resources:
# ------------------------------------------------------------#
# S3
# ------------------------------------------------------------#
S3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref BucketName
PublicAccessBlockConfiguration:
BlockPublicAcls: false
BlockPublicPolicy: false
IgnorePublicAcls: false
RestrictPublicBuckets: false
Tags:
- Key: Cost
Value: !Ref BucketName
S3BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref S3Bucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Action:
- "s3:GetObject"
Effect: Allow
Resource: !Sub "arn:aws:s3:::${S3Bucket}/*"
Principal: "*"
DependsOn:
- S3Bucket
# ------------------------------------------------------------#
# Output Parameters
# ------------------------------------------------------------#
Outputs:
#S3
S3BucketName:
Value: !Ref S3Bucket
TopPageURL:
Value: !Sub https://s3.${AWS::Region}.amazonaws.com/${S3Bucket}/index.html