forked from SUSE-Enceladus/public-cloud-info-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
97 lines (90 loc) · 3.12 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
pint-server-ng
Public Cloud Info Service
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Parameters:
LambdaSg:
Description: "Lambda security group ID"
Type: AWS::EC2::SecurityGroup::Id
LambdaSubnets:
Description: "Lambda subnets"
Type: List<AWS::EC2::Subnet::Id>
DBResourceId:
Type: String
Description: "RDS-DB instance resource identifier"
DBEndpoint:
Type: String
Description: "Amazon RDS Postgres endpoint"
DBName:
Type: String
Description: "Name of the database connected"
Default: postgre
DBUsername:
Type: String
NoEcho: true
DBPassword:
Type: String
Description: "Database password: WARNING: for testing only!"
NoEcho: true
DBSSLMode:
Type: String
Description: "Indication whether to use TLS/SSL connection."
Default: ""
DBTrustedCertFile:
Type: String
Description: "Path to the trusted certificates file."
Default: ""
Resources:
PintServerNG:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
PackageType: Image
Events:
PintServerNG:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: '/{proxy+}'
Method: GET
VpcConfig:
SecurityGroupIds:
- !Ref LambdaSg
SubnetIds: !Ref LambdaSubnets
Policies:
-
Version: '2012-10-17'
Statement:
Effect: Allow
Action:
- rds-db:connect
Resource:
- !Sub "arn:aws:rds-db:${AWS::Region}:${AWS::AccountId}:dbuser:${DBResourceId}/${DBUsername}"
Environment:
Variables:
POSTGRES_HOST: !Ref DBEndpoint
POSTGRES_USER: !Ref DBUsername
POSTGRES_PASSWORD: !Ref DBPassword
POSTGRES_DB: !Ref DBName
POSTGRES_SSL_MODE: !Ref DBSSLMode
POSTGRES_SSL_ROOT_CERTIFICATE: !Ref DBTrustedCertFile
Metadata:
DockerTag: pintserver-v1
DockerContext: .staging
Dockerfile: Dockerfile
Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
PintAPI:
Description: "API Gateway endpoint URL for Prod stage for Pint API Server function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/v1/"
PintAPIFunction:
Description: "Pint API Server Lambda Function ARN"
Value: !GetAtt PintAPIFunction.Arn
PintAPIIamRole:
Description: "Implicit IAM Role created for Pint API Server function"
Value: !GetAtt PintAPIFunctionRole.Arn