-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.yaml
109 lines (109 loc) · 3.62 KB
/
template.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: Stackery Serverless API Example Stack
Resources:
TriggerDeployFrontEndOnDeploy:
Type: Custom::TriggerDeployFrontEndOnDeploy
Properties:
ServiceToken: !GetAtt deployFrontEnd.Arn
Trigger: !Ref StackeryDeploymentTimestamp
deployFrontEnd:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${AWS::StackName}-deployFrontEnd
Description: !Sub
- Stackery Stack ${StackeryStackTagName} Environment ${StackeryEnvironmentTagName} Function ${ResourceName}
- ResourceName: deployFrontEnd
CodeUri: src/deployFrontEnd
Handler: index.handler
Runtime: nodejs12.x
MemorySize: 3008
Timeout: 300
Tracing: Active
Policies:
- AWSXrayWriteOnlyAccess
- S3CrudPolicy:
BucketName: !Ref websiteHosting
- Statement:
- Effect: Allow
Action:
- s3:PutObjectAcl
Resource:
- !Sub ${websiteHosting.Arn}/*
Environment:
Variables:
XDG_CONFIG_HOME: /tmp/.config
BUCKET_NAME: !Ref websiteHosting
BUCKET_ARN: !GetAtt websiteHosting.Arn
Metadata:
StackeryName: deployFrontEnd
deployFrontEndDeployTrigger:
Type: Custom::FunctionDeployTrigger
Properties:
ServiceToken: !GetAtt deployFrontEnd.Arn
websiteHosting:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub ${AWS::StackName}-websitehosting
AccessControl: PublicRead
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: index.html
Metadata:
StackeryName: S3 Website Hosting
api:
Type: AWS::Serverless::Api
Properties:
Name: !Sub
- ${ResourceName} From Stackery Stack ${StackeryStackTagName} Environment ${StackeryEnvironmentTagName}
- ResourceName: api
StageName: !Ref StackeryEnvironmentAPIGatewayStageName
DefinitionBody:
swagger: '2.0'
info: {}
paths:
/:
get:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${getWelcomePage.Arn}/invocations
responses: {}
EndpointConfiguration: REGIONAL
getWelcomePage:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${AWS::StackName}-getWelcomePage
Description: !Sub
- Stackery Stack ${StackeryStackTagName} Environment ${StackeryEnvironmentTagName} Function ${ResourceName}
- ResourceName: getWelcomePage
CodeUri: src/getWelcomePage
Handler: index.handler
Runtime: nodejs12.x
MemorySize: 3008
Timeout: 30
Tracing: Active
Policies:
- AWSXrayWriteOnlyAccess
Events:
apiGET:
Type: Api
Properties:
Path: /
Method: GET
RestApiId: !Ref api
Metadata:
StackeryName: getWelcomePage
Parameters:
StackeryStackTagName:
Type: String
Description: Stack Name (injected by Stackery at deployment time)
StackeryEnvironmentTagName:
Type: String
Description: Environment Name (injected by Stackery at deployment time)
StackeryEnvironmentAPIGatewayStageName:
Type: String
Description: Environment name used for API Gateway Stage names (injected by Stackery at deployment time)
StackeryDeploymentTimestamp:
Type: Number
Description: Deployment preparation timestamp in milliseconds Since Epoch (injected by Stackery at deployment time)