Giter Club home page Giter Club logo

mattymoomoo / aws-power-tuner-ui Goto Github PK

View Code? Open in Web Editor NEW
200.0 5.0 22.0 2.81 MB

AWS Lambda Power Tuner UI is an open source project creating a deployable easy to use website built on a layered technology stack allowing you to optimize your Lambda functions for cost and/or performance in a data-driven way via an easy to use UI.

License: Apache License 2.0

JavaScript 4.82% TypeScript 68.11% HTML 26.21% SCSS 0.86%
aws aws-lambda serverless stepfunctions state-machine cost performance visualization user-interface ui

aws-power-tuner-ui's Introduction

AWS Lambda Power Tuner UI

GitHub license Maintenance GitHub issues Open Source Love svg2

AWS Lambda Power Tuner UI is a deployable easy to use website built on a layered technology stack allowing you to optimize your Lambda functions for cost and/or performance in a data-driven way.

By using a user interface instead of worrying about IAM users, CLI commands, Amazon API Gateway etc, developers can run Lambda power tuning much easier and more consistently in a matter of seconds.

Read about how this project started on medium

Website

Once deployed into your AWS account, developers need to know only the ARN of the lambda and tweak the various settings to their own liking and simply click Start power tuner.

The foundation uses Alex Casalboni's Lambda Power Tuning state machine powered by AWS Step Functions.

This solution abstracts away the implementation of the tuner through the simplicity of AWS CDK and lowers the barrier of entry to this essential activity

How do you deploy and run the website in your AWS account?

You can deploy the solution to your AWS account using the following easy steps:

Git clone and install node modules

Clone down the repo and install the modules in both folders

git clone https://github.com/mattymoomoo/aws-power-tuner-ui.git

cd aws-power-tuner-ui/website
npm install

cd ../cdk
npm install

Deploy tuning infrastructure

Run the following command in the cdk directory to deploy the infrastructure:

npm run deploy-infra

Note: This will create a folder called website-output which is required for the website infrastructure and deploy the tuning infrastructure.

Once the infrastructure is deployed, the Amazon API Gateway endpoint will be made available as a CDK stack output:

Outputs:

NAME = https://UNIQUE_ID.execute-api.REGION.amazonaws.com/development

Copy this value and update the apiGatewayBaseUrl prod (without ending slash) environment variable within the website/src/environments/environment.prod.ts file. This will tell the angular app where to execute the power tuner:

export const environment = {
  apiGatewayBaseUrl: 'https://UNIQUE_ID.execute-api.REGION.amazonaws.com/development',
  production: true,
};

Once the endpoint is updated in the prod environment file, build the website to create the static files to be used for deployment:

Note: Make sure to run the below command in the website/ directory

npm run build

Deploy the website infrastructure

Once the website is built, run the following command in the cdk directory to deploy the website infrastructure:

If you have never deployed a CDK app to your AWS account, you need to first deploy static assets:

# Replace ACCOUNT_ID with your account ID, REGION with the region you're working in
npm run cdk bootstrap aws://ACCOUNT_ID/REGION

If you don't run this, the deploy-website operation below will report the error

PowerTunerWebsiteStack failed: Error: This stack uses assets, so the toolkit stack must be deployed to the environment

npm run deploy-website

And that is it ... you will now have a deployed website which the url will be visible in the stack output which can communicate with the deployed infrastructure.

Once deployed into your AWS account, developers need to know only the ARN of the lambda and tweak the various settings to their own liking and simply click Start power tuner:

Website

The tuner will generate a visualisation of average cost and speed for each power configuration using Matteo's tool and shows the recommended memory based on the selected strategy including average cost & duration.

Visualisation

Extra: Do you need an example Lambda function to run?

An example Hello Lambda function has been included for you to test out the tuner to verify all the parts are connected and working as expected.

To deploy the Lambda function, simple run inside the cdk directory:

npm run deploy-lambda

You can now grab the ARN of the deployed Lambda function and run the tuner.

What does the deployed architecture look like?

The architecture is as follows:

  • Angular 9 website fronted via Amazon CloudFront & Amazon S3
  • Amazon API Gateway using direct integrations to AWS Step functions
  • Alex Casalboni's Power Tuning State Machine

Architecture

Contribution

