This repository has been archived by the owner on Jun 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yml
110 lines (105 loc) · 3.77 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
- AWS::CodeStar
Parameters:
ProjectId:
Type: String
Description: AWS CodeStar project ID.
CodeDeployRole:
Type: String
Description: IAM role to allow AWS CodeDeploy to manage deployment of AWS Lambda functions
Stage:
Type: String
Description: The name for a project pipeline stage, such as Staging or Prod, for which resources are provisioned and deployed.
Default: 'Sandbox'
OpenDataAPIEndpoint:
Description: Open Data API endpoint (SSM Parameter name)
Type: AWS::SSM::Parameter::Value<String>
Default: 'OpenDataAPIEndpoint'
OpenDataAPITokenValidity:
Description: Open Data API token validity time (SSM Parameter name)
Type: AWS::SSM::Parameter::Value<String>
Default: 'OpenDataAPITokenValidity'
DynamoDBTableName:
Description: The name of the dynamo DB table used by the alexa skill for persistent storage of user data (SSM Parameter name)
Type: AWS::SSM::Parameter::Value<String>
Default: 'DynamoDBTableName'
MemcachedEndpoint:
Description: The SAAS solution (redislabs) memcached endpoint (SSM Parameter name)
Type: AWS::SSM::Parameter::Value<String>
Default: 'MemcachedEndpoint'
MemcachedUsername:
Description: The SAAS solution (redislabs) memcached username for for SASL Authentication (SSM Parameter name)
Type: AWS::SSM::Parameter::Value<String>
Default: 'MemcachedUsername'
MemcachedPassword:
Description: The SAAS solution (redislabs) memcached password for for SASL Authentication (SSM Parameter name)
Type: AWS::SSM::Parameter::Value<String>
Default: 'MemcachedPassword'
Globals:
Function:
MemorySize: 256
Timeout: 30
AutoPublishAlias: prod
DeploymentPreference:
Enabled: true
Type: AllAtOnce
Role: !Ref CodeDeployRole
Resources:
DailyCommuteFunction:
Type: AWS::Serverless::Function
Properties:
Tracing: Active
FunctionName: !Sub 'awscodestar-${ProjectId}-lambda-DailyCommuteFunction'
CodeUri: 'lambda/custom'
Environment:
Variables:
env: !Ref Stage
LOG_LEVEL: INFO
secret_name: !Sub 'OpenData${Stage}Secret'
open_data_api_endpoint: !Ref OpenDataAPIEndpoint
open_data_api_token_validity: !Ref OpenDataAPITokenValidity
dynamo_db_table_name: !Ref DynamoDBTableName
cache_endpoint: !Ref MemcachedEndpoint
cache_username: !Ref MemcachedUsername
cache_password: !Ref MemcachedPassword
POWERTOOLS_TRACE_DISABLED: false
POWERTOOLS_LOGGER_SAMPLE_RATE: 0.4
Handler: daily_commute.handler
Runtime: python3.8
Role: !GetAtt LambdaExecutionRole.Arn
Events:
AlexaSkillEvent:
Type: AlexaSkill
LambdaExecutionRole:
Description: Creating service role in IAM for AWS Lambda
Type: AWS::IAM::Role
Properties:
RoleName: !Sub '${ProjectId}-Execution'
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: [lambda.amazonaws.com]
Action: sts:AssumeRole
Path: /
ManagedPolicyArns:
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole'
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/AWSXrayWriteOnlyAccess'
- !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:policy/SystemsManagerGetParameters'
- !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:policy/AmazonDynamoDBAlexaSkillAccess'
Outputs:
overrides:
Value: !Sub |-
{
"manifest": {
"apis": {
"custom": {
"endpoint": {
"uri": "${DailyCommuteFunction.Alias}"
}
}
}
}
}