-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplate.yml
104 lines (99 loc) · 3.1 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
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Metadata:
AWS::ServerlessRepo::Application:
Name: cmda
Description: A Lambda stack to perform commands and copy to/from EFS
Author: LambCI
SpdxLicenseId: MIT
LicenseUrl: LICENSE
ReadmeUrl: README-SAR.md
Labels: ['lambda', 'filesystem', 'efs']
HomePageUrl: https://github.com/lambci/cmda
SemanticVersion: 1.2.0
SourceCodeUrl: https://github.com/lambci/cmda/tree/v1.2.0
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: VPC Configuration (optional)
Parameters:
- VpcSubnetIds
- VpcSecurityGroupIds
- EfsAccessPointId
- EfsMountPath
ParameterLabels:
VpcSubnetIds:
default: Subnet IDs
VpcSecurityGroupIds:
default: Security Group ID(s)
EfsAccessPointId:
default: EFS Access Point ID
EfsMountPath:
default: EFS Local Mount Path
Parameters:
VpcSubnetIds:
Type: String
Description: VPC Subnet IDs (typically you only want private subnets)
Default: ''
VpcSecurityGroupIds:
Type: String
Description: VPC Security Group ID(s) (typically you only want one)
Default: ''
EfsAccessPointId:
Type: String
Description: EFS Access Point ID (eg fsap-1234abcd - see "Manage client access" in the EFS web console)
AllowedPattern: '^$|^fsap-[0-9a-f]+$'
ConstraintDescription: Must start with fsap-
Default: ''
EfsMountPath:
Type: String
Description: Local mount path to use for the EFS filesystem (eg /mnt/efs)
AllowedPattern: '^$|^/mnt/.+$'
ConstraintDescription: Must start with /mnt/
Default: ''
Conditions:
AddVpcConfig: !And
- !Not [!Equals ['', !Ref VpcSubnetIds]]
- !Not [!Equals ['', !Ref VpcSecurityGroupIds]]
AddEfsConfig: !And
- !Not [!Equals ['', !Ref VpcSubnetIds]]
- !Not [!Equals ['', !Ref VpcSecurityGroupIds]]
- !Not [!Equals ['', !Ref EfsAccessPointId]]
- !Not [!Equals ['', !Ref EfsMountPath]]
Resources:
CmdaFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs12.x
CodeUri: lambda/dist
Handler: index.handler
MemorySize: 3008
Timeout: 900
Policies:
- S3CrudPolicy:
BucketName: !Ref CmdaBucket
Environment:
Variables:
CMDA_BUCKET: !Ref CmdaBucket
VPC_SUBNETS: !Ref VpcSubnetIds
VpcConfig: !If
- AddVpcConfig
- SubnetIds: !Split [',', !Ref VpcSubnetIds]
SecurityGroupIds: !Split [',', !Ref VpcSecurityGroupIds]
- !Ref AWS::NoValue
FileSystemConfigs: !If
- AddEfsConfig
- - Arn: !Sub 'arn:${AWS::Partition}:elasticfilesystem:${AWS::Region}:${AWS::AccountId}:access-point/${EfsAccessPointId}'
LocalMountPath: !Ref EfsMountPath
- !Ref AWS::NoValue
CmdaBucket:
Type: AWS::S3::Bucket
Properties:
LifecycleConfiguration:
Rules:
- ExpirationInDays: 1
Status: Enabled
Outputs:
FunctionName:
Description: The name of the cmda Lambda function
Value: !Ref CmdaFunction