Feature requests and pull requests are more than welcome!

aws-power-tuner-ui's People

Contributors

calh avatar dependabot[bot] avatar matthewdorrian avatar mattymoomoo avatar micksatana avatar rsioss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aws-power-tuner-ui's Issues

Deploy infra - yargs do not define a valid target for node version 13.x

When using node version 13.x and running npm run deploy-infra in the cdk dir following error is display

Package exports for '/home/savnik/blackbird/aws-power-tuner-ui/cdk/node_modules/aws-cdk/node_modules/yargs' do not define a valid '.' target

In the cdk folder the error is originating from npx cdk deploy PowerTunerInfraStack

Steps to reproduce:

  1. Clone the latest master
  2. cd to website-output and run npm install
  3. cd to cdk and run npm install
  4. Still in cdk run npm run deploy-infra
  5. See error message as stated above

Node version: 13.1.0

Quick fix:
Use version 12.x

How do you specify --profile?

For us CloudFormation old-timer, can you profile instructions on how to provide a profile via the usual --profile flag.

I thought possibly:

npm run deploy-infra --profile teacherseat

or possibly:

PROFILE=teacherseat npm run deploy-infra

cloudformation permissions issue when attempting to run `npm run deploy-infra`

Currently when I try to run deploy-infra from the cdk directory, I get this error:

User: arn:aws:iam::482324516790:user/[email protected] is not authorized to perform: cloudformation:DescribeStacks on resource: arn:aws:cloudformation:us-east-1:482324516790:stack/PowerTunerInfraStack/* because no identity-based policy allows the cloudformation:DescribeStacks action

is this related to my companies policy? Just seemed odd since it traced to a power tuner AWS arn

Installation failing due to missing website/dist/power-tuner-ui

Hello.

Can you please look at below output?
It seems that installation script refers to non existing directory website/dist/power-tuner-ui


~/PycharmProjects/GitHub/aws-power-tuner-ui/cdk  on master !2 ?1  npm run deploy-infra                                                                                           ✔  took 40s  at 12:50:23 

[email protected] deploy-infra /home/tom/PycharmProjects/GitHub/aws-power-tuner-ui/cdk
cdk deploy PowerTunerInfraStack

ENOENT: no such file or directory, stat '/home/tom/PycharmProjects/GitHub/aws-power-tuner-ui/website/dist/power-tuner-ui'
Subprocess exited with error 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] deploy-infra: `cdk deploy PowerTunerInfraStack`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] deploy-infra script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/tom/.npm/_logs/2020-09-18T10_50_46_110Z-debug.log
 ~/PycharmProjects/GitHub/aws-power-tuner-ui/cdk  on master !2 ?1  pwd                                                                                                           1 ✘  took 7s  at 12:50:46 
/home/tom/PycharmProjects/GitHub/aws-power-tuner-ui/cdk
 ~/PycharmProjects/GitHub/aws-power-tuner-ui/cdk  on master !2 ?1  ls web                                                                                                                    ✔  at 12:52:33 
 ~/PycharmProjects/GitHub/aws-power-tuner-ui/cdk  on master !2 ?1  ls -la                                                                                                                INT ✘  at 12:52:46 
total 640
drwxrwxr-x   7 tom tom   4096 wrz 18 12:50 .
drwxrwxr-x   6 tom tom   4096 wrz 18 12:47 ..
drwxrwxr-x   2 tom tom   4096 wrz 18 12:47 bin
-rw-rw-r--   1 tom tom    166 wrz 18 12:47 cdk.json
drwxrwxr-x   2 tom tom   4096 wrz 18 12:50 cdk.out
-rw-rw-r--   1 tom tom    135 wrz 18 12:47 .gitignore
-rw-rw-r--   1 tom tom    130 wrz 18 12:47 jest.config.js
drwxrwxr-x   2 tom tom   4096 wrz 18 12:47 lib
drwxrwxr-x 389 tom tom  16384 wrz 18 12:50 node_modules
-rw-rw-r--   1 tom tom     65 wrz 18 12:47 .npmignore
-rw-rw-r--   1 tom tom   1462 wrz 18 12:50 package.json
-rw-rw-r--   1 tom tom 567002 wrz 18 12:50 package-lock.json
-rw-rw-r--   1 tom tom    543 wrz 18 12:47 README.md
-rw-rw-r--   1 tom tom  14973 wrz 18 12:47 template.yml
drwxrwxr-x   2 tom tom   4096 wrz 18 12:47 test
-rw-rw-r--   1 tom tom    598 wrz 18 12:47 tsconfig.json
 ~/PycharmProjects/GitHub/aws-power-tuner-ui/cdk  on master !2 ?1  ls ../                                                                                                                    ✔  at 12:52:51 
cdk  imgs  LICENSE.txt  README.md  website
 ~/PycharmProjects/GitHub/aws-power-tuner-ui/cdk  on master !2 ?1  ls ../website/dist/power-tuner-ui                                                                                         ✔  at 12:52:54 
ls: cannot access '../website/dist/power-tuner-ui': No such file or directory
 ~/PycharmProjects/GitHub/aws-power-tuner-ui/cdk  on master !2 ?1  ls ../website/                                                                                                          2 ✘  at 12:53:05 
angular.json  browserslist  e2e  karma.conf.js  node_modules  package.json  package-lock.json  README.md  src  tsconfig.app.json  tsconfig.json  tsconfig.spec.json  tslint.json
 ~/PycharmProjects/GitHub/aws-power-tuner-ui/cdk  on master !2 ?1                                                                                                                            ✔  at 12:53:09 


Tuner results in error

Hi,

I already did some debugging. I think it's do to this change: https://aws.amazon.com/blogs/compute/coming-soon-expansion-of-aws-lambda-states-to-all-functions/

Cloudwatch error:

2021-11-25T07:20:03.843Z 687c79de-4a49-4dbb-b3cf-8302354ff3ac ERROR Invoke Error { "errorType": "ResourceConflictException", "errorMessage": "The operation cannot be performed at this time. An update is in progress for resource: arn:aws:lambda:eu-west-1:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "code": "ResourceConflictException", "message": "The operation cannot be performed at this time. An update is in progress for resource: arn:aws:lambda:eu-west-1:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "time": "2021-11-25T07:20:03.842Z", "requestId": "c63773db-f777-4379-9f33-7229708e555d", "statusCode": 409, "retryable": false, "retryDelay": 21.75168710443578, "stack": [ "ResourceConflictException: The operation cannot be performed at this time. An update is in progress for resource: arn:aws:lambda:eu-west-1:647702511981:function:GatewayService-Monitoring-Tools-dev-Update_LambdaReferences", " at Object.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:52:27)", " at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/rest_json.js:55:8)", " at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)", " at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)", " at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:688:14)", " at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)", " at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)", " at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10", " at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)", " at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:690:12)" ] }

Previous Clouwatch log line:

2021-11-25T07:20:03.843Z 687c79de-4a49-4dbb-b3cf-8302354ff3ac INFO error during config creation for value 128

Input:

image

Kind regard,

Ruurd

Permission boundary support

Do we have option to specify permission boundary ?

source: arn:aws:iam::143384653512:role/PowerTunerWebsiteStack-CustomCDKBucketDeployment86-1K0D6JG63Y5UY because no permissions boundary allows the iam:CreateRole act
ion

URL for the tool after installation

I'm not well versed with npm, where is the to access the UI? The restAPIendpoint gives me a missing auth token error (but I don't think I'm supposed to access that directly). port :8080 on the machine doesn't have anything running. I think everything is installed ok but I just can't seem to find where to access the UI...

Install errors

Hi,

following the install guide i get errors trying to run the npm install in the cdk folder

cd website/
stephen@navi:/mnt/e/aws-power-tuner-ui/website$ npm install

added 1297 packages, and audited 1297 packages in 3m

11 vulnerabilities (9 low, 2 high)

To address issues that do not require attention, run:   
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
npm notice 
npm notice New minor version of npm available! 7.0.15 -> 7.5.3
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.5.3
npm notice Run npm install -g [email protected] to update!
npm notice

cd ../cdk
stephen@navi:/mnt/e/aws-power-tuner-ui/cdk$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/jest
npm ERR!   dev jest@"^25.5.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer jest@"^26.4.2" from @aws-cdk/[email protected]
npm ERR! node_modules/@aws-cdk/assert
npm ERR!   dev @aws-cdk/assert@"1.65.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/stephen/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/stephen/.npm/_logs/2021-02-11T10_31_09_224Z-debug.log

npm debug.log

$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
0 verbose cli [
0 verbose cli   '/home/linuxbrew/.linuxbrew/Cellar/node/15.4.0/bin/node',
0 verbose cli   '/home/linuxbrew/.linuxbrew/bin/npm',
0 verbose cli   'install'
0 verbose cli ]
1 info using [email protected]
2 info using [email protected]
3 timing config:load:defaults Completed in 2ms
4 timing config:load:file:/home/linuxbrew/.linuxbrew/lib/node_modules/npm/npmrc Completed in 3ms
5 timing config:load:builtin Completed in 4ms
6 timing config:load:cli Completed in 2ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/mnt/e/aws-power-tuner-ui/cdk/.npmrc Completed in 1ms
9 timing config:load:project Completed in 3ms
10 timing config:load:file:/home/stephen/.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:/home/linuxbrew/.linuxbrew/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 1ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
"~/.npm/_logs/2021-02-11T10_31_09_224Z-debug.log" 86L, 5069C 

Error with cdk version

Hello.

I´m trying to deploy in my AWS account here, but I get error with CDK version.

`
Do you wish to deploy these changes (y/n)? y
PowerTunerInfraStack: deploying...
PowerTunerInfraStack: creating CloudFormation changeset...

❌ PowerTunerInfraStack failed: Error: Failed to create ChangeSet cdk-deploy-change-set on PowerTunerInfraStack: FAILED, Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [powerTuner] is invalid. User: arn:aws:sts::521916331075:assumed-role/AWSReservedSSO_Developers-1_f6c82285d21ec261/[email protected] is not authorized to perform: serverlessrepo:CreateCloudFormationTemplate on resource: arn:aws:serverlessrepo:us-east-1:451282441545:applications/aws-lambda-power-tuning
at C:\Users\rafael.barioni\git\aws-power-tuner-ui\cdk\node_modules\aws-cdk\lib\api\util\cloudformation.ts:265:11
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at waitFor (C:\Users\rafael.barioni\git\aws-power-tuner-ui\cdk\node_modules\aws-cdk\lib\api\util\cloudformation.ts:220:20)
at waitForChangeSet (C:\Users\rafael.barioni\git\aws-power-tuner-ui\cdk\node_modules\aws-cdk\lib\api\util\cloudformation.ts:251:15)
at prepareAndExecuteChangeSet (C:\Users\rafael.barioni\git\aws-power-tuner-ui\cdk\node_modules\aws-cdk\lib\api\deploy-stack.ts:337:32)
at CdkToolkit.deploy (C:\Users\rafael.barioni\git\aws-power-tuner-ui\cdk\node_modules\aws-cdk\lib\cdk-toolkit.ts:209:24)
at initCommandLine (C:\Users\rafael.barioni\git\aws-power-tuner-ui\cdk\node_modules\aws-cdk\lib\cli.ts:341:12)

NOTICES

19836 AWS CDK v1 has entered maintenance mode

    Overview: AWS CDK v1 has entered maintenance mode on June 1, 2022.
              Migrate to AWS CDK v2 to continue to get the latest features
              and fixes!

    Affected versions: framework: 1.*, cli: 1.*

`

I´m not very familiar with Node code.
How could I solve this issue, please?

Thanks a lot

Feature Request: Extend the tuning to upto 10GB memory

As it was recently announced that a lambda container can be created with up to 10GB of memory, it would great to see it reflect in this tool.

In the app component, I tried editing the max from 30008 to 10240

getPowerValues() {
    const increment = 64;
    const powerValues = [];
    for (let value = 128; value <= 10240; value += increment) {
      powerValues.push(value);
    }
    return powerValues;
  }

The UI shows all options with 64MB increments and even the lambda gets executed with more than 3008 MB memory, but the final result where it should show the graph comparing cost vs execution time, it threw the following error.

image

It feels like the changes must be made on Matteo's tool, but I received the error on the UI so adding this feature request here.

After install - refused to connect error msg ...

After "sucessfull installation", I get refused to connect using https://<>/development ....
Installation without any erorr messages but needed to use #10)
npm install --legacy-peer-deps

How to check what is blocking?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.