-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
99 lines (88 loc) · 2.56 KB
/
serverless.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
service: reto-backend-csti
provider:
name: aws
runtime: nodejs18.x
region: sa-east-1
iam:
role:
managedPolicies:
- "arn:aws:iam::aws:policy/AmazonElastiCacheFullAccess"
- "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
environment:
##### PRODUCCION ####
# REDIS_PORT: !GetAtt MyElasticacheCluster.RedisEndpoint.Port
# REDIS_HOST: !GetAtt MyElasticacheCluster.RedisEndpoint.Address
#####################
##### LOCAL #########
REDIS_PORT: 6379
REDIS_HOST: localhost
#####################
REDIS_TTL: 900
functions:
generateToken:
handler: src/presentation/generateTokenHandler.generateTokenHandler
events:
- httpApi: POST /generateToken
vpc:
securityGroupIds:
- !GetAtt MyLambdaSecurityGroup.GroupId
subnetIds:
- !Ref MySubnet
retrieveCardData:
handler: src/presentation/retrieveCardDataHandler.retrieveCardDataHandler
events:
- httpApi: POST /retrieveCardData
vpc:
securityGroupIds:
- !GetAtt MyLambdaSecurityGroup.GroupId
subnetIds:
- !Ref MySubnet
resources:
Resources:
MyVPC:
Type: "AWS::EC2::VPC"
Properties:
CidrBlock: "10.0.0.0/16"
MySubnet:
Type: "AWS::EC2::Subnet"
Properties:
VpcId: !Ref MyVPC
CidrBlock: "10.0.1.0/24"
MyLambdaSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "CSTI - Lambda function security group"
VpcId: !Ref MyVPC
MyElasticacheSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "CSTI - ElastiCache security group"
VpcId: !Ref MyVPC
SecurityGroupIngress:
- IpProtocol: "tcp" # Specify TCP protocol
FromPort: "6379" # Port 6379
ToPort: "6379" # Port 6379
CidrIp: "10.0.1.0/24"
MyElasticacheSubnetGroup:
Type: "AWS::ElastiCache::SubnetGroup"
Properties:
Description: "CSTI - Subnet Group for ElastiCache"
SubnetIds:
- !Ref MySubnet
CacheSubnetGroupName: "MyElasticacheSubnetGroupNew"
MyElasticacheCluster:
Type: "AWS::ElastiCache::CacheCluster"
Properties:
CacheNodeType: "cache.t2.micro"
Engine: "redis"
NumCacheNodes: "1"
CacheSubnetGroupName: !Ref MyElasticacheSubnetGroup
VpcSecurityGroupIds:
- !GetAtt MyElasticacheSecurityGroup.GroupId
custom:
esbuild:
bundle: true
minify: true
plugins:
- serverless-esbuild
- serverless-offline