aws-classify-server 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/yml/apig.yml +7 -0
- package/yml/custom-cloudfront.yml +3 -0
- package/yml/custom-dynamodb.yml +9 -0
- package/yml/functions.yml +14 -0
- package/yml/provider-iam.yml +8 -0
- package/yml/resources-custom-website.yml +80 -0
- package/yml/resources-dynamodb.yml +15 -0
- package/yml/resources-website.yml +77 -0
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aws-classify-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"main": "./lib/cjs/index.js",
|
|
5
5
|
"module": "./lib/esm/index.js",
|
|
6
6
|
"types": "./lib/esm/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"/lib"
|
|
8
|
+
"/lib", "yml"
|
|
9
9
|
],
|
|
10
10
|
"description": "Typescript Interface to Lambda and Websockets",
|
|
11
11
|
"scripts": {
|
package/yml/apig.yml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
responseHandler:
|
|
2
|
+
handler: ${self:custom.directories.responseHandlers}.responseHandler
|
|
3
|
+
events:
|
|
4
|
+
- httpApi:
|
|
5
|
+
path: /api/dispatch
|
|
6
|
+
method: ANY
|
|
7
|
+
connectHandler:
|
|
8
|
+
handler: ${self:custom.directories.responseHandlers}.webSocketConnect
|
|
9
|
+
events:
|
|
10
|
+
- websocket: $connect
|
|
11
|
+
disconnectHandler:
|
|
12
|
+
handler: ${self:custom.directories.responseHandlers}.webSocketDisconnect
|
|
13
|
+
events:
|
|
14
|
+
- websocket: $disconnect
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
Resources:
|
|
2
|
+
CloudFrontOriginAccessIdentity:
|
|
3
|
+
Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
|
|
4
|
+
Properties:
|
|
5
|
+
CloudFrontOriginAccessIdentityConfig:
|
|
6
|
+
Comment: !Join [ "-", [ "access-identity", !GetAtt S3Bucket.DomainName ] ]
|
|
7
|
+
CloudFrontDistribution:
|
|
8
|
+
Type: AWS::CloudFront::Distribution
|
|
9
|
+
DependsOn:
|
|
10
|
+
- S3Bucket
|
|
11
|
+
Properties:
|
|
12
|
+
DistributionConfig:
|
|
13
|
+
PriceClass: PriceClass_All
|
|
14
|
+
ViewerCertificate:
|
|
15
|
+
AcmCertificateArn: ${self:custom.certificateARN}
|
|
16
|
+
MinimumProtocolVersion: TLSv1.1_2016
|
|
17
|
+
SslSupportMethod: sni-only
|
|
18
|
+
Aliases:
|
|
19
|
+
- ${self:custom.domainName}
|
|
20
|
+
Enabled: true
|
|
21
|
+
HttpVersion: http2
|
|
22
|
+
DefaultRootObject: index.html
|
|
23
|
+
Origins:
|
|
24
|
+
- Id: api
|
|
25
|
+
DomainName: !Join [ ".", [ !Ref HttpApi, "execute-api", !Ref AWS::Region, "amazonaws.com" ] ]
|
|
26
|
+
CustomOriginConfig:
|
|
27
|
+
OriginProtocolPolicy: https-only
|
|
28
|
+
- Id: static
|
|
29
|
+
DomainName: !GetAtt S3Bucket.RegionalDomainName
|
|
30
|
+
S3OriginConfig:
|
|
31
|
+
OriginAccessIdentity: !Join [ "", [ "origin-access-identity/cloudfront/", !Ref CloudFrontOriginAccessIdentity ] ]
|
|
32
|
+
CacheBehaviors:
|
|
33
|
+
- PathPattern: api/*
|
|
34
|
+
TargetOriginId: api
|
|
35
|
+
# recently deprecated style of setting ForwardedValues
|
|
36
|
+
# but currently there's no alternative if using CloudFormation
|
|
37
|
+
ForwardedValues:
|
|
38
|
+
QueryString: true
|
|
39
|
+
ViewerProtocolPolicy: redirect-to-https
|
|
40
|
+
AllowedMethods: [ GET, HEAD, OPTIONS, PATCH, POST, PUT, DELETE ]
|
|
41
|
+
# No caching by default but caching can be set with appropriate headers in the api responses
|
|
42
|
+
MinTTL: 0
|
|
43
|
+
DefaultTTL: 0
|
|
44
|
+
DefaultCacheBehavior:
|
|
45
|
+
TargetOriginId: static
|
|
46
|
+
# 'Managed-CachingOptimized'
|
|
47
|
+
# https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html
|
|
48
|
+
CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6
|
|
49
|
+
# 'Managed-CORS-S3Origin'
|
|
50
|
+
# https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-origin-request-policies.html
|
|
51
|
+
OriginRequestPolicyId: 88a5eaf4-2fd4-4709-b370-b4c650ea3fcf
|
|
52
|
+
ViewerProtocolPolicy: redirect-to-https
|
|
53
|
+
S3Bucket:
|
|
54
|
+
Type: AWS::S3::Bucket
|
|
55
|
+
Properties:
|
|
56
|
+
BucketName: ${self:custom.bucketName}
|
|
57
|
+
S3BucketPolicy:
|
|
58
|
+
Type: AWS::S3::BucketPolicy
|
|
59
|
+
Properties:
|
|
60
|
+
Bucket: !Ref S3Bucket
|
|
61
|
+
PolicyDocument:
|
|
62
|
+
Statement:
|
|
63
|
+
- Effect: Allow
|
|
64
|
+
Action: "s3:GetObject"
|
|
65
|
+
Resource: !Join [ "", [ !GetAtt S3Bucket.Arn, "/*" ] ]
|
|
66
|
+
Principal:
|
|
67
|
+
CanonicalUser: !GetAtt CloudFrontOriginAccessIdentity.S3CanonicalUserId
|
|
68
|
+
CustomDNSName:
|
|
69
|
+
Type: AWS::Route53::RecordSetGroup
|
|
70
|
+
Properties:
|
|
71
|
+
HostedZoneName: ${self:custom.hostedZoneName}
|
|
72
|
+
RecordSets:
|
|
73
|
+
- Name: ${self:custom.domainName}
|
|
74
|
+
Type: A
|
|
75
|
+
AliasTarget:
|
|
76
|
+
HostedZoneId: Z2FDTNDATAQYW2 #cloudfront hostedzone id
|
|
77
|
+
DNSName:
|
|
78
|
+
Fn::GetAtt:
|
|
79
|
+
- CloudFrontDistribution
|
|
80
|
+
- DomainName
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Resources:
|
|
2
|
+
AWSClassifySessionTable:
|
|
3
|
+
Type: AWS::DynamoDB::Table
|
|
4
|
+
Properties:
|
|
5
|
+
TableName: classifySessionStore
|
|
6
|
+
BillingMode: PAY_PER_REQUEST
|
|
7
|
+
AttributeDefinitions:
|
|
8
|
+
- AttributeName: sessionId
|
|
9
|
+
AttributeType: S
|
|
10
|
+
KeySchema:
|
|
11
|
+
- AttributeName: sessionId
|
|
12
|
+
KeyType: HASH
|
|
13
|
+
TimeToLiveSpecification:
|
|
14
|
+
AttributeName: expires
|
|
15
|
+
Enabled: true
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Resources:
|
|
2
|
+
CloudFrontOriginAccessIdentity:
|
|
3
|
+
Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
|
|
4
|
+
Properties:
|
|
5
|
+
CloudFrontOriginAccessIdentityConfig:
|
|
6
|
+
Comment: !Join ["-", ["access-identity", !GetAtt S3Bucket.DomainName]]
|
|
7
|
+
CloudFrontDistribution:
|
|
8
|
+
Type: AWS::CloudFront::Distribution
|
|
9
|
+
DependsOn:
|
|
10
|
+
- S3Bucket
|
|
11
|
+
Properties:
|
|
12
|
+
DistributionConfig:
|
|
13
|
+
PriceClass: PriceClass_All
|
|
14
|
+
ViewerCertificate:
|
|
15
|
+
CloudFrontDefaultCertificate: true
|
|
16
|
+
Enabled: true
|
|
17
|
+
HttpVersion: http2
|
|
18
|
+
DefaultRootObject: index.html
|
|
19
|
+
Origins:
|
|
20
|
+
- Id: api
|
|
21
|
+
DomainName: !Join [".", [!Ref HttpApi, "execute-api", !Ref AWS::Region, "amazonaws.com"]]
|
|
22
|
+
CustomOriginConfig:
|
|
23
|
+
OriginProtocolPolicy: https-only
|
|
24
|
+
- Id: static
|
|
25
|
+
DomainName: !GetAtt S3Bucket.RegionalDomainName
|
|
26
|
+
S3OriginConfig:
|
|
27
|
+
OriginAccessIdentity: !Join ["", ["origin-access-identity/cloudfront/", !Ref CloudFrontOriginAccessIdentity]]
|
|
28
|
+
CacheBehaviors:
|
|
29
|
+
- PathPattern: api/*
|
|
30
|
+
TargetOriginId: api
|
|
31
|
+
# recently deprecated style of setting ForwardedValues
|
|
32
|
+
# but currently there's no alternative if using CloudFormation
|
|
33
|
+
ForwardedValues:
|
|
34
|
+
QueryString: true
|
|
35
|
+
ViewerProtocolPolicy: redirect-to-https
|
|
36
|
+
AllowedMethods: [GET, HEAD, OPTIONS, PATCH, POST, PUT, DELETE]
|
|
37
|
+
# No caching by default but caching can be set with appropriate headers in the api responses
|
|
38
|
+
MinTTL: 0
|
|
39
|
+
DefaultTTL: 0
|
|
40
|
+
DefaultCacheBehavior:
|
|
41
|
+
TargetOriginId: static
|
|
42
|
+
# 'Managed-CachingOptimized'
|
|
43
|
+
# https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html
|
|
44
|
+
CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6
|
|
45
|
+
# 'Managed-CORS-S3Origin'
|
|
46
|
+
# https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-origin-request-policies.html
|
|
47
|
+
OriginRequestPolicyId: 88a5eaf4-2fd4-4709-b370-b4c650ea3fcf
|
|
48
|
+
ViewerProtocolPolicy: redirect-to-https
|
|
49
|
+
S3Bucket:
|
|
50
|
+
Type: AWS::S3::Bucket
|
|
51
|
+
Properties:
|
|
52
|
+
BucketName: ${self:custom.bucketName}
|
|
53
|
+
S3BucketPolicy:
|
|
54
|
+
Type: AWS::S3::BucketPolicy
|
|
55
|
+
Properties:
|
|
56
|
+
Bucket: !Ref S3Bucket
|
|
57
|
+
PolicyDocument:
|
|
58
|
+
Statement:
|
|
59
|
+
- Effect: Allow
|
|
60
|
+
Action: "s3:GetObject"
|
|
61
|
+
Resource: !Join ["", [!GetAtt S3Bucket.Arn, "/*"]]
|
|
62
|
+
Principal:
|
|
63
|
+
CanonicalUser: !GetAtt CloudFrontOriginAccessIdentity.S3CanonicalUserId
|
|
64
|
+
CustomDNSName:
|
|
65
|
+
Type: AWS::Route53::RecordSetGroup
|
|
66
|
+
Properties:
|
|
67
|
+
HostedZoneName: ${self:custom.hostedZoneName}
|
|
68
|
+
RecordSets:
|
|
69
|
+
- Name: ${self:custom.domainName}
|
|
70
|
+
Type: A
|
|
71
|
+
AliasTarget:
|
|
72
|
+
HostedZoneId: Z2FDTNDATAQYW2 #cloudfront hostedzone id
|
|
73
|
+
DNSName:
|
|
74
|
+
Fn::GetAtt:
|
|
75
|
+
- CloudFrontDistribution
|
|
76
|
+
- DomainName
|
|
77
|
+
|