MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / DecodeLambda

Function DecodeLambda

internal/pulumi/resources/aws/lambda.go:17–75  ·  view source on GitHub ↗

DecodeLambda splits a Lambda function into multiple pricing queries: - Requests (always) - Duration (always) - Ephemeral Storage Duration (when ephemeralStorage.size > 512 MB) Architecture (x86 vs ARM) selects the appropriate group variant.

(record resources.ResourceRecord, mapping api.PulumiResourceDef, region string, _ map[string]string, inputsJSON string)

Source from the content-addressed store, hash-verified

15//
16// Architecture (x86 vs ARM) selects the appropriate group variant.
17func DecodeLambda(record resources.ResourceRecord, mapping api.PulumiResourceDef, region string, _ map[string]string, inputsJSON string) []resources.DecodedResource {
18 arch := strings.ToLower(strings.TrimSpace(ExtractInput(record.Inputs, "architectures")))
19 isArm := arch == "arm64"
20
21 armSuffix := ""
22 if isArm {
23 armSuffix = "-ARM"
24 }
25
26 // Build clean props for Lambda — don't inherit attrs from the generic
27 // metadata loop (e.g. instanceType mapped from memorySize is misleading).
28 lambdaProps := map[string]string{"type": record.Type}
29 if arch != "" {
30 lambdaProps["architecture"] = arch
31 }
32 if v := ExtractInput(record.Inputs, "memorySize"); v != "" {
33 lambdaProps["memorySize"] = v + " MB"
34 }
35 if v := ExtractInput(record.Inputs, "timeout"); v != "" {
36 lambdaProps["timeout"] = v + "s"
37 }
38 if v := ExtractInput(record.Inputs, "runtime"); v != "" {
39 lambdaProps["runtime"] = v
40 }
41 if v := ExtractInput(record.Inputs, "ephemeralStorage.size"); v != "" {
42 lambdaProps["ephemeralStorage"] = v + " MB"
43 }
44
45 base := func(subLabel, group string) resources.DecodedResource {
46 return resources.DecodedResource{
47 Provider: mapping.Provider,
48 Region: region,
49 Service: mapping.Product,
50 Name: record.Name,
51 SubLabel: subLabel,
52 RawType: record.Type,
53 Attrs: map[string]string{"group": group, "servicecode": "AWSLambda"},
54 Props: lambdaProps,
55 InputsJSON: inputsJSON,
56 }
57 }
58
59 result := []resources.DecodedResource{
60 base("Requests", "AWS-Lambda-Requests"+armSuffix),
61 base("Duration", "AWS-Lambda-Duration"+armSuffix),
62 }
63
64 // Ephemeral storage beyond the free 512 MB incurs additional charges.
65 ephemeralSize := ExtractInput(record.Inputs, "ephemeralStorage.size")
66 if ephemeralSize != "" {
67 size := 0
68 fmt.Sscanf(ephemeralSize, "%d", &size)
69 if size > 512 {
70 result = append(result, base("Ephemeral Storage", "AWS-Lambda-Storage-Duration"+armSuffix))
71 }
72 }
73
74 return result

Callers

nothing calls this directly

Calls 1

ExtractInputFunction · 0.85

Tested by

no test coverage detected