forked from amazon-archives/aws-summit-hackathon-2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
89 lines (81 loc) · 2.66 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Starter template for Day One Space Tours hackathon
Parameters:
DbPassword:
Type: String
Default: password
NoEcho: true
Globals:
Api:
BinaryMediaTypes:
- '*~1*'
Resources:
HotelsService:
Type: AWS::Serverless::Function
Properties:
Handler: lambda.handler
Runtime: nodejs6.10
Timeout: 15 # in seconds
CodeUri: .
Policies:
# Add other AWS Managed policies as necessary
- AmazonDynamoDBReadOnlyAccess
Environment:
Variables:
CUSTOMER_TABLE_ARN: !GetAtt CustomerTable.Arn
HOTELDB_INSTANCE_ADDRESS: !GetAtt HotelDBInstance.Endpoint.Address
HOTELDB_INSTANCE_PORT: !GetAtt HotelDBInstance.Endpoint.Port
Events:
RootRoute:
Type: Api
Properties:
Path: /
Method: get
AllRoutes:
Type: Api
Properties:
Path: /{proxy+}
Method: any
CustomerTable:
# https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlesssimpletable
Type: AWS::Serverless::SimpleTable
Properties:
PrimaryKey:
Name: CustomerId
Type: Number
# Example for creating a Aurora RDS Instance running MySQL. This will only create the instance with the DB server,
# the Database and tables will have to be created using normanl MySQL commands after connecting to this instance.
# To connect to the RDS instance running MySQL using MySQL workbench please refer
# https://aws.amazon.com/premiumsupport/knowledge-center/connect-rds-mysql-workbench/
#
# You don't need both Aurora and DynamoDB tables.Choose the one that makes most sense for you
HotelDBInstance:
Type: AWS::RDS::DBInstance
Properties:
DBInstanceClass: db.t2.small
Engine: aurora
# EngineVersion: 5.6.39
DBClusterIdentifier: !Ref HotelDBCluster
HotelDBCluster:
Type: AWS::RDS::DBCluster
Properties:
MasterUsername: admin
MasterUserPassword: !Ref DbPassword
Engine: aurora
Outputs:
ApiBaseUrl:
Description: API Gateway endpoint URL for Prod environment
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
HotelDBInstanceAddress:
Description: Address to connect to the MySQL Hotel DB Instance
Value:
Fn::GetAtt:
- HotelDBInstance
- Endpoint.Address
HotelDBInstancePort:
Description: Port number to connect to the MySQL Hotel DB Instance
Value:
Fn::GetAtt:
- HotelDBInstance
- Endpoint.Port