@@ -10,13 +10,21 @@ Globals:
10
10
Timeout : 3
11
11
12
12
Resources :
13
+ # #########################################################################
14
+ # API Gateway with stage name #
15
+ # #########################################################################
16
+ HttpApi :
17
+ Type : AWS::Serverless::HttpApi
18
+ Properties :
19
+ StageName : dev
20
+
13
21
# #########################################################################
14
22
# S3 Bucket to store static assets #
15
23
# #########################################################################
16
24
Assets :
17
25
Type : AWS::S3::Bucket
18
26
Properties :
19
- BucketName : php-example-assets-for-php-app-example-3
27
+ BucketName : !Sub 'cf-origin-${AWS::AccountId}-${AWS::StackName}'
20
28
# The policy that makes the bucket publicly readable
21
29
AssetsBucketPolicy :
22
30
Type : AWS::S3::BucketPolicy
@@ -52,16 +60,18 @@ Resources:
52
60
Timeout : 30
53
61
Tracing : Active
54
62
Layers :
55
- - ' arn:aws:lambda:us-east-1: 209497400698:layer:php-73 -fpm:25 '
63
+ - !Sub ' arn:aws:lambda:${AWS::Region}: 209497400698:layer:php-81 -fpm:19 '
56
64
Events :
57
65
DynamicRequestsRoot :
58
66
Type : HttpApi
59
67
Properties :
68
+ ApiId : !Ref HttpApi
60
69
Path : /
61
70
Method : ANY
62
71
DynamicRequestsProxy :
63
72
Type : HttpApi
64
73
Properties :
74
+ ApiId : !Ref HttpApi
65
75
Path : /{proxy+}
66
76
Method : ANY
67
77
# #########################################################################
@@ -74,15 +84,16 @@ Resources:
74
84
Enabled : true
75
85
Origins :
76
86
- Id : Website
77
- DomainName : !Join ['.', [!Ref ServerlessHttpApi, ' execute-api', !Ref AWS::Region, 'amazonaws.com']]
87
+ DomainName : !Sub '${HttpApi}. execute-api.${ AWS::Region}.${AWS::URLSuffix}'
78
88
# This is the stage
79
89
OriginPath : " /dev"
80
90
CustomOriginConfig :
81
91
OriginProtocolPolicy : ' https-only' # API Gateway only supports HTTPS
82
92
# The assets (S3)
83
93
- Id : Assets
84
94
DomainName : !GetAtt Assets.RegionalDomainName
85
- S3OriginConfig : {} # this key is required to tell CloudFront that this is an S3 origin, even though nothing is configured
95
+ S3OriginConfig :
96
+ OriginAccessIdentity : !Sub 'origin-access-identity/cloudfront/${S3OriginIdentityExample}'
86
97
# The default behavior is to send everything to AWS Lambda
87
98
DefaultCacheBehavior :
88
99
AllowedMethods : [GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE]
0 commit comments