This repository has been archived by the owner on May 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
skill-stack.yaml
107 lines (107 loc) · 3.26 KB
/
skill-stack.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
AWSTemplateFormatVersion: 2010-09-09
Parameters:
SkillId:
Type: String
LambdaRuntime:
Type: String
LambdaHandler:
Type: String
CodeBucket:
Type: String
CodeKey:
Type: String
CodeVersion:
Type: String
Resources:
AlexaSkillIAMRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: /
Policies:
- PolicyName: alexaSkillExecutionPolicy
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- logs:*
- S3:*
Resource: "*"
S3UserDataBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Delete
S3WebAppBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Delete
S3OriginAccessID:
Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
Properties:
CloudFrontOriginAccessIdentityConfig:
Comment: Origin Access Identity for S3.
CloudfrontDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
DefaultCacheBehavior:
AllowedMethods: [GET, HEAD]
CachedMethods: [GET, HEAD]
DefaultTTL: 3600 #This is deprecated. Recomendation is to use Cache Policy but not exposed in CFN
TargetOriginId: WebAppCloudfrontDistribution
ViewerProtocolPolicy: https-only
ForwardedValues:
QueryString: false
Enabled: true
Origins:
- DomainName: !GetAtt [S3WebAppBucket, DomainName]
S3OriginConfig :
OriginAccessIdentity: !Sub
- origin-access-identity/cloudfront/${originAccessParam}
- originAccessParam: !Ref S3OriginAccessID
Id: WebAppCloudfrontDistribution
AlexaSkillFunction:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket: !Ref CodeBucket
S3Key: !Ref CodeKey
S3ObjectVersion: !Ref CodeVersion
Handler: !Ref LambdaHandler
Runtime: !Ref LambdaRuntime
Role: !GetAtt AlexaSkillIAMRole.Arn
MemorySize: 512
Timeout: 60
Environment:
Variables:
Domain: !GetAtt [CloudfrontDistribution, DomainName]
S3_PERSISTENCE_BUCKET: {Ref: S3UserDataBucket}
AlexaSkillFunctionEventPermission:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:invokeFunction
FunctionName: !GetAtt AlexaSkillFunction.Arn
Principal: alexa-appkit.amazon.com
EventSourceToken: !Ref SkillId
AlexaSkillFunctionLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${AlexaSkillFunction}
RetentionInDays: 14
Outputs:
SkillEndpoint:
Description: LambdaARN for the regional endpoint
Value: !GetAtt AlexaSkillFunction.Arn
WebsiteURL:
Value: !GetAtt [S3WebAppBucket, WebsiteURL]
Description: URL for website hosted on S3
S3BucketSecureURL:
Value: !Join ['', ['https://', !GetAtt [S3WebAppBucket, DomainName]]]
Description: Name of S3 bucket to hold website content