This repository has been archived by the owner on Jun 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
129 lines (122 loc) · 4.1 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
AWS
Sample SAM Template for AWS
Metadata:
AWS::ServerlessRepo::Application:
Name: DoiProxy
Description: Proxy DOI data requests to Datacite.
Author: Unit
SpdxLicenseId: MIT
LicenseUrl: LICENSE
Labels: ['${CODEBUILD_RESOLVED_SOURCE_VERSION}', '${GIT_REPO}', '@${BUILD_TIMESTAMP}']
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 20
Api:
Cors:
AllowMethods: "'POST,OPTIONS'"
AllowHeaders: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
AllowOrigin: "'*'"
Parameters:
CognitoAuthorizerArn:
Type: String
Description: Reference to Cognito UserPool for the stage
Default: '{{resolve:ssm:CognitoAuthorizerArn:2}}'
CustomDomain:
Type: String
Description: Custom API to connect this lambda to
CustomDomainBasePath:
Type: String
Description: Base path mapping in CustomDomain
Resources:
NvaDoiFunctionApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
EndpointConfiguration: REGIONAL
DefinitionBody:
openapi: 3.0.0
info:
title: NVA DOI proxy
version: '1.0'
paths:
/:
post:
summary: Request data for DOI URL
security:
- CognitoUserPool: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DoiLookup'
example:
doi: 'https://doi.org/10.1109/5.771073'
x-amazon-apigateway-integration:
uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NvaDoiFunction.Arn}/invocations
responses: {}
httpMethod: POST
type: AWS_PROXY
passthroughBehavior: WHEN_NO_MATCH
responses:
'200':
content:
application/vnd.citationstyles.csl+json:
schema:
type: object
application/vnd.datacite.datacite+json:
schema:
type: object
application/vnd.datacite.datacite+xml:
schema:
type: object
components:
securitySchemes:
CognitoUserPool:
type: apiKey
name: Authorization
in: header
x-amazon-apigateway-authtype: cognito_user_pools
x-amazon-apigateway-authorizer:
type: cognito_user_pools
providerARNs:
- !Ref CognitoAuthorizerArn
schemas:
DoiLookup:
title: Lookup DOI URL
type: object
properties:
doi:
type: string
description: DOI URL
required:
- doi
NvaDoiFunction:
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:
CodeUri: .
Handler: no.unit.nva.doi.FetchDoiMetadata::handleRequest
Runtime: java11
MemorySize: 512
Environment:
Variables:
AllowOrigin: '*'
Events:
NvaDoi:
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: /
Method: post
RestApiId: !Ref NvaDoiFunctionApi
NvaDoiFunctionBasePathMapping:
Type: AWS::ApiGateway::BasePathMapping
Properties:
BasePath: !Ref CustomDomainBasePath
DomainName: !Ref CustomDomain
RestApiId: !Ref NvaDoiFunctionApi
Stage: !Ref NvaDoiFunctionApi.Stage