@ez4/aws-function 0.41.0 → 0.42.0
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/README.md +11 -0
- package/dist/function/client.d.ts +2 -0
- package/dist/function/errors.d.ts +3 -0
- package/dist/function/utils.d.ts +4 -0
- package/dist/main.cjs +169 -161
- package/dist/main.mjs +159 -150
- package/dist/mapping/helpers/state.d.ts +2 -0
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -35,6 +35,17 @@ Ensure the user performing deployments has the permissions below:
|
|
|
35
35
|
"lambda:UntagResource"
|
|
36
36
|
],
|
|
37
37
|
"Resource": ["arn:aws:lambda:*:{account-id}:function:{prefix}-*"]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"Sid": "AuthorizeLambdaServices",
|
|
41
|
+
"Effect": "Allow",
|
|
42
|
+
"Action": ["iam:PassRole"],
|
|
43
|
+
"Resource": ["arn:aws:iam::{account-id}:role/{prefix}-*"],
|
|
44
|
+
"Condition": {
|
|
45
|
+
"StringLike": {
|
|
46
|
+
"iam:PassedToService": ["lambda.amazonaws.com"]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
38
49
|
}
|
|
39
50
|
]
|
|
40
51
|
}
|
|
@@ -15,6 +15,7 @@ export type CreateRequest = {
|
|
|
15
15
|
memory?: number;
|
|
16
16
|
publish?: boolean;
|
|
17
17
|
debug?: boolean;
|
|
18
|
+
vpc?: boolean;
|
|
18
19
|
tags?: ResourceTags;
|
|
19
20
|
};
|
|
20
21
|
export type ImportOrCreateResponse = {
|
|
@@ -31,6 +32,7 @@ export type UpdateConfigurationRequest = {
|
|
|
31
32
|
timeout?: number;
|
|
32
33
|
memory?: number;
|
|
33
34
|
debug?: boolean;
|
|
35
|
+
vpc?: boolean;
|
|
34
36
|
};
|
|
35
37
|
export type UpdateSourceCodeRequest = {
|
|
36
38
|
architecture?: ArchitectureType;
|
package/dist/function/utils.d.ts
CHANGED
|
@@ -7,3 +7,7 @@ export declare const getFunctionState: (context: EventContext, functionName: str
|
|
|
7
7
|
export declare const getFunctionName: (serviceName: string, resourceId: string, context: StepContext) => string;
|
|
8
8
|
export declare const tryGetFunctionArn: (context: StepContext) => `arn:aws:${string}:${string}:${string}:${string}` | undefined;
|
|
9
9
|
export declare const getFunctionArn: (serviceName: string, resourceId: string, context: StepContext) => `arn:aws:${string}:${string}:${string}:${string}`;
|
|
10
|
+
export declare const getDefaultVpcConfig: () => Promise<{
|
|
11
|
+
subnetIds: string[];
|
|
12
|
+
securityGroupId: string;
|
|
13
|
+
}>;
|
package/dist/main.cjs
CHANGED
|
@@ -1,180 +1,188 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
typeof e=="object"||typeof e=="function")for(let i of
|
|
3
|
-
|
|
4
|
-
enumerable:!0}):n,t)),
|
|
5
|
-
FunctionServiceName:()=>
|
|
6
|
-
MappingServiceType:()=>
|
|
7
|
-
buildFunctionArn:()=>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports=
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
z=o(t=>
|
|
16
|
-
t=>
|
|
17
|
-
e))throw new
|
|
18
|
-
assertVariables"),A=o(t=>{let e={};for(let n in t)e[n]=(0,
|
|
19
|
-
"protectVariables");var
|
|
20
|
-
e,r),n.toBufferPromise()},"getZipBuffer");var
|
|
1
|
+
"use strict";var ut=Object.create;var T=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,dt=Object.prototype.hasOwnProperty;var o=(t,e)=>T(t,"name",{value:e,configurable:!0});var ft=(t,e)=>{for(var n in e)T(t,n,{get:e[n],enumerable:!0})},me=(t,e,n,r)=>{if(e&&
|
|
2
|
+
typeof e=="object"||typeof e=="function")for(let i of lt(e))!dt.call(t,i)&&i!==n&&
|
|
3
|
+
T(t,i,{get:()=>e[i],enumerable:!(r=mt(e,i))||r.enumerable});return t};var yt=(t,e,n)=>(n=t!=null?ut(gt(t)):{},me(e||!t||!t.__esModule?T(n,"default",{value:t,
|
|
4
|
+
enumerable:!0}):n,t)),St=t=>me(T({},"__esModule",{value:!0}),t);var Xt={};ft(Xt,{FunctionArchitecture:()=>de,FunctionDefaults:()=>pt,FunctionRuntime:()=>ge,
|
|
5
|
+
FunctionServiceName:()=>w,FunctionServiceType:()=>x,MappingService:()=>Ge,MappingServiceName:()=>v,
|
|
6
|
+
MappingServiceType:()=>R,PermissionServiceName:()=>E,PermissionServiceType:()=>b,
|
|
7
|
+
buildFunctionArn:()=>Kt,createFunction:()=>jt,createMapping:()=>_t,createPermission:()=>Zt,
|
|
8
|
+
getDefaultVpcConfig:()=>q,getFunctionArchitecture:()=>D,getFunctionArn:()=>ht,getFunctionName:()=>N,
|
|
9
|
+
getFunctionRuntime:()=>z,getFunctionState:()=>Rt,getPermission:()=>Qt,isFunctionState:()=>Y,
|
|
10
|
+
isMappingState:()=>Jt,registerTriggers:()=>$t,tryGetFunctionArn:()=>xe,tryGetFunctionState:()=>vt});
|
|
11
|
+
module.exports=St(Xt);var Ye=require("@ez4/aws-common"),et=require("@ez4/aws-identity"),tt=require("@ez4/aws-logs"),
|
|
12
|
+
nt=require("@ez4/project/library");var Ne=require("@ez4/aws-common");var f=require("@ez4/aws-common"),C=require("@ez4/utils"),re=require("@ez4/aws-logs"),
|
|
13
|
+
oe=require("@ez4/aws-identity");var s=require("@aws-sdk/client-lambda"),B=require("@ez4/aws-common");var U=require("@ez4/aws-common"),le=require("@aws-sdk/client-lambda");var d=o(()=>new le.LambdaClient((0,U.getAwsClientOptions)()),"getLambdaClient"),
|
|
14
|
+
G=o(t=>({...(0,U.getAwsClientWaiter)(),client:t}),"getLambdaWaiter");var _=require("@ez4/project");var ge=(n=>(n.Node22="nodejs22.x",n.Node24="nodejs24.x",n))(ge||{});var wt={[_.RuntimeType.Node22]:"nodejs22.x",[_.RuntimeType.Node24]:"nodejs24.x"},
|
|
15
|
+
z=o(t=>wt[t],"getFunctionRuntime");var J=require("@ez4/project");var de=(n=>(n.Arm="arm64",n.x86="x86_64",n))(de||{});var Ft={[J.ArchitectureType.Arm]:"arm64",[J.ArchitectureType.x86]:"x86_64"},D=o(
|
|
16
|
+
t=>Ft[t],"getFunctionArchitecture");var fe=require("@ez4/aws-common"),ye=require("@ez4/utils");var w="AWS:Lambda/Function",x="aws:lambda.function";var xt=/[a-z][\w]+/i,bt=o(t=>xt.test(t),"isValidName"),K=o(t=>{for(let e in t)if(!bt(
|
|
17
|
+
e))throw new fe.InvalidParameterError(w,`${e} is an invalid variable name .`)},"\
|
|
18
|
+
assertVariables"),A=o(t=>{let e={};for(let n in t)e[n]=(0,ye.hashData)(t[n]);return e},
|
|
19
|
+
"protectVariables");var Se=yt(require("adm-zip"),1),we=require("node:fs/promises");var Fe=o(async(t,e)=>{let n=new Se.default,r=await(0,we.readFile)(t);return n.addFile(
|
|
20
|
+
e,r),n.toBufferPromise()},"getZipBuffer");var L=require("@ez4/aws-vpc"),X=require("@ez4/aws-common");var k=class extends Error{static{o(this,"FunctionNotFoundError")}constructor(e){
|
|
21
|
+
super(`Function ${e} wasn't found.`)}},V=class extends Error{static{o(this,"Defa\
|
|
22
|
+
ultVpcDetailsError")}constructor(){super("Unable to get the default VPC details.")}};var Y=o(t=>t.type===x,"isFunctionState"),vt=o((t,e,n)=>{try{let r=t.getServiceState(
|
|
23
|
+
e,n);if(Y(r))return r}catch{}},"tryGetFunctionState"),Rt=o((t,e,n)=>{let r=t.getServiceState(
|
|
24
|
+
e,n);if(!Y(r))throw new k(e);return r},"getFunctionState"),N=o((t,e,n)=>{let r=n.
|
|
25
|
+
getDependencies(x).at(0)?.parameters;if(!r?.functionName)throw new X.IncompleteResourceError(
|
|
26
|
+
t,e,"functionName");return r.functionName},"getFunctionName"),xe=o(t=>t.getDependencies(
|
|
27
|
+
x)[0]?.result?.functionArn,"tryGetFunctionArn"),ht=o((t,e,n)=>{let r=xe(n);if(!r)
|
|
28
|
+
throw new X.IncompleteResourceError(t,e,"functionArn");return r},"getFunctionArn"),
|
|
29
|
+
q=o(async()=>{let t=await(0,L.getDefaultVpcId)();if(!t)throw new V;let[e,n]=await Promise.
|
|
30
|
+
all([(0,L.getDefaultSubnetIds)(t),(0,L.getDefaultSecurityGroupId)(t)]);if(!e?.length||
|
|
31
|
+
!n)throw new V;return{subnetIds:e.slice(0,2),securityGroupId:n}},"getDefaultVpcC\
|
|
32
|
+
onfig");var be=o(async(t,e,n)=>{t.update("Importing function");try{let r=await d().send(
|
|
21
33
|
new s.GetFunctionCommand({FunctionName:e,Qualifier:n})),i=r.Configuration.Version,
|
|
22
34
|
a=r.Configuration.FunctionArn;return{functionVersion:i,functionArn:a}}catch(r){if(!(r instanceof
|
|
23
|
-
s.ResourceNotFoundException))throw r;return}},"importFunction"),
|
|
24
|
-
t.update("Creating function");let{functionName:n,variables:r}=e;r&&
|
|
25
|
-
e.handlerName),
|
|
26
|
-
|
|
27
|
-
()=>
|
|
28
|
-
Timeout:
|
|
29
|
-
Zip",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
s.ResourceNotFoundException))throw r;return}},"importFunction"),ve=o(async(t,e)=>{
|
|
36
|
+
t.update("Creating function");let{functionName:n,variables:r}=e;r&&K(r);let i=e.
|
|
37
|
+
vpc?await q():void 0,a=Pe(e.handlerName),p=await Ce(e.sourceFile),{description:c,
|
|
38
|
+
memory:l,timeout:u,publish:m,architecture:g,runtime:S,debug:F,roleArn:P,logGroup:Q}=e,
|
|
39
|
+
O=d(),pe=await(0,B.waitCreation)(()=>O.send(new s.CreateFunctionCommand({FunctionName:n,
|
|
40
|
+
Description:c,MemorySize:l,Timeout:u,Role:P,Publish:m,Handler:a,Architectures:[D(
|
|
41
|
+
g)],Runtime:z(S),PackageType:"Zip",VpcConfig:{SecurityGroupIds:i?[i.securityGroupId]:
|
|
42
|
+
[],SubnetIds:i?i.subnetIds:[]},LoggingConfig:{LogGroup:Q,ApplicationLogLevel:F?s.ApplicationLogLevel.
|
|
43
|
+
Debug:s.ApplicationLogLevel.Warn,SystemLogLevel:s.SystemLogLevel.Warn,LogFormat:s.LogFormat.
|
|
44
|
+
Json},Code:{ZipFile:p},Environment:{Variables:r},Tags:{...e.tags,ManagedBy:"EZ4"}}))),
|
|
45
|
+
ct=pe.FunctionArn,ce=pe.Version,ue=G(O);return await(0,s.waitUntilFunctionActive)(
|
|
46
|
+
ue,{FunctionName:n}),m&&await(0,s.waitUntilPublishedVersionActive)(ue,{FunctionName:n,
|
|
47
|
+
Qualifier:ce}),{functionArn:ct,...m&&{functionVersion:ce}}},"createFunction"),ee=o(
|
|
48
|
+
async(t,e,n)=>{t.update("Updating source code");let r=await Ce(n.sourceFile),{publish:i,
|
|
36
49
|
architecture:a}=n,p=d(),c=await p.send(new s.UpdateFunctionCodeCommand({Architectures:a&&
|
|
37
|
-
[
|
|
38
|
-
return await(0,s.waitUntilFunctionUpdated)(
|
|
39
|
-
|
|
40
|
-
teSourceCode"),
|
|
41
|
-
variables:i}=n;i&&
|
|
42
|
-
logGroup:
|
|
43
|
-
z(
|
|
44
|
-
r)},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
[D(a)],FunctionName:e,ZipFile:r,Publish:i})),l=c.FunctionArn,u=c.Version,m=G(p);
|
|
51
|
+
return await(0,s.waitUntilFunctionUpdated)(m,{FunctionName:e}),i&&await(0,s.waitUntilPublishedVersionActive)(
|
|
52
|
+
m,{FunctionName:e,Qualifier:u}),{functionArn:l,...i&&{functionVersion:u}}},"upda\
|
|
53
|
+
teSourceCode"),te=o(async(t,e,n)=>{t.update("Updating configuration");let{handlerName:r,
|
|
54
|
+
variables:i}=n;i&&K(i);let a=n.vpc?await q():void 0,{description:p,memory:c,timeout:l,
|
|
55
|
+
runtime:u,debug:m,roleArn:g,logGroup:S}=n,F=d();await F.send(new s.UpdateFunctionConfigurationCommand(
|
|
56
|
+
{Runtime:u&&z(u),FunctionName:e,Description:p,MemorySize:c,Timeout:l,Role:g,...r&&
|
|
57
|
+
{Handler:Pe(r)},VpcConfig:{SecurityGroupIds:a?[a.securityGroupId]:[],SubnetIds:a?
|
|
58
|
+
a.subnetIds:[]},LoggingConfig:{LogGroup:S,ApplicationLogLevel:m?s.ApplicationLogLevel.
|
|
59
|
+
Debug:s.ApplicationLogLevel.Warn,SystemLogLevel:s.SystemLogLevel.Warn,LogFormat:s.LogFormat.
|
|
60
|
+
Json},Environment:{Variables:i}})),await(0,s.waitUntilFunctionUpdated)(G(F),{FunctionName:e})},
|
|
61
|
+
"updateConfiguration"),Re=o(async(t,e)=>{e.update("Deleting function");let n=d();
|
|
62
|
+
await(0,B.waitDeletion)(async()=>{try{await n.send(new s.DeleteFunctionCommand({
|
|
49
63
|
FunctionName:t}))}catch(r){if(!(r instanceof s.ResourceNotFoundException))throw r}})},
|
|
50
|
-
"deleteFunction");var
|
|
51
|
-
{Resource:e,Tags:{...n,ManagedBy:"EZ4"}}))},"tagFunction"),
|
|
64
|
+
"deleteFunction");var ne=o(async(t,e,n)=>{t.update("Tag function"),await d().send(new s.TagResourceCommand(
|
|
65
|
+
{Resource:e,Tags:{...n,ManagedBy:"EZ4"}}))},"tagFunction"),he=o(async(t,e,n)=>{t.
|
|
52
66
|
update("Untag function"),await d().send(new s.UntagResourceCommand({Resource:e,TagKeys:n}))},
|
|
53
|
-
"untagFunction"),
|
|
54
|
-
"getSourceHandlerName");var
|
|
55
|
-
getFunctionHandler"),
|
|
56
|
-
"equalsResource"),
|
|
67
|
+
"untagFunction"),Ce=o(t=>Fe(t,"main.mjs"),"getSourceZipFile"),Pe=o(t=>`main.${t}`,
|
|
68
|
+
"getSourceHandlerName");var Ae=o(()=>({equals:Ct,create:Le,replace:At,preview:Pt,update:Lt,delete:Nt}),"\
|
|
69
|
+
getFunctionHandler"),Ct=o((t,e)=>!!t.result&&t.result.functionArn===e.result?.functionArn,
|
|
70
|
+
"equalsResource"),Pt=o(async(t,e)=>{let n=t.parameters,r=e.parameters,i=(0,C.deepCompare)(
|
|
57
71
|
{...n,connections:t.connections,dependencies:t.dependencies,variables:A(await n.
|
|
58
|
-
getFunctionVariables()),sourceHash:await(0,
|
|
72
|
+
getFunctionVariables()),sourceHash:await(0,f.getBundleHash)(...n.getFunctionFiles()),
|
|
59
73
|
valuesHash:n.getFunctionHash()},{...r,connections:e.connections,dependencies:e.dependencies,
|
|
60
74
|
variables:e.result?.variables,sourceHash:e.result?.sourceHash,valuesHash:e.result?.
|
|
61
75
|
valuesHash},{exclude:{release:!0}});if(i.counts)return{...i,name:n.functionName}},
|
|
62
|
-
"previewResource"),
|
|
63
|
-
|
|
64
|
-
release:r,...i}=t.parameters;return
|
|
65
|
-
async a=>{let p=(0,
|
|
66
|
-
all([(0,
|
|
67
|
-
i.getFunctionVariables()]),
|
|
68
|
-
a,n,{architecture:i.architecture,publish:!1,sourceFile:u}),
|
|
69
|
-
roleArn:c,variables:{...g,...r?.variableName&&{[r.
|
|
70
|
-
a,
|
|
71
|
-
|
|
72
|
-
bundleHash:
|
|
73
|
-
sourceFile:u,logGroup:p,roleArn:c,variables:{...g
|
|
74
|
-
|
|
75
|
-
functionArn,functionVersion:
|
|
76
|
-
bundleHash:
|
|
77
|
-
result:i}=t,{functionName:a}=r;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
logGroup:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
n
|
|
92
|
-
c
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
76
|
+
"previewResource"),At=o(async(t,e,n)=>{if(e.result)throw new f.ReplaceResourceError(
|
|
77
|
+
w,t.entryId,e.entryId);return Le(t,n)},"replaceResource"),Le=o((t,e)=>{let{functionName:n,
|
|
78
|
+
release:r,...i}=t.parameters;return f.OperationLogger.logExecution(w,n,"creation",
|
|
79
|
+
async a=>{let p=(0,re.getLogGroupName)(w,n,e),c=(0,oe.getRoleArn)(w,n,e),[l,u,m,
|
|
80
|
+
g]=await Promise.all([(0,f.getBundleHash)(...i.getFunctionFiles()),i.getFunctionBundle(
|
|
81
|
+
e),i.getFunctionHash(),i.getFunctionVariables()]),S=await be(a,n),F=await(0,C.hashFile)(
|
|
82
|
+
u);if(S)return await ee(a,n,{architecture:i.architecture,publish:!1,sourceFile:u}),
|
|
83
|
+
await te(a,n,{...i,logGroup:p,roleArn:c,variables:{...g,...r?.variableName&&{[r.
|
|
84
|
+
variableName]:r.version}}}),await ne(a,S.functionArn,{...i.tags,...r?.tagName&&{
|
|
85
|
+
[r.tagName]:r.version}}),{functionArn:S.functionArn,functionVersion:S.functionVersion,
|
|
86
|
+
variables:A(g),valuesHash:m,sourceHash:l,bundleHash:F,logGroup:p,roleArn:c};let P=await ve(
|
|
87
|
+
a,{...i,publish:!0,functionName:n,sourceFile:u,logGroup:p,roleArn:c,variables:{...g,
|
|
88
|
+
...r?.variableName&&{[r.variableName]:r.version}},tags:{...i.tags,...r?.tagName&&
|
|
89
|
+
{[r.tagName]:r.version}}});return{functionArn:P.functionArn,functionVersion:P.functionVersion,
|
|
90
|
+
variables:A(g),valuesHash:m,sourceHash:l,bundleHash:F,logGroup:p,roleArn:c}})},"\
|
|
91
|
+
createResource"),Lt=o((t,e,n)=>{let{parameters:r,result:i}=t,{functionName:a}=r;
|
|
92
|
+
if(!i)throw new f.CorruptedResourceError(w,a);return f.OperationLogger.logExecution(
|
|
93
|
+
w,a,"updates",async p=>{let c=await r.getFunctionVariables(),l=e.result?.variables??
|
|
94
|
+
c,u=(0,oe.getRoleArn)(w,a,n),m=e.result?.roleArn??u,g=(0,re.getLogGroupName)(w,a,
|
|
95
|
+
n),S=e.result?.logGroup??g,{isUpdated:F,...P}=await Mt(p,a,r,e.result,n),Q={...r,
|
|
96
|
+
variables:c,roleArn:u,logGroup:g},O={...e.parameters,variables:l,roleArn:m,logGroup:S};
|
|
97
|
+
return await It(p,a,Q,O,F,n),await Et(p,i.functionArn,r,e.parameters,F),{...i,...P,
|
|
98
|
+
variables:A(c),logGroup:g,roleArn:u}})},"updateResource"),Nt=o(async t=>{let{result:e,
|
|
99
|
+
parameters:n}=t;if(!e)return;let{functionName:r}=n;await f.OperationLogger.logExecution(
|
|
100
|
+
w,r,"deletion",async i=>{await Re(r,i)})},"deleteResource"),It=o(async(t,e,n,r,i,a)=>{
|
|
101
|
+
let{variables:p,...c}=n,l={variables:A(p),...c},u=!(0,C.deepEqual)(l,r,{exclude:{
|
|
102
|
+
sourceFile:!0,functionName:!0,architecture:!0,release:!0,tags:!0}}),m=i?n.release:
|
|
103
|
+
r.release,g=i&&m?.variableName;(u||g||a.force)&&await te(t,e,{...n,variables:{...n.
|
|
104
|
+
variables,...m?.variableName&&{[m.variableName]:m.version}}})},"checkConfigurati\
|
|
105
|
+
onUpdates"),Et=o(async(t,e,n,r,i)=>{let p=i&&n.release?.version!==r.release?.version?
|
|
106
|
+
n.release:void 0,c={...n.tags,...p?.tagName&&{[p.tagName]:p.version}};await(0,f.applyTagUpdates)(
|
|
107
|
+
c,r.tags,l=>ne(t,e,l),l=>he(t,e,l))},"checkTagUpdates"),Mt=o(async(t,e,n,r,i)=>{
|
|
108
|
+
let[a,p]=await Promise.all([(0,f.getBundleHash)(...n.getFunctionFiles()),n.getFunctionHash()]),
|
|
109
|
+
c=r?.sourceHash,l=r?.valuesHash;if(a!==c||p!==l||i.force){let u=await n.getFunctionBundle(
|
|
110
|
+
i),m=await(0,C.hashFile)(u),g=r?.bundleHash;if(m===g&&p===l)return t.update("Ski\
|
|
111
|
+
pping source code update"),{isUpdated:!1,valuesHash:p,sourceHash:a};let{functionVersion:S}=await ee(
|
|
97
112
|
t,e,{architecture:n.architecture,publish:!r?.functionVersion,sourceFile:u});return{
|
|
98
|
-
isUpdated:!0,valuesHash:p,sourceHash:a,bundleHash:
|
|
99
|
-
isUpdated:!1}},"checkSourceCodeUpdates");var
|
|
100
|
-
|
|
101
|
-
e,n);if(te(r))return r}catch{}},"tryGetFunctionState"),Ct=o((t,e,n)=>{let r=t.getServiceState(
|
|
102
|
-
e,n);if(!te(r))throw new q(e);return r},"getFunctionState"),L=o((t,e,n)=>{let r=n.
|
|
103
|
-
getDependencies(x).at(0)?.parameters;if(!r?.functionName)throw new ee.IncompleteResourceError(
|
|
104
|
-
t,e,"functionName");return r.functionName},"getFunctionName"),Pe=o(t=>t.getDependencies(
|
|
105
|
-
x)[0]?.result?.functionArn,"tryGetFunctionArn"),At=o((t,e,n)=>{let r=Pe(n);if(!r)
|
|
106
|
-
throw new ee.IncompleteResourceError(t,e,"functionArn");return r},"getFunctionAr\
|
|
107
|
-
n");var N=require("@aws-sdk/client-lambda");var Ce=o(async(t,e)=>{t.update("Creating permission");let n=e.statementId??`ID${Date.
|
|
108
|
-
now()}`;return await d().send(new N.AddPermissionCommand({StatementId:n,FunctionName:e.
|
|
113
|
+
isUpdated:!0,valuesHash:p,sourceHash:a,bundleHash:m,...S&&{functionVersion:S}}}return{
|
|
114
|
+
isUpdated:!1}},"checkSourceCodeUpdates");var Ie=o(()=>{(0,Ne.tryRegisterProvider)(x,Ae())},"registerFunctionProvider");var He=require("@ez4/aws-common");var H=require("@ez4/aws-common");var I=require("@aws-sdk/client-lambda");var Ee=o(async(t,e)=>{t.update("Creating permission");let n=e.statementId??`ID${Date.
|
|
115
|
+
now()}`;return await d().send(new I.AddPermissionCommand({StatementId:n,FunctionName:e.
|
|
109
116
|
functionName,SourceArn:e.sourceArn,Principal:e.principal,Action:e.action})),{statementId:n}},
|
|
110
|
-
"createPermission"),
|
|
111
|
-
send(new
|
|
112
|
-
if(!(r instanceof
|
|
113
|
-
ion");var E="AWS:Lambda/Permission",
|
|
114
|
-
getPermissionHandler"),
|
|
115
|
-
functionName,"equalsResource"),
|
|
116
|
-
if(e.result)throw new
|
|
117
|
-
n)},"replaceResource"),
|
|
118
|
-
logExecution(E,r,"creation",async i=>{let a=await n.getPermission(e);return{statementId:(await
|
|
117
|
+
"createPermission"),Me=o(async(t,e,n)=>{t.update("Deleting permission");try{return await d().
|
|
118
|
+
send(new I.RemovePermissionCommand({FunctionName:e,StatementId:n})),!0}catch(r){
|
|
119
|
+
if(!(r instanceof I.ResourceNotFoundException))throw r;return!1}},"deletePermiss\
|
|
120
|
+
ion");var E="AWS:Lambda/Permission",b="aws:lambda.permission";var Te=o(()=>({equals:Tt,create:Ve,replace:Ht,preview:Vt,update:Ot,delete:Ut}),"\
|
|
121
|
+
getPermissionHandler"),Tt=o((t,e)=>!!t.result&&t.result.functionName===e.result?.
|
|
122
|
+
functionName,"equalsResource"),Vt=o((t,e)=>{},"previewResource"),Ht=o(async(t,e,n)=>{
|
|
123
|
+
if(e.result)throw new H.ReplaceResourceError(E,t.entryId,e.entryId);return Ve(t,
|
|
124
|
+
n)},"replaceResource"),Ve=o((t,e)=>{let n=t.parameters,r=N(E,"permission",e);return H.OperationLogger.
|
|
125
|
+
logExecution(E,r,"creation",async i=>{let a=await n.getPermission(e);return{statementId:(await Ee(
|
|
119
126
|
i,{action:"lambda:InvokeFunction",sourceArn:a.sourceArn,principal:a.principal,functionName:r})).
|
|
120
|
-
statementId,functionName:r}})},"createResource"),
|
|
121
|
-
e"),
|
|
122
|
-
await
|
|
123
|
-
"deleteResource");var
|
|
124
|
-
|
|
127
|
+
statementId,functionName:r}})},"createResource"),Ot=o(async()=>{},"updateResourc\
|
|
128
|
+
e"),Ut=o(async t=>{let e=t.result;if(!e)return;let{functionName:n,statementId:r}=e;
|
|
129
|
+
await H.OperationLogger.logExecution(E,n,"deletion",async i=>{await Me(i,n,r)})},
|
|
130
|
+
"deleteResource");var Oe=o(()=>{(0,He.tryRegisterProvider)(b,Te())},"registerPermissionProvider");var Ze=require("@ez4/aws-common");var h=require("@ez4/aws-common"),W=require("@ez4/utils");var y=require("@aws-sdk/client-lambda"),ze=require("@ez4/aws-common");var Ue=require("@aws-sdk/client-lambda"),ie=require("@ez4/utils");var ae=o(async(t,e)=>{let n=new Set(["Enabled","Disabled"]);await ie.Wait.until(
|
|
131
|
+
async()=>{let r=await Gt(t,e);return n.has(r)?!0:ie.Wait.RetryAttempt})},"waitFo\
|
|
132
|
+
rReadyState"),Gt=o(async(t,e)=>(await t.send(new Ue.GetEventSourceMappingCommand(
|
|
133
|
+
{UUID:e}))).State,"getMappingState");var v="AWS:Lambda/Mapping",R="aws:lambda.mapping",Ge=(n=>(n.DynamoDB="dynamodb",
|
|
134
|
+
n.Queue="sqs",n))(Ge||{});var De=o(async(t,e,n)=>{t.update("Importing mapping");let r=await d().send(new y.ListEventSourceMappingsCommand(
|
|
125
135
|
{FunctionName:e,EventSourceArn:n})),[i]=r.EventSourceMappings;return i?{eventId:i.
|
|
126
|
-
UUID}:void 0},"importMapping"),
|
|
127
|
-
sourceArn:n,functionName:r}=e,
|
|
128
|
-
{FunctionName:r,EventSourceArn:n,...
|
|
129
|
-
"createMapping"),
|
|
130
|
-
|
|
131
|
-
n)})),await
|
|
132
|
-
try{return await d().send(new
|
|
133
|
-
if(!(n instanceof
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
until(async()=>{let n=await Tt(t);return e.has(n)?!0:ne.Wait.RetryAttempt})},"wa\
|
|
137
|
-
itForReadyState"),Ge=o(t=>{let{sourceArn:e,enabled:n,concurrency:r,batch:i}=t,{service:a}=(0,Te.parseArn)(
|
|
138
|
-
e);return{Enabled:n,FunctionResponseTypes:[f.FunctionResponseType.ReportBatchItemFailures],
|
|
136
|
+
UUID}:void 0},"importMapping"),ke=o(async(t,e)=>{t.update("Creating mapping");let{
|
|
137
|
+
sourceArn:n,functionName:r}=e,i=d(),p=(await i.send(new y.CreateEventSourceMappingCommand(
|
|
138
|
+
{FunctionName:r,EventSourceArn:n,...We(e)}))).UUID;return await ae(i,p),{eventId:p}},
|
|
139
|
+
"createMapping"),qe=o(async(t,e,n)=>{t.update("Updating mapping");let{functionName:r}=n,
|
|
140
|
+
i=d();await i.send(new y.UpdateEventSourceMappingCommand({UUID:e,FunctionName:r,
|
|
141
|
+
...We(n)})),await ae(i,e)},"updateMapping"),Be=o(async(t,e)=>{t.update("Deleting\
|
|
142
|
+
mapping");try{return await d().send(new y.DeleteEventSourceMappingCommand({UUID:e})),
|
|
143
|
+
!0}catch(n){if(!(n instanceof y.ResourceNotFoundException))throw n;return!1}},"d\
|
|
144
|
+
eleteMapping"),We=o(t=>{let{sourceArn:e,enabled:n,concurrency:r,batch:i}=t,{service:a}=(0,ze.parseArn)(
|
|
145
|
+
e);return{Enabled:n,FunctionResponseTypes:[y.FunctionResponseType.ReportBatchItemFailures],
|
|
139
146
|
MaximumBatchingWindowInSeconds:i?.maxWait,BatchSize:i?.size,...a==="dynamodb"&&{
|
|
140
|
-
StartingPosition:
|
|
141
|
-
"upsertMappingRequest");var
|
|
142
|
-
getMappingHandler"),
|
|
143
|
-
"equalsResource"),
|
|
144
|
-
r={...e.parameters,dependencies:e.dependencies},i=(0,
|
|
147
|
+
StartingPosition:y.EventSourcePosition.LATEST},...a==="sqs"&&{ScalingConfig:{MaximumConcurrency:r}}}},
|
|
148
|
+
"upsertMappingRequest");var $e=o(()=>({equals:zt,create:je,replace:kt,preview:Dt,update:qt,delete:Bt}),"\
|
|
149
|
+
getMappingHandler"),zt=o((t,e)=>!!t.result&&t.result.eventId===e.result?.eventId,
|
|
150
|
+
"equalsResource"),Dt=o((t,e)=>{let n={...t.parameters,dependencies:t.dependencies},
|
|
151
|
+
r={...e.parameters,dependencies:e.dependencies},i=(0,W.deepCompare)(n,r,{exclude:{
|
|
145
152
|
getSourceArn:!0}});if(i.counts)return{...i,name:n.fromService}},"previewResource"),
|
|
146
|
-
|
|
147
|
-
return
|
|
148
|
-
g",e);return
|
|
149
|
-
getSourceArn(e);return{eventId:(await
|
|
150
|
-
sourceArn:a})).eventId,functionName:r,sourceArn:a}})},"createResource"),
|
|
151
|
-
let{result:r,parameters:i}=t,{fromService:a}=i;if(!r)throw new
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
functionName:c,sourceArn:u},g={...e.parameters,functionName:
|
|
155
|
-
p,r.eventId,
|
|
156
|
-
result;if(!e)return;let{functionName:n}=e;await
|
|
157
|
-
n,"deletion",async r=>{await
|
|
158
|
-
!(0,
|
|
159
|
-
"checkGeneralUpdates");var
|
|
160
|
-
return(0,
|
|
161
|
-
LogEvents"],resourceIds:[`arn:aws:logs:${e}:${n}:log-group:${t}-*:*`]}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
(0,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
entryId
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
t,{
|
|
173
|
-
|
|
174
|
-
|
|
153
|
+
kt=o(async(t,e,n)=>{if(e.result)throw new h.ReplaceResourceError(v,t.entryId,e.entryId);
|
|
154
|
+
return je(t,n)},"replaceResource"),je=o((t,e)=>{let n=t.parameters,r=N(v,"mappin\
|
|
155
|
+
g",e);return h.OperationLogger.logExecution(v,r,"creation",async i=>{let a=await n.
|
|
156
|
+
getSourceArn(e);return{eventId:(await De(i,r,a)??await ke(i,{...t.parameters,functionName:r,
|
|
157
|
+
sourceArn:a})).eventId,functionName:r,sourceArn:a}})},"createResource"),qt=o((t,e,n)=>{
|
|
158
|
+
let{result:r,parameters:i}=t,{fromService:a}=i;if(!r)throw new h.CorruptedResourceError(
|
|
159
|
+
v,"mapping");return h.OperationLogger.logExecution(v,a,"updates",async p=>{let c=N(
|
|
160
|
+
v,"mapping",n),l=e.result?.functionName??r.functionName,u=r.sourceArn,m={...t.parameters,
|
|
161
|
+
functionName:c,sourceArn:u},g={...e.parameters,functionName:l,sourceArn:u};return await Wt(
|
|
162
|
+
p,r.eventId,m,g),{...r,functionName:c}})},"updateResource"),Bt=o(async t=>{let e=t.
|
|
163
|
+
result;if(!e)return;let{functionName:n}=e;await h.OperationLogger.logExecution(v,
|
|
164
|
+
n,"deletion",async r=>{await Be(r,e.eventId)})},"deleteResource"),Wt=o(async(t,e,n,r)=>{
|
|
165
|
+
!(0,W.deepEqual)(n,r,{exclude:{getSourceArn:!0,fromService:!0}})&&await qe(t,e,n)},
|
|
166
|
+
"checkGeneralUpdates");var Qe=o(()=>{(0,Ze.tryRegisterProvider)(R,$e())},"registerMappingProvider");var _e=o(()=>[{account:"lambda.amazonaws.com"}],"prepareIdentityAccount");var $=require("@ez4/aws-identity"),Ke=require("@ez4/project/library");var M=require("@ez4/aws-identity");var Je=o(async t=>{let[e,n]=await Promise.all([(0,M.getRegion)(),(0,M.getAccountId)()]);
|
|
167
|
+
return(0,M.createPolicyDocument)([{permissions:["logs:CreateLogStream","logs:Put\
|
|
168
|
+
LogEvents"],resourceIds:[`arn:aws:logs:${e}:${n}:log-group:${t}-*:*`]},{permissions:[
|
|
169
|
+
"ec2:CreateNetworkInterface","ec2:DescribeNetworkInterfaces","ec2:DeleteNetworkI\
|
|
170
|
+
nterface"],resourceIds:["*"]}])},"getPolicyDocument");var Xe=o(async t=>{let{state:e,options:n}=t,r=(0,Ke.getServiceName)("",n),i=`${r}\
|
|
171
|
+
-lambda-policy`;return(0,$.tryGetPolicy)(e,i)??(0,$.createPolicy)(e,{tags:n.tags,
|
|
172
|
+
policyDocument:await Je(r),policyName:i})},"prepareExecutionPolicy");var $t=o(()=>{(0,Ye.registerTriggers)(),(0,et.registerTriggers)(),(0,tt.registerTriggers)(),
|
|
173
|
+
(0,nt.tryCreateTrigger)("@ez4/aws-function",{"deploy:prepareIdentityAccount":_e,
|
|
174
|
+
"deploy:prepareExecutionPolicy":Xe}),Ie(),Oe(),Qe()},"registerTriggers");var j=require("@ez4/utils"),rt=require("@ez4/stateful");var jt=o((t,e,n,r)=>{let i=(0,j.toKebabCase)(r.functionName),a=(0,j.hashData)(x,
|
|
175
|
+
e.entryId,i),p=[e.entryId];return n&&p.push(n.entryId),(0,rt.attachEntry)(t,{type:x,
|
|
176
|
+
entryId:a,dependencies:p,parameters:{...r,functionName:i}})},"createFunction");var it=require("@ez4/stateful"),se=require("@ez4/utils");var ot=o(t=>t.type===b,"isPermissionState");var Zt=o((t,e,n,r)=>{let i=(0,se.hashData)(b,e.entryId,n.entryId);return(0,it.attachEntry)(
|
|
177
|
+
t,{type:b,entryId:i,dependencies:[e.entryId,n.entryId],parameters:r})},"createPe\
|
|
178
|
+
rmission"),Qt=o((t,e,n)=>{let r=(0,se.hashData)(b,e.entryId,n.entryId),i=t[r];return i&&
|
|
179
|
+
ot(i)?i:null},"getPermission");var at=require("@ez4/utils"),st=require("@ez4/stateful");var _t=o((t,e,n,r)=>{let i=(0,at.hashData)(R,e.entryId,n.entryId);return(0,st.attachEntry)(
|
|
180
|
+
t,{type:R,entryId:i,dependencies:[e.entryId,n.entryId],parameters:r})},"createMa\
|
|
181
|
+
pping");var Jt=o(t=>t.type===R,"isMappingState");var Kt=o((t,e,n)=>`arn:aws:lambda:${t}:${e}:function:${n}`,"buildFunctionArn");var Z=require("@ez4/project"),pt;(a=>(a.LogRetention=90,a.Architecture=Z.ArchitectureType.
|
|
182
|
+
x86,a.Runtime=Z.RuntimeType.Node24,a.Timeout=90,a.Memory=192))(pt||={});0&&(module.exports={FunctionArchitecture,FunctionDefaults,FunctionRuntime,FunctionServiceName,
|
|
175
183
|
FunctionServiceType,MappingService,MappingServiceName,MappingServiceType,PermissionServiceName,
|
|
176
184
|
PermissionServiceType,buildFunctionArn,createFunction,createMapping,createPermission,
|
|
177
|
-
getFunctionArchitecture,getFunctionArn,getFunctionName,getFunctionRuntime,
|
|
178
|
-
getPermission,isFunctionState,isMappingState,registerTriggers,tryGetFunctionArn,
|
|
185
|
+
getDefaultVpcConfig,getFunctionArchitecture,getFunctionArn,getFunctionName,getFunctionRuntime,
|
|
186
|
+
getFunctionState,getPermission,isFunctionState,isMappingState,registerTriggers,tryGetFunctionArn,
|
|
179
187
|
tryGetFunctionState});
|
|
180
188
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.mjs
CHANGED
|
@@ -1,162 +1,171 @@
|
|
|
1
|
-
var
|
|
2
|
-
import{registerTriggers as
|
|
3
|
-
ReplaceResourceError as
|
|
4
|
-
hashFile as
|
|
5
|
-
import{getRoleArn as
|
|
6
|
-
UpdateFunctionCodeCommand as
|
|
7
|
-
TagResourceCommand as
|
|
8
|
-
waitUntilFunctionUpdated as
|
|
9
|
-
ApplicationLogLevel as
|
|
10
|
-
import{waitCreation as
|
|
11
|
-
import{LambdaClient as
|
|
12
|
-
daWaiter");import{RuntimeType as
|
|
13
|
-
onRuntime");import{ArchitectureType as
|
|
14
|
-
e))throw new
|
|
15
|
-
t=>{let e={};for(let n in t)e[n]=
|
|
16
|
-
"getZipBuffer");
|
|
17
|
-
{
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Warn,SystemLogLevel:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
g
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
1
|
+
var Ve=Object.defineProperty;var o=(t,e)=>Ve(t,"name",{value:e,configurable:!0});import{registerTriggers as sn}from"@ez4/aws-common";import{registerTriggers as pn}from"@ez4/aws-identity";
|
|
2
|
+
import{registerTriggers as cn}from"@ez4/aws-logs";import{tryCreateTrigger as un}from"@ez4/project/library";import{tryRegisterProvider as bt}from"@ez4/aws-common";import{applyTagUpdates as pt,CorruptedResourceError as ct,getBundleHash as G,OperationLogger as z,
|
|
3
|
+
ReplaceResourceError as ut}from"@ez4/aws-common";import{deepCompare as mt,deepEqual as lt,
|
|
4
|
+
hashFile as se}from"@ez4/utils";import{getLogGroupName as pe}from"@ez4/aws-logs";
|
|
5
|
+
import{getRoleArn as ce}from"@ez4/aws-identity";import{GetFunctionCommand as Xe,CreateFunctionCommand as Ye,DeleteFunctionCommand as et,
|
|
6
|
+
UpdateFunctionCodeCommand as tt,UpdateFunctionConfigurationCommand as nt,PublishVersionCommand as tr,
|
|
7
|
+
TagResourceCommand as rt,UntagResourceCommand as ot,waitUntilFunctionActive as it,
|
|
8
|
+
waitUntilFunctionUpdated as J,waitUntilPublishedVersionActive as K,ResourceNotFoundException as X,
|
|
9
|
+
ApplicationLogLevel as N,SystemLogLevel as Y,LogFormat as ee}from"@aws-sdk/client-lambda";
|
|
10
|
+
import{waitCreation as at,waitDeletion as st}from"@ez4/aws-common";import{getAwsClientOptions as He,getAwsClientWaiter as Oe}from"@ez4/aws-common";
|
|
11
|
+
import{LambdaClient as Ue}from"@aws-sdk/client-lambda";var g=o(()=>new Ue(He()),"getLambdaClient"),A=o(t=>({...Oe(),client:t}),"getLamb\
|
|
12
|
+
daWaiter");import{RuntimeType as $}from"@ez4/project";var Ge=(n=>(n.Node22="nodejs22.x",n.Node24="nodejs24.x",n))(Ge||{});var ze={[$.Node22]:"nodejs22.x",[$.Node24]:"nodejs24.x"},E=o(t=>ze[t],"getFuncti\
|
|
13
|
+
onRuntime");import{ArchitectureType as j}from"@ez4/project";var De=(n=>(n.Arm="arm64",n.x86="x86_64",n))(De||{});var ke={[j.Arm]:"arm64",[j.x86]:"x86_64"},M=o(t=>ke[t],"getFunctionArchitecture");import{InvalidParameterError as qe}from"@ez4/aws-common";import{hashData as Be}from"@ez4/utils";var f="AWS:Lambda/Function",S="aws:lambda.function";var We=/[a-z][\w]+/i,$e=o(t=>We.test(t),"isValidName"),T=o(t=>{for(let e in t)if(!$e(
|
|
14
|
+
e))throw new qe(f,`${e} is an invalid variable name .`)},"assertVariables"),v=o(
|
|
15
|
+
t=>{let e={};for(let n in t)e[n]=Be(t[n]);return e},"protectVariables");import je from"adm-zip";import{readFile as Ze}from"node:fs/promises";var Z=o(async(t,e)=>{let n=new je,r=await Ze(t);return n.addFile(e,r),n.toBufferPromise()},
|
|
16
|
+
"getZipBuffer");import{getDefaultSecurityGroupId as Qe,getDefaultSubnetIds as _e,getDefaultVpcId as Je}from"@ez4/aws-vpc";
|
|
17
|
+
import{IncompleteResourceError as Q}from"@ez4/aws-common";var L=class extends Error{static{o(this,"FunctionNotFoundError")}constructor(e){
|
|
18
|
+
super(`Function ${e} wasn't found.`)}},R=class extends Error{static{o(this,"Defa\
|
|
19
|
+
ultVpcDetailsError")}constructor(){super("Unable to get the default VPC details.")}};var _=o(t=>t.type===S,"isFunctionState"),_n=o((t,e,n)=>{try{let r=t.getServiceState(
|
|
20
|
+
e,n);if(_(r))return r}catch{}},"tryGetFunctionState"),Jn=o((t,e,n)=>{let r=t.getServiceState(
|
|
21
|
+
e,n);if(!_(r))throw new L(e);return r},"getFunctionState"),h=o((t,e,n)=>{let r=n.
|
|
22
|
+
getDependencies(S).at(0)?.parameters;if(!r?.functionName)throw new Q(t,e,"functi\
|
|
23
|
+
onName");return r.functionName},"getFunctionName"),Ke=o(t=>t.getDependencies(S)[0]?.
|
|
24
|
+
result?.functionArn,"tryGetFunctionArn"),Kn=o((t,e,n)=>{let r=Ke(n);if(!r)throw new Q(
|
|
25
|
+
t,e,"functionArn");return r},"getFunctionArn"),V=o(async()=>{let t=await Je();if(!t)
|
|
26
|
+
throw new R;let[e,n]=await Promise.all([_e(t),Qe(t)]);if(!e?.length||!n)throw new R;
|
|
27
|
+
return{subnetIds:e.slice(0,2),securityGroupId:n}},"getDefaultVpcConfig");var te=o(async(t,e,n)=>{t.update("Importing function");try{let r=await g().send(
|
|
28
|
+
new Xe({FunctionName:e,Qualifier:n})),i=r.Configuration.Version,a=r.Configuration.
|
|
29
|
+
FunctionArn;return{functionVersion:i,functionArn:a}}catch(r){if(!(r instanceof X))
|
|
30
|
+
throw r;return}},"importFunction"),ne=o(async(t,e)=>{t.update("Creating function");
|
|
31
|
+
let{functionName:n,variables:r}=e;r&&T(r);let i=e.vpc?await V():void 0,a=ae(e.handlerName),
|
|
32
|
+
s=await ie(e.sourceFile),{description:p,memory:m,timeout:c,publish:u,architecture:l,
|
|
33
|
+
runtime:d,debug:y,roleArn:b,logGroup:I}=e,P=g(),q=await at(()=>P.send(new Ye({FunctionName:n,
|
|
34
|
+
Description:p,MemorySize:m,Timeout:c,Role:b,Publish:u,Handler:a,Architectures:[M(
|
|
35
|
+
l)],Runtime:E(d),PackageType:"Zip",VpcConfig:{SecurityGroupIds:i?[i.securityGroupId]:
|
|
36
|
+
[],SubnetIds:i?i.subnetIds:[]},LoggingConfig:{LogGroup:I,ApplicationLogLevel:y?N.
|
|
37
|
+
Debug:N.Warn,SystemLogLevel:Y.Warn,LogFormat:ee.Json},Code:{ZipFile:s},Environment:{
|
|
38
|
+
Variables:r},Tags:{...e.tags,ManagedBy:"EZ4"}}))),Te=q.FunctionArn,B=q.Version,W=A(
|
|
39
|
+
P);return await it(W,{FunctionName:n}),u&&await K(W,{FunctionName:n,Qualifier:B}),
|
|
40
|
+
{functionArn:Te,...u&&{functionVersion:B}}},"createFunction"),H=o(async(t,e,n)=>{
|
|
41
|
+
t.update("Updating source code");let r=await ie(n.sourceFile),{publish:i,architecture:a}=n,
|
|
42
|
+
s=g(),p=await s.send(new tt({Architectures:a&&[M(a)],FunctionName:e,ZipFile:r,Publish:i})),
|
|
43
|
+
m=p.FunctionArn,c=p.Version,u=A(s);return await J(u,{FunctionName:e}),i&&await K(
|
|
44
|
+
u,{FunctionName:e,Qualifier:c}),{functionArn:m,...i&&{functionVersion:c}}},"upda\
|
|
45
|
+
teSourceCode"),O=o(async(t,e,n)=>{t.update("Updating configuration");let{handlerName:r,
|
|
46
|
+
variables:i}=n;i&&T(i);let a=n.vpc?await V():void 0,{description:s,memory:p,timeout:m,
|
|
47
|
+
runtime:c,debug:u,roleArn:l,logGroup:d}=n,y=g();await y.send(new nt({Runtime:c&&
|
|
48
|
+
E(c),FunctionName:e,Description:s,MemorySize:p,Timeout:m,Role:l,...r&&{Handler:ae(
|
|
49
|
+
r)},VpcConfig:{SecurityGroupIds:a?[a.securityGroupId]:[],SubnetIds:a?a.subnetIds:
|
|
50
|
+
[]},LoggingConfig:{LogGroup:d,ApplicationLogLevel:u?N.Debug:N.Warn,SystemLogLevel:Y.
|
|
51
|
+
Warn,LogFormat:ee.Json},Environment:{Variables:i}})),await J(A(y),{FunctionName:e})},
|
|
52
|
+
"updateConfiguration"),re=o(async(t,e)=>{e.update("Deleting function");let n=g();
|
|
53
|
+
await st(async()=>{try{await n.send(new et({FunctionName:t}))}catch(r){if(!(r instanceof
|
|
54
|
+
X))throw r}})},"deleteFunction");var U=o(async(t,e,n)=>{t.update("Tag function"),await g().send(new rt({Resource:e,
|
|
55
|
+
Tags:{...n,ManagedBy:"EZ4"}}))},"tagFunction"),oe=o(async(t,e,n)=>{t.update("Unt\
|
|
56
|
+
ag function"),await g().send(new ot({Resource:e,TagKeys:n}))},"untagFunction"),ie=o(
|
|
57
|
+
t=>Z(t,"main.mjs"),"getSourceZipFile"),ae=o(t=>`main.${t}`,"getSourceHandlerName");var ue=o(()=>({equals:gt,create:me,replace:ft,preview:dt,update:yt,delete:St}),"\
|
|
58
|
+
getFunctionHandler"),gt=o((t,e)=>!!t.result&&t.result.functionArn===e.result?.functionArn,
|
|
59
|
+
"equalsResource"),dt=o(async(t,e)=>{let n=t.parameters,r=e.parameters,i=mt({...n,
|
|
46
60
|
connections:t.connections,dependencies:t.dependencies,variables:v(await n.getFunctionVariables()),
|
|
47
|
-
sourceHash:await
|
|
61
|
+
sourceHash:await G(...n.getFunctionFiles()),valuesHash:n.getFunctionHash()},{...r,
|
|
48
62
|
connections:e.connections,dependencies:e.dependencies,variables:e.result?.variables,
|
|
49
63
|
sourceHash:e.result?.sourceHash,valuesHash:e.result?.valuesHash},{exclude:{release:!0}});
|
|
50
|
-
if(i.counts)return{...i,name:n.functionName}},"previewResource"),
|
|
51
|
-
if(e.result)throw new
|
|
52
|
-
|
|
53
|
-
f,n,"creation",async a=>{let s=
|
|
54
|
-
[
|
|
55
|
-
d=await
|
|
56
|
-
publish:!1,sourceFile:c}),await
|
|
57
|
-
...r?.variableName&&{[r.variableName]:r.version}}}),await
|
|
64
|
+
if(i.counts)return{...i,name:n.functionName}},"previewResource"),ft=o(async(t,e,n)=>{
|
|
65
|
+
if(e.result)throw new ut(f,t.entryId,e.entryId);return me(t,n)},"replaceResource"),
|
|
66
|
+
me=o((t,e)=>{let{functionName:n,release:r,...i}=t.parameters;return z.logExecution(
|
|
67
|
+
f,n,"creation",async a=>{let s=pe(f,n,e),p=ce(f,n,e),[m,c,u,l]=await Promise.all(
|
|
68
|
+
[G(...i.getFunctionFiles()),i.getFunctionBundle(e),i.getFunctionHash(),i.getFunctionVariables()]),
|
|
69
|
+
d=await te(a,n),y=await se(c);if(d)return await H(a,n,{architecture:i.architecture,
|
|
70
|
+
publish:!1,sourceFile:c}),await O(a,n,{...i,logGroup:s,roleArn:p,variables:{...l,
|
|
71
|
+
...r?.variableName&&{[r.variableName]:r.version}}}),await U(a,d.functionArn,{...i.
|
|
58
72
|
tags,...r?.tagName&&{[r.tagName]:r.version}}),{functionArn:d.functionArn,functionVersion:d.
|
|
59
|
-
functionVersion,variables:v(l),valuesHash:
|
|
60
|
-
roleArn:p};let
|
|
73
|
+
functionVersion,variables:v(l),valuesHash:u,sourceHash:m,bundleHash:y,logGroup:s,
|
|
74
|
+
roleArn:p};let b=await ne(a,{...i,publish:!0,functionName:n,sourceFile:c,logGroup:s,
|
|
61
75
|
roleArn:p,variables:{...l,...r?.variableName&&{[r.variableName]:r.version}},tags:{
|
|
62
|
-
...i.tags,...r?.tagName&&{[r.tagName]:r.version}}});return{functionArn:
|
|
63
|
-
functionVersion:
|
|
64
|
-
logGroup:s,roleArn:p}})},"createResource"),
|
|
65
|
-
{functionName:a}=r;if(!i)throw new
|
|
66
|
-
let p=await r.getFunctionVariables(),
|
|
67
|
-
roleArn??c,l=
|
|
68
|
-
e.result,n),
|
|
69
|
-
roleArn:
|
|
70
|
-
parameters,
|
|
71
|
-
|
|
72
|
-
logExecution(f,r,"deletion",async i=>{await
|
|
73
|
-
let{variables:s,...p}=n,
|
|
74
|
-
functionName:!0,architecture:!0,release:!0,tags:!0}}),
|
|
75
|
-
|
|
76
|
-
variableName&&{[
|
|
76
|
+
...i.tags,...r?.tagName&&{[r.tagName]:r.version}}});return{functionArn:b.functionArn,
|
|
77
|
+
functionVersion:b.functionVersion,variables:v(l),valuesHash:u,sourceHash:m,bundleHash:y,
|
|
78
|
+
logGroup:s,roleArn:p}})},"createResource"),yt=o((t,e,n)=>{let{parameters:r,result:i}=t,
|
|
79
|
+
{functionName:a}=r;if(!i)throw new ct(f,a);return z.logExecution(f,a,"updates",async s=>{
|
|
80
|
+
let p=await r.getFunctionVariables(),m=e.result?.variables??p,c=ce(f,a,n),u=e.result?.
|
|
81
|
+
roleArn??c,l=pe(f,a,n),d=e.result?.logGroup??l,{isUpdated:y,...b}=await xt(s,a,r,
|
|
82
|
+
e.result,n),I={...r,variables:p,roleArn:c,logGroup:l},P={...e.parameters,variables:m,
|
|
83
|
+
roleArn:u,logGroup:d};return await wt(s,a,I,P,y,n),await Ft(s,i.functionArn,r,e.
|
|
84
|
+
parameters,y),{...i,...b,variables:v(p),logGroup:l,roleArn:c}})},"updateResource"),
|
|
85
|
+
St=o(async t=>{let{result:e,parameters:n}=t;if(!e)return;let{functionName:r}=n;await z.
|
|
86
|
+
logExecution(f,r,"deletion",async i=>{await re(r,i)})},"deleteResource"),wt=o(async(t,e,n,r,i,a)=>{
|
|
87
|
+
let{variables:s,...p}=n,m={variables:v(s),...p},c=!lt(m,r,{exclude:{sourceFile:!0,
|
|
88
|
+
functionName:!0,architecture:!0,release:!0,tags:!0}}),u=i?n.release:r.release,l=i&&
|
|
89
|
+
u?.variableName;(c||l||a.force)&&await O(t,e,{...n,variables:{...n.variables,...u?.
|
|
90
|
+
variableName&&{[u.variableName]:u.version}}})},"checkConfigurationUpdates"),Ft=o(
|
|
77
91
|
async(t,e,n,r,i)=>{let s=i&&n.release?.version!==r.release?.version?n.release:void 0,
|
|
78
|
-
p={...n.tags,...s?.tagName&&{[s.tagName]:s.version}};await
|
|
79
|
-
|
|
80
|
-
all([
|
|
81
|
-
if(a!==p||s!==
|
|
82
|
-
bundleHash;if(
|
|
83
|
-
valuesHash:s,sourceHash:a};let{functionVersion:d}=await
|
|
92
|
+
p={...n.tags,...s?.tagName&&{[s.tagName]:s.version}};await pt(p,r.tags,m=>U(t,e,
|
|
93
|
+
m),m=>oe(t,e,m))},"checkTagUpdates"),xt=o(async(t,e,n,r,i)=>{let[a,s]=await Promise.
|
|
94
|
+
all([G(...n.getFunctionFiles()),n.getFunctionHash()]),p=r?.sourceHash,m=r?.valuesHash;
|
|
95
|
+
if(a!==p||s!==m||i.force){let c=await n.getFunctionBundle(i),u=await se(c),l=r?.
|
|
96
|
+
bundleHash;if(u===l&&s===m)return t.update("Skipping source code update"),{isUpdated:!1,
|
|
97
|
+
valuesHash:s,sourceHash:a};let{functionVersion:d}=await H(t,e,{architecture:n.architecture,
|
|
84
98
|
publish:!r?.functionVersion,sourceFile:c});return{isUpdated:!0,valuesHash:s,sourceHash:a,
|
|
85
|
-
bundleHash:
|
|
86
|
-
dates");var
|
|
87
|
-
|
|
88
|
-
e,n);if(pe(r))return r}catch{}},"tryGetFunctionState"),gr=o((t,e,n)=>{let r=t.getServiceState(
|
|
89
|
-
e,n);if(!pe(r))throw new N(e);return r},"getFunctionState"),b=o((t,e,n)=>{let r=n.
|
|
90
|
-
getDependencies(y).at(0)?.parameters;if(!r?.functionName)throw new se(t,e,"funct\
|
|
91
|
-
ionName");return r.functionName},"getFunctionName"),ft=o(t=>t.getDependencies(y)[0]?.
|
|
92
|
-
result?.functionArn,"tryGetFunctionArn"),dr=o((t,e,n)=>{let r=ft(n);if(!r)throw new se(
|
|
93
|
-
t,e,"functionArn");return r},"getFunctionArn");import{AddPermissionCommand as yt,RemovePermissionCommand as St,ResourceNotFoundException as Ft}from"@aws-sdk/client-lambda";var ce=o(async(t,e)=>{t.update("Creating permission");let n=e.statementId??`ID${Date.
|
|
94
|
-
now()}`;return await g().send(new yt({StatementId:n,FunctionName:e.functionName,
|
|
99
|
+
bundleHash:u,...d&&{functionVersion:d}}}return{isUpdated:!1}},"checkSourceCodeUp\
|
|
100
|
+
dates");var le=o(()=>{bt(S,ue())},"registerFunctionProvider");import{tryRegisterProvider as Et}from"@ez4/aws-common";import{OperationLogger as fe,ReplaceResourceError as Ct}from"@ez4/aws-common";import{AddPermissionCommand as vt,RemovePermissionCommand as Rt,ResourceNotFoundException as ht}from"@aws-sdk/client-lambda";var ge=o(async(t,e)=>{t.update("Creating permission");let n=e.statementId??`ID${Date.
|
|
101
|
+
now()}`;return await g().send(new vt({StatementId:n,FunctionName:e.functionName,
|
|
95
102
|
SourceArn:e.sourceArn,Principal:e.principal,Action:e.action})),{statementId:n}},
|
|
96
|
-
"createPermission"),
|
|
97
|
-
send(new
|
|
98
|
-
return!1}},"deletePermission");var
|
|
99
|
-
getPermissionHandler"),
|
|
100
|
-
functionName,"equalsResource"),
|
|
101
|
-
if(e.result)throw new
|
|
102
|
-
|
|
103
|
-
"creation",async i=>{let a=await n.getPermission(e);return{statementId:(await
|
|
103
|
+
"createPermission"),de=o(async(t,e,n)=>{t.update("Deleting permission");try{return await g().
|
|
104
|
+
send(new Rt({FunctionName:e,StatementId:n})),!0}catch(r){if(!(r instanceof ht))throw r;
|
|
105
|
+
return!1}},"deletePermission");var C="AWS:Lambda/Permission",w="aws:lambda.permission";var ye=o(()=>({equals:Pt,create:Se,replace:Lt,preview:At,update:Nt,delete:It}),"\
|
|
106
|
+
getPermissionHandler"),Pt=o((t,e)=>!!t.result&&t.result.functionName===e.result?.
|
|
107
|
+
functionName,"equalsResource"),At=o((t,e)=>{},"previewResource"),Lt=o(async(t,e,n)=>{
|
|
108
|
+
if(e.result)throw new Ct(C,t.entryId,e.entryId);return Se(t,n)},"replaceResource"),
|
|
109
|
+
Se=o((t,e)=>{let n=t.parameters,r=h(C,"permission",e);return fe.logExecution(C,r,
|
|
110
|
+
"creation",async i=>{let a=await n.getPermission(e);return{statementId:(await ge(
|
|
104
111
|
i,{action:"lambda:InvokeFunction",sourceArn:a.sourceArn,principal:a.principal,functionName:r})).
|
|
105
|
-
statementId,functionName:r}})},"createResource"),
|
|
106
|
-
e"),
|
|
107
|
-
await
|
|
108
|
-
e");var
|
|
109
|
-
import{deepCompare as
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
import{parseArn as
|
|
113
|
-
|
|
112
|
+
statementId,functionName:r}})},"createResource"),Nt=o(async()=>{},"updateResourc\
|
|
113
|
+
e"),It=o(async t=>{let e=t.result;if(!e)return;let{functionName:n,statementId:r}=e;
|
|
114
|
+
await fe.logExecution(C,n,"deletion",async i=>{await de(i,n,r)})},"deleteResourc\
|
|
115
|
+
e");var we=o(()=>{Et(w,ye())},"registerPermissionProvider");import{tryRegisterProvider as Yt}from"@ez4/aws-common";import{CorruptedResourceError as Bt,OperationLogger as k,ReplaceResourceError as Wt}from"@ez4/aws-common";
|
|
116
|
+
import{deepCompare as $t,deepEqual as jt}from"@ez4/utils";import{CreateEventSourceMappingCommand as Ht,UpdateEventSourceMappingCommand as Ot,
|
|
117
|
+
DeleteEventSourceMappingCommand as Ut,ListEventSourceMappingsCommand as Gt,FunctionResponseType as zt,
|
|
118
|
+
EventSourcePosition as Dt,ResourceNotFoundException as kt}from"@aws-sdk/client-lambda";
|
|
119
|
+
import{parseArn as qt}from"@ez4/aws-common";import{GetEventSourceMappingCommand as Mt}from"@aws-sdk/client-lambda";import{Wait as Fe}from"@ez4/utils";var D=o(async(t,e)=>{let n=new Set(["Enabled","Disabled"]);await Fe.until(async()=>{
|
|
120
|
+
let r=await Tt(t,e);return n.has(r)?!0:Fe.RetryAttempt})},"waitForReadyState"),Tt=o(
|
|
121
|
+
async(t,e)=>(await t.send(new Mt({UUID:e}))).State,"getMappingState");var F="AWS:Lambda/Mapping",x="aws:lambda.mapping",Vt=(n=>(n.DynamoDB="dynamodb",
|
|
122
|
+
n.Queue="sqs",n))(Vt||{});var xe=o(async(t,e,n)=>{t.update("Importing mapping");let r=await g().send(new Gt(
|
|
114
123
|
{FunctionName:e,EventSourceArn:n})),[i]=r.EventSourceMappings;return i?{eventId:i.
|
|
115
|
-
UUID}:void 0},"importMapping"),
|
|
116
|
-
sourceArn:n,functionName:r}=e,
|
|
117
|
-
...
|
|
118
|
-
t.update("Updating mapping");let{functionName:r}=n;await
|
|
119
|
-
FunctionName:r,...
|
|
120
|
-
"Deleting mapping");try{return await g().send(new
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
"
|
|
128
|
-
|
|
129
|
-
"
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
be
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
functionName:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
await xe(r,e.eventId)})},"deleteResource"),jt=o(async(t,e,n,r)=>{!Dt(n,r,{exclude:{
|
|
143
|
-
getSourceArn:!0,fromService:!0}})&&await Fe(t,e,n)},"checkGeneralUpdates");var he=o(()=>{Zt(w,ve())},"registerMappingProvider");var Pe=o(()=>[{account:"lambda.amazonaws.com"}],"prepareIdentityAccount");import{createPolicy as Kt,tryGetPolicy as Xt}from"@ez4/aws-identity";import{getServiceName as Yt}from"@ez4/project/library";import{getAccountId as Qt,getRegion as _t,createPolicyDocument as Jt}from"@ez4/aws-identity";var Ce=o(async t=>{let[e,n]=await Promise.all([_t(),Qt()]);return Jt([{permissions:[
|
|
124
|
+
UUID}:void 0},"importMapping"),be=o(async(t,e)=>{t.update("Creating mapping");let{
|
|
125
|
+
sourceArn:n,functionName:r}=e,i=g(),s=(await i.send(new Ht({FunctionName:r,EventSourceArn:n,
|
|
126
|
+
...he(e)}))).UUID;return await D(i,s),{eventId:s}},"createMapping"),ve=o(async(t,e,n)=>{
|
|
127
|
+
t.update("Updating mapping");let{functionName:r}=n,i=g();await i.send(new Ot({UUID:e,
|
|
128
|
+
FunctionName:r,...he(n)})),await D(i,e)},"updateMapping"),Re=o(async(t,e)=>{t.update(
|
|
129
|
+
"Deleting mapping");try{return await g().send(new Ut({UUID:e})),!0}catch(n){if(!(n instanceof
|
|
130
|
+
kt))throw n;return!1}},"deleteMapping"),he=o(t=>{let{sourceArn:e,enabled:n,concurrency:r,
|
|
131
|
+
batch:i}=t,{service:a}=qt(e);return{Enabled:n,FunctionResponseTypes:[zt.ReportBatchItemFailures],
|
|
132
|
+
MaximumBatchingWindowInSeconds:i?.maxWait,BatchSize:i?.size,...a==="dynamodb"&&{
|
|
133
|
+
StartingPosition:Dt.LATEST},...a==="sqs"&&{ScalingConfig:{MaximumConcurrency:r}}}},
|
|
134
|
+
"upsertMappingRequest");var Ce=o(()=>({equals:Zt,create:Pe,replace:_t,preview:Qt,update:Jt,delete:Kt}),"\
|
|
135
|
+
getMappingHandler"),Zt=o((t,e)=>!!t.result&&t.result.eventId===e.result?.eventId,
|
|
136
|
+
"equalsResource"),Qt=o((t,e)=>{let n={...t.parameters,dependencies:t.dependencies},
|
|
137
|
+
r={...e.parameters,dependencies:e.dependencies},i=$t(n,r,{exclude:{getSourceArn:!0}});
|
|
138
|
+
if(i.counts)return{...i,name:n.fromService}},"previewResource"),_t=o(async(t,e,n)=>{
|
|
139
|
+
if(e.result)throw new Wt(F,t.entryId,e.entryId);return Pe(t,n)},"replaceResource"),
|
|
140
|
+
Pe=o((t,e)=>{let n=t.parameters,r=h(F,"mapping",e);return k.logExecution(F,r,"cr\
|
|
141
|
+
eation",async i=>{let a=await n.getSourceArn(e);return{eventId:(await xe(i,r,a)??
|
|
142
|
+
await be(i,{...t.parameters,functionName:r,sourceArn:a})).eventId,functionName:r,
|
|
143
|
+
sourceArn:a}})},"createResource"),Jt=o((t,e,n)=>{let{result:r,parameters:i}=t,{fromService:a}=i;
|
|
144
|
+
if(!r)throw new Bt(F,"mapping");return k.logExecution(F,a,"updates",async s=>{let p=h(
|
|
145
|
+
F,"mapping",n),m=e.result?.functionName??r.functionName,c=r.sourceArn,u={...t.parameters,
|
|
146
|
+
functionName:p,sourceArn:c},l={...e.parameters,functionName:m,sourceArn:c};return await Xt(
|
|
147
|
+
s,r.eventId,u,l),{...r,functionName:p}})},"updateResource"),Kt=o(async t=>{let e=t.
|
|
148
|
+
result;if(!e)return;let{functionName:n}=e;await k.logExecution(F,n,"deletion",async r=>{
|
|
149
|
+
await Re(r,e.eventId)})},"deleteResource"),Xt=o(async(t,e,n,r)=>{!jt(n,r,{exclude:{
|
|
150
|
+
getSourceArn:!0,fromService:!0}})&&await ve(t,e,n)},"checkGeneralUpdates");var Ae=o(()=>{Yt(x,Ce())},"registerMappingProvider");var Le=o(()=>[{account:"lambda.amazonaws.com"}],"prepareIdentityAccount");import{createPolicy as rn,tryGetPolicy as on}from"@ez4/aws-identity";import{getServiceName as an}from"@ez4/project/library";import{getAccountId as en,getRegion as tn,createPolicyDocument as nn}from"@ez4/aws-identity";var Ne=o(async t=>{let[e,n]=await Promise.all([tn(),en()]);return nn([{permissions:[
|
|
144
151
|
"logs:CreateLogStream","logs:PutLogEvents"],resourceIds:[`arn:aws:logs:${e}:${n}\
|
|
145
|
-
:log-group:${t}-*:*`]}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
dependencies:[e.entryId,n.entryId],parameters:r})},"
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
152
|
+
:log-group:${t}-*:*`]},{permissions:["ec2:CreateNetworkInterface","ec2:DescribeN\
|
|
153
|
+
etworkInterfaces","ec2:DeleteNetworkInterface"],resourceIds:["*"]}])},"getPolicy\
|
|
154
|
+
Document");var Ie=o(async t=>{let{state:e,options:n}=t,r=an("",n),i=`${r}-lambda-policy`;return on(
|
|
155
|
+
e,i)??rn(e,{tags:n.tags,policyDocument:await Ne(r),policyName:i})},"prepareExecu\
|
|
156
|
+
tionPolicy");var Io=o(()=>{sn(),pn(),cn(),un("@ez4/aws-function",{"deploy:prepareIdentityAcco\
|
|
157
|
+
unt":Le,"deploy:prepareExecutionPolicy":Ie}),le(),we(),Ae()},"registerTriggers");import{toKebabCase as mn,hashData as ln}from"@ez4/utils";import{attachEntry as gn}from"@ez4/stateful";var Oo=o((t,e,n,r)=>{let i=mn(r.functionName),a=ln(S,e.entryId,i),s=[e.entryId];
|
|
158
|
+
return n&&s.push(n.entryId),gn(t,{type:S,entryId:a,dependencies:s,parameters:{...r,
|
|
159
|
+
functionName:i}})},"createFunction");import{attachEntry as dn}from"@ez4/stateful";import{hashData as Me}from"@ez4/utils";var Ee=o(t=>t.type===w,"isPermissionState");var jo=o((t,e,n,r)=>{let i=Me(w,e.entryId,n.entryId);return dn(t,{type:w,entryId:i,
|
|
160
|
+
dependencies:[e.entryId,n.entryId],parameters:r})},"createPermission"),Zo=o((t,e,n)=>{
|
|
161
|
+
let r=Me(w,e.entryId,n.entryId),i=t[r];return i&&Ee(i)?i:null},"getPermission");import{hashData as fn}from"@ez4/utils";import{attachEntry as yn}from"@ez4/stateful";var Yo=o((t,e,n,r)=>{let i=fn(x,e.entryId,n.entryId);return yn(t,{type:x,entryId:i,
|
|
162
|
+
dependencies:[e.entryId,n.entryId],parameters:r})},"createMapping");var ri=o(t=>t.type===x,"isMappingState");var ai=o((t,e,n)=>`arn:aws:lambda:${t}:${e}:function:${n}`,"buildFunctionArn");import{ArchitectureType as Sn,RuntimeType as wn}from"@ez4/project";var Fn;(a=>(a.
|
|
163
|
+
LogRetention=90,a.Architecture=Sn.x86,a.Runtime=wn.Node24,a.Timeout=90,a.Memory=
|
|
164
|
+
192))(Fn||={});export{De as FunctionArchitecture,Fn as FunctionDefaults,Ge as FunctionRuntime,f as FunctionServiceName,
|
|
165
|
+
S as FunctionServiceType,Vt as MappingService,F as MappingServiceName,x as MappingServiceType,
|
|
166
|
+
C as PermissionServiceName,w as PermissionServiceType,ai as buildFunctionArn,Oo as createFunction,
|
|
167
|
+
Yo as createMapping,jo as createPermission,V as getDefaultVpcConfig,M as getFunctionArchitecture,
|
|
168
|
+
Kn as getFunctionArn,h as getFunctionName,E as getFunctionRuntime,Jn as getFunctionState,
|
|
169
|
+
Zo as getPermission,_ as isFunctionState,ri as isMappingState,Io as registerTriggers,
|
|
170
|
+
Ke as tryGetFunctionArn,_n as tryGetFunctionState};
|
|
162
171
|
//# sourceMappingURL=main.mjs.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ez4/aws-function",
|
|
3
3
|
"description": "EZ4: Self-managed AWS lambda function provider",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.42.0",
|
|
5
5
|
"author": "Silas B.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -43,13 +43,14 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@aws-sdk/client-lambda": "^3.958.0",
|
|
46
|
-
"@ez4/aws-common": "^0.
|
|
47
|
-
"@ez4/aws-identity": "^0.
|
|
48
|
-
"@ez4/aws-logs": "^0.
|
|
49
|
-
"@ez4/
|
|
50
|
-
"@ez4/
|
|
51
|
-
"@ez4/
|
|
52
|
-
"@ez4/
|
|
46
|
+
"@ez4/aws-common": "^0.42.0",
|
|
47
|
+
"@ez4/aws-identity": "^0.42.0",
|
|
48
|
+
"@ez4/aws-logs": "^0.42.0",
|
|
49
|
+
"@ez4/aws-vpc": "^0.42.0",
|
|
50
|
+
"@ez4/project": "^0.42.0",
|
|
51
|
+
"@ez4/common": "^0.42.0",
|
|
52
|
+
"@ez4/stateful": "^0.42.0",
|
|
53
|
+
"@ez4/utils": "^0.42.0",
|
|
53
54
|
"@types/adm-zip": "^0.5.5",
|
|
54
55
|
"adm-zip": "^0.5.14"
|
|
55
56
|
}
|