Skip to content

Commit c57955e

Browse files
committed
Deployment instruction revisions, removed references to UI and Lumigo
1 parent 6272a6b commit c57955e

File tree

6 files changed

+94
-104
lines changed

6 files changed

+94
-104
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
node_modules
66
jspm_packages
77
venv
8+
.venv
89
coverage
910
.nyc_output
1011

@@ -22,3 +23,9 @@ layer-sdk/src
2223
# ignore SAM CLI created files/dirs
2324
.aws-sam/
2425
samconfig.toml
26+
27+
# ignore terraform created files/dirs
28+
.terraform/
29+
.terraform.*
30+
*.tfstate*
31+
cid.log

README-DEPLOY.md

+47-48
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
# How to deploy the AWS Lambda Power Tuning tool
22

3-
There are multiple options to deploy the tool.
3+
There are 5 deployment options for deploying the tool using Infrastructure as Code (IaC).
44

5-
If you are familiar with Infrastructure as Code, there are 4 ways for you to create all of the resources necessary for Lambda Power Tuning.
65

7-
The following three options utilize [AWS CloudFormation](https://aws.amazon.com/cloudformation/) on your behalf to create the necessary resources. Each will create a new CloudFormation stack in your AWS account containing all the resources for the Lambda Power Tuning tool.
8-
1. The easiest way is to [deploy the app via the AWS Serverless Application Repository (SAR)](#option1)
9-
1. Manually [using the AWS SAM CLI](#option2)
10-
1. Manually [using the AWS CDK](#option3)
6+
1. The easiest way is to [deploy the app via the AWS Serverless Application Repository (SAR)](#option1).
7+
1. [Using the AWS SAM CLI](#option2)
8+
1. [Using the AWS CDK](#option3)
9+
1. [Using Terraform by Hashicorp and SAR](#option4)
10+
1. [Using native Terraform](#option5)
1111

12-
You can also [deploy manually with Terraform](#option5) by Hashicorp.
13-
14-
If you want to use Terraform natively (which circumvents Cloudformation), see [Option 6](#option6)
15-
16-
If you don't want to deal with any Infrastructure as Code tool, you can use one of the following:
17-
1. The [Lumigo CLI](https://www.npmjs.com/package/lumigo-cli#lumigo-cli-powertune-lambda) (WARNING: deprecated)
18-
1. The [Lambda Power Tuner UI](#option4)
1912

2013
Read more about the [deployment parameters here](README-INPUT-OUTPUT.md#state-machine-configuration-at-deployment-time).
2114

@@ -28,12 +21,15 @@ You can also integrate the SAR app in your existing CloudFormation stacks - chec
2821

2922
## Option 2: Build and deploy with the AWS SAM CLI<a name="option2"></a>
3023

24+
**Note**: This method requires Docker.
25+
3126
1. Install the [AWS SAM CLI in your local environment](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html).
3227

3328
1. Configure your [AWS credentials (requires AWS CLI installed)](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html#cli-quick-configuration):
3429
```bash
3530
$ aws configure
3631
```
32+
1. Install [Docker](https://docs.docker.com/get-docker/).
3733
1. Clone this git repository:
3834
```bash
3935
$ git clone https://github.com/alexcasalboni/aws-lambda-power-tuning.git
@@ -45,24 +41,40 @@ You can also integrate the SAR app in your existing CloudFormation stacks - chec
4541
```
4642
[`sam build -u`](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-build.html) will run SAM build using a Docker container image that provides an environment similar to that which your function would run in. SAM build in-turn looks at your AWS SAM template file for information about Lambda functions and layers in this project.
4743

48-
Once the build has completed you should see output that states `Build Succeeded`. If not there will be error messages providing guidance on what went wrong.
49-
1. Deploy the application using the SAM deploy "guided" mode:
44+
Once the build completes successfully you will see output stating `Build Succeeded`. If the build is not successful, there will be error messages providing guidance on what went wrong.
45+
1. Deploy the application using the guided SAM deploy mode:
5046
```bash
5147
$ sam deploy -g
5248
```
53-
[`sam deploy -g`](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-deploy.html) will provide simple prompts to walk you through the process of deploying the tool. Provide a unique name for the 'Stack Name' and supply the [AWS Region](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html#Concepts.RegionsAndAvailabilityZones.Regions) you want to run the tool in and then you can select the defaults for testing of this tool. After accepting the prompted questions with a "Y" you can optionally save your application configuration.
49+
* For **Stack Name**, enter a unique name for the stack.
50+
* For **AWS Region**, enter the region you want to deploy in.
51+
52+
Accept the defaults for all other prompts.
53+
54+
[`sam deploy -g`](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-deploy.html) provides simple prompts to walk you through the process of deploying the tool. The responses are saved in a configuration file, `samconfig.toml`, to be reused during subsequent deployments.
5455

55-
After that the SAM CLI will run the required commands to create the resources for the Lambda Power Tuning tool. The CloudFormation outputs shown will highlight any issues or failures.
56+
SAM CLI will run the required commands to create the resources for the Lambda Power Tuning tool.
5657

57-
If there are no issues, once complete you will see the stack outputs and a `Successfully created/updated stack` message.
58+
A successful deployment displays the message `Successfully created/updated stack`.
59+
1. To delete Lambda Power Tuning, run
60+
```bash
61+
sam delete
62+
```
63+
Answer `Y` to the prompts.
5864

5965

6066
## Option 3: Deploy the AWS SAR app with AWS CDK<a name="option3"></a>
6167

62-
1. [Install AWS CDK](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html) and [configure your AWS credentials](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html#cli-quick-configuration):
63-
68+
1. [Install AWS CDK](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html).
6469
```bash
6570
$ npm install -g aws-cdk
71+
```
72+
73+
1. [Bootstrap](https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html#getting_started_bootstrap) your account.
74+
75+
1. [Configure your AWS credentials](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html#cli-quick-configuration):
76+
77+
```bash
6678
$ aws configure
6779
```
6880

@@ -83,34 +95,21 @@ You can also integrate the SAR app in your existing CloudFormation stacks - chec
8395
})
8496
```
8597

86-
Alternatively, you can use [CDK Patterns](https://github.com/cdk-patterns/serverless) to give you a pre configured project in either TypeScript or Python:
98+
Alternatively, you can build and deploy the solution from the source in this repo. See the following pages for language-specific instructions.
8799

88-
```bash
89-
# For the TypeScript CDK version
90-
npx cdkp init the-lambda-power-tuner
100+
### TypeScript
101+
See the [Typescript instructions](cdk/typescript/README.md)
91102

92-
# or for the Python CDK version
93-
npx cdkp init the-lambda-power-tuner --lang=python
94-
```
95-
96-
1. To deploy the TypeScript version you just need to:
97-
98-
```bash
99-
cd the-lambda-power-tuner
100-
npm run deploy
101-
```
102-
103-
For Python deployment, see the instructions [here](https://github.com/cdk-patterns/serverless#2-download-pattern-in-python-or-typescript-cdk).
104-
105-
## Option 4: Deploy via AWS Lambda Power Tuner UI<a name="option4"></a>
106-
107-
You can deploy and interact with Lambda Power Tuning with an ad-hoc web interface. This UI will deploy everything you need to power-tune your functions and also simplify the input/output management for Step Functions via API Gateway.
108-
109-
You can find the open-source project and the instructions to deploy it here: [mattymoomoo/aws-power-tuner-ui](https://github.com/mattymoomoo/aws-power-tuner-ui).
103+
### Python
104+
See the [Python instructions](cdk/python/README.md)
105+
106+
### go
107+
See the [go instructions](cdk/go/README.md)
110108

111-
![Power Tuner UI](https://github.com/mattymoomoo/aws-power-tuner-ui/blob/master/imgs/website.png?raw=true)
109+
### C\#
110+
See the [Csharp instructions](cdk/csharp/README.md)
112111

113-
## Option 5: Deploy the SAR app with Terraform<a name="option5"></a>
112+
## Option 4: Deploy the SAR app with Terraform<a name="option4"></a>
114113

115114
Simply add the `aws_serverlessapplicationrepository_cloudformation_stack` resource below to your Terraform code and deploy as usual through `terraform apply`.
116115

@@ -137,11 +136,11 @@ See the [Terraform documentation](https://registry.terraform.io/providers/hashic
137136

138137
If you don't yet have a Terraform project, check out the [Terraform introduction](https://www.terraform.io/intro/index.html).
139138
140-
## Option 6: deploy natively with Terraform<a name="option6"></a>
139+
## Option 5: Deploy natively with Terraform<a name="option5"></a>
141140
142-
Please see the documentation [here](terraform/Readme.md).
141+
The Terraform modules are located in the [terraform](terraform) directory. Deployment documentation is [here](terraform/Readme.md).
143142
144143
145-
## How to execute the state machine once deployed?
144+
## How to execute the state machine once deployed
146145
147-
See [here](README-EXECUTE.md).
146+
See the [execution](README-EXECUTE.md) instructions to run the state machine.

README-EXECUTE.md

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# How to execute the state machine
22

3-
Independently of how you've deployed the state machine, you can execute it in a few different ways. Programmatically, using the AWS CLI, AWS SDK, or Lumigo CLI. Manually, using the AWS Step Functions web console or the Lambda Power Tuner UI.
3+
Independently of how you've deployed the state machine, you can execute it in a few different ways. Programmatically, using the AWS CLI, or AWS SDK. Manually, using the AWS Step Functions web console.
44

55
## Option 1: Execute the state machine programmatically (CLI)
66

@@ -10,13 +10,7 @@ Feel free to customize the `scripts/sample-execution-input.json`, and then run `
1010

1111
The script will start a state machine execution, wait for the execution to complete (polling), and then show the execution results.
1212

13-
## Option 2: Execute the state machine programmatically (Lumigo CLI)
14-
15-
The Lumigo CLI integration takes care of both deploying and executing the SAR app transparently.
16-
17-
Check it out [here](README-DEPLOY.md#user-content-option-4-deploy-with-the-lumigo-cli).
18-
19-
## Option 3: Execute the state machine manually (web console)
13+
## Option 2: Execute the state machine manually (web console)
2014

2115
Once the state machine is deployed, you can execute it and provide an input object.
2216

@@ -41,10 +35,4 @@ Click "**Start Execution**" again and the execution will start. In the next page
4135

4236
Once the execution has completed, you will find the execution results in the "**Output**" tab of the "**Execution Details**" section at the top of the page. The output will contain the optimal power configuration and its corresponding average cost per execution.
4337

44-
## Option 4: Execute the state machine manually (AWS Lambda Power Tuner UI)
45-
46-
You can deploy and interact with Lambda Power Tuning with an ad-hoc web interface. This UI will deploy everything you need to power-tune your functions and also simplify the input/output management for Step Functions via API Gateway.
47-
48-
You can find the open-source project and the instructions to deploy it here: [mattymoomoo/aws-power-tuner-ui](https://github.com/mattymoomoo/aws-power-tuner-ui).
4938

50-
![Power Tuner UI](https://github.com/mattymoomoo/aws-power-tuner-ui/blob/master/imgs/website.png?raw=true)

README-INPUT-OUTPUT.md

+22-19
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@
33
Each execution of the state machine will require an input and will provide the corresponding output.
44

55

6+
## Deployment configuration options
7+
8+
The CloudFormation template accepts the following parameters:
9+
10+
* **PowerValues** (list of numbers): these power values will be used as the default in case no `powerValues` input parameter is provided at execution time
11+
* **visualizationURL** (string): the base URL for the visualization tool, by default it's `lambda-power-tuning.show` but you could use your own custom tool
12+
* **totalExecutionTimeout** (number in seconds, default=`300`): the timeout in seconds applied to all functions of the state machine
13+
* **lambdaResource** (string, default=`*`): the `Resource` used in IAM policies; it's `*` by default but you could restrict it to a prefix or a specific function ARN
14+
* **permissionsBoundary** (string): the ARN of a permissions boundary (policy), applied to all functions of the state machine
15+
* **payloadS3Bucket** (string): the S3 bucket name used for large payloads (>256KB); if provided, it's added to a custom managed IAM policy that grants read-only permission to the S3 bucket; more details below in the [S3 payloads section](#user-content-s3-payloads)
16+
* **payloadS3Key** (string, default=`*`): the S3 object key used for large payloads (>256KB); the default value grants access to all S3 objects in the bucket specified with `payloadS3Bucket`; more details below in the [S3 payloads section](#user-content-s3-payloads)
17+
* **layerSdkName** (string): the name of the SDK layer, in case you need to customize it (optional)
18+
* **logGroupRetentionInDays** (number, default=7): the number of days to retain log events in the Lambda log groups. Before this parameter existed, log events were retained indefinitely
19+
* **securityGroupIds** (list of SecurityGroup IDs): List of Security Groups to use in every Lambda function's VPC Configuration (optional); please note that your VPC should be configured to allow public internet access (via NAT Gateway) or include VPC Endpoints to the Lambda service
20+
* **subnetIds** (list of Subnet IDs): List of Subnets to use in every Lambda function's VPC Configuration (optional); please note that your VPC should be configured to allow public internet access (via NAT Gateway) or include VPC Endpoints to the Lambda service
21+
* **stateMachineNamePrefix** (string, default=`powerTuningStateMachine`): Allows you to customize the name of the state machine. Maximum 43 characters, only alphanumeric (plus `-` and `_`). The last portion of the `AWS::StackId` will be appended to this value, so the full name will look like `powerTuningStateMachine-89549da0-a4f9-11ee-844d-12a2895ed91f`. Note: `StateMachineName` has a maximum of 80 characters and 36+1 from the `StackId` are appended, allowing 43 for a custom prefix.
22+
23+
24+
25+
Please note that the total execution time should stay below 300 seconds (5 min), which is the default timeout. You can easily estimate the total execution timeout based on the average duration of your functions. For example, if your function's average execution time is 5 seconds and you haven't enabled `parallelInvocation`, you should set `totalExecutionTimeout` to at least `num * 5`: 50 seconds if `num=10`, 500 seconds if `num=100`, and so on. If you have enabled `parallelInvocation`, usually you don't need to tune the value of `totalExecutionTimeout` unless your average execution time is above 5 min. If you have a sleep between invocations set, you should include that in your timeout calculations.
26+
27+
628
## State machine input (at execution time)
729

830
The state machine accepts the following input parameters:
@@ -25,25 +47,6 @@ The state machine accepts the following input parameters:
2547
* **disablePayloadLogs** (boolean) If provided and set to a truthy value, suppresses `payload` from error messages and logs. If `preProcessorARN` is provided, this also suppresses the output payload of the pre-processor.
2648
* **includeOutputResults** (boolean) If provided and set to true, the average cost and average duration for every power value configuration will be included in the state machine output.
2749

28-
## State machine configuration (at deployment time)
29-
30-
The CloudFormation template accepts the following parameters:
31-
32-
* **PowerValues** (list of numbers): these power values will be used as the default in case no `powerValues` input parameter is provided at execution time
33-
* **visualizationURL** (string): the base URL for the visualization tool, by default it's `lambda-power-tuning.show` but you could use your own custom tool
34-
* **totalExecutionTimeout** (number in seconds, default=`300`): the timeout in seconds applied to all functions of the state machine
35-
* **lambdaResource** (string, default=`*`): the `Resource` used in IAM policies; it's `*` by default but you could restrict it to a prefix or a specific function ARN
36-
* **permissionsBoundary** (string): the ARN of a permissions boundary (policy), applied to all functions of the state machine
37-
* **payloadS3Bucket** (string): the S3 bucket name used for large payloads (>256KB); if provided, it's added to a custom managed IAM policy that grants read-only permission to the S3 bucket; more details below in the [S3 payloads section](#user-content-s3-payloads)
38-
* **payloadS3Key** (string, default=`*`): the S3 object key used for large payloads (>256KB); the default value grants access to all S3 objects in the bucket specified with `payloadS3Bucket`; more details below in the [S3 payloads section](#user-content-s3-payloads)
39-
* **layerSdkName** (string): the name of the SDK layer, in case you need to customize it (optional)
40-
* **logGroupRetentionInDays** (number, default=7): the number of days to retain log events in the Lambda log groups. Before this parameter existed, log events were retained indefinitely
41-
* **securityGroupIds** (list of SecurityGroup IDs): List of Security Groups to use in every Lambda function's VPC Configuration (optional); please note that your VPC should be configured to allow public internet access (via NAT Gateway) or include VPC Endpoints to the Lambda service
42-
* **subnetIds** (list of Subnet IDs): List of Subnets to use in every Lambda function's VPC Configuration (optional); please note that your VPC should be configured to allow public internet access (via NAT Gateway) or include VPC Endpoints to the Lambda service
43-
* **stateMachineNamePrefix** (string, default=`powerTuningStateMachine`): Allows you to customize the name of the state machine. Maximum 43 characters, only alphanumeric (plus `-` and `_`). The last portion of the `AWS::StackId` will be appended to this value, so the full name will look like `powerTuningStateMachine-89549da0-a4f9-11ee-844d-12a2895ed91f`. Note: `StateMachineName` has a maximum of 80 characters and 36+1 from the `StackId` are appended, allowing 43 for a custom prefix.
44-
45-
46-
Please note that the total execution time should stay below 300 seconds (5 min), which is the default timeout. You can easily estimate the total execution timeout based on the average duration of your functions. For example, if your function's average execution time is 5 seconds and you haven't enabled `parallelInvocation`, you should set `totalExecutionTimeout` to at least `num * 5`: 50 seconds if `num=10`, 500 seconds if `num=100`, and so on. If you have enabled `parallelInvocation`, usually you don't need to tune the value of `totalExecutionTimeout` unless your average execution time is above 5 min. If you have a sleep between invocations set, you should include that in your timeout calculations.
4750

4851
### Usage in CI/CD pipelines
4952

README.md

-8
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,6 @@ Website repository: [matteo-ronchetti/aws-lambda-power-tuning-ui](https://github
8888

8989
Optionally, you could deploy your own custom visualization tool and configure the CloudFormation Parameter named `visualizationURL` with your own URL.
9090

91-
## Power Tuner UI
92-
93-
Lambda Power Tuner UI is a web interface to simplify the deployment and execution of Lambda Power Tuning. It's built and maintained by [Matthew Dorrian](https://twitter.com/DorrianMatthew) and it aims at providing a consistent interface and a uniform developer experience across teams and projects.
94-
95-
![Power Tuner UI](https://github.com/mattymoomoo/aws-power-tuner-ui/blob/master/imgs/website.png?raw=true)
96-
97-
Power Tuner UI repository: [mattymoomoo/aws-power-tuner-ui](https://github.com/mattymoomoo/aws-power-tuner-ui)
98-
9991
## Additional features, considerations, and internals
10092

10193
[Here](README-ADVANCED.md) you can find out more about some advanced features of this project, its internals, and some considerations about security and execution cost.

0 commit comments

Comments
 (0)