-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yml
96 lines (86 loc) · 3.06 KB
/
template.yml
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
# This is the SAM template that represents the architecture of your serverless application
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-basics.html
# The AWSTemplateFormatVersion identifies the capabilities of the template
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/format-version-structure.html
AWSTemplateFormatVersion: 2010-09-09
Description: >-
postcode-lookup
# Transform section specifies one or more macros that AWS CloudFormation uses to process your template
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html
Transform:
- AWS::Serverless-2016-10-31
# Resources declares the AWS resources that you want to include in the stack
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html
Parameters:
Stage:
Type: String
Default: dev
WncOsApiKey:
Type: String
NncOsApiKey:
Type: String
Resources:
PostcodeCheckFunction:
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: src/getauthority/
Handler: index.lambdaHandler
Runtime: nodejs12.x
Events:
PostcodeCheck:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
RestApiId:
Ref: PostcodeCheckApiJSON
Path: /check-postcode/{postcode}
Method: get
Policies:
- AWSLambdaBasicExecutionRole
- AmazonDynamoDBReadOnlyAccess
Environment:
Variables:
WNC_OS_API_KEY: !Ref WncOsApiKey
NNC_OS_API_KEY: !Ref NncOsApiKey
PostcodeCheckApiJSON:
Type: AWS::Serverless::Api
Properties:
StageName:
Ref: Stage
Cors:
AllowMethods: "'GET'"
AllowOrigin: "'*'"
OpenApiVersion: '2.0'
# Auth:
# ApiKeyRequired: true
# ## generate apikey
# ApiKey:
# Type: AWS::ApiGateway::ApiKey
# Properties:
# Name: !Sub
# - '${Stage}-${StackName}-apikey'
# - Stage: !Ref Stage
# StackName: !Ref AWS::StackName
# Description: "Api key for run step function api"
# Enabled: true
# StageKeys:
# - RestApiId: !Ref PostcodeCheckApi
# StageName: !Ref Stage
# ApiUsagePlan:
# Type: "AWS::ApiGateway::UsagePlan"
# Properties:
# ApiStages:
# - ApiId: !Ref PostcodeCheckApi
# Stage: !Ref Stage
# Description: !Join [" ", [{"Ref": "AWS::StackName"}, "usage plan"]]
# Quota:
# Limit: 100
# Period: MONTH
# UsagePlanName: !Join ["", [{"Ref": "AWS::StackName"}, "-usage-plan"]]
# ApiUsagePlanKey:
# Type: "AWS::ApiGateway::UsagePlanKey"
# DependsOn:
# - PostcodeCheckApi
# Properties:
# KeyId: !Ref ApiKey
# KeyType: API_KEY
# UsagePlanId: !Ref ApiUsagePlan