• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

alexcasalboni / aws-lambda-power-tuning / 4345884293

pending completion
4345884293

Pull #194

github

GitHub
<a href="https://github.com/alexcasalboni/aws-lambda-power-tuning/commit/<a class=hub.com/alexcasalboni/aws-lambda-power-tuning/commit/fd841d1b72d65ce294bc101ff104ec12843c80b1">fd841d1b7<a href="https://github.com/alexcasalboni/aws-lambda-power-tuning/commit/fd841d1b72d65ce294bc101ff104ec12843c80b1">">Merge </a><a class="double-link" href="https://github.com/alexcasalboni/aws-lambda-power-tuning/commit/<a class="double-link" href="https://github.com/alexcasalboni/aws-lambda-power-tuning/commit/389479c42ba778034a9fcfb43f8e27461fb4145e">389479c42</a>">389479c42</a><a href="https://github.com/alexcasalboni/aws-lambda-power-tuning/commit/fd841d1b72d65ce294bc101ff104ec12843c80b1"> into 01d5277ec">01d5277ec</a>
Pull Request #194: Add sam build to GH actions

168 of 168 branches covered (100.0%)

Branch coverage included in aggregate %.

453 of 453 relevant lines covered (100.0%)

51.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/lambda/initializer.js
1
'use strict';
2

3
const utils = require('./utils');
1✔
4
const defaultPowerValues = process.env.defaultPowerValues.split(',');
1✔
5

6
/**
7
 * Initialize versions & aliases so we can execute everything in parallel.
8
 */
9
module.exports.handler = async(event, context) => {
1✔
10

11
    const {lambdaARN, num} = event;
21✔
12
    const powerValues = extractPowerValues(event);
20✔
13

14
    validateInput(lambdaARN, num); // may throw
20✔
15

16
    // fetch initial $LATEST value so we can reset it later
17
    const initialPower = await utils.getLambdaPower(lambdaARN);
9✔
18

19
    // reminder: configuration updates must run sequentially
20
    // (otherwise you get a ResourceConflictException)
21
    for (let value of powerValues){
9✔
22
        const alias = 'RAM' + value;
71✔
23
        await utils.createPowerConfiguration(lambdaARN, value, alias);
71✔
24
    }
25

26
    await utils.setLambdaPower(lambdaARN, initialPower);
7✔
27

28
    return powerValues;
7✔
29
};
30

31
const extractPowerValues = (event) => {
1✔
32
    var powerValues = event.powerValues; // could be undefined
20✔
33

34
    // auto-generate all possible values if ALL
35
    if (powerValues === 'ALL') {
20✔
36
        powerValues = utils.allPowerValues();
1✔
37
    }
38

39
    // use default list of values (defined at deploy-time) if not provided
40
    if (!powerValues || powerValues.length === 0) {
20✔
41
        powerValues = defaultPowerValues;
18✔
42
    }
43

44
    return powerValues;
20✔
45
};
46

47
const validateInput = (lambdaARN, num) => {
1✔
48
    if (!lambdaARN) {
20✔
49
        throw new Error('Missing or empty lambdaARN');
5✔
50
    }
51
    if (!num || num < 5) {
15✔
52
        throw new Error('Missing num or num below 5');
6✔
53
    }
54
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc