You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are 5 deployment options for deploying the tool using Infrastructure as Code (IaC).
4
4
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.
6
5
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)
11
11
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)
19
12
20
13
Read more about the [deployment parameters here](README-INPUT-OUTPUT.md#state-machine-configuration-at-deployment-time).
21
14
@@ -28,12 +21,15 @@ You can also integrate the SAR app in your existing CloudFormation stacks - chec
28
21
29
22
## Option 2: Build and deploy with the AWS SAM CLI<aname="option2"></a>
30
23
24
+
**Note**: This method requires Docker.
25
+
31
26
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).
32
27
33
28
1. Configure your [AWS credentials (requires AWS CLI installed)](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html#cli-quick-configuration):
@@ -45,24 +41,40 @@ You can also integrate the SAR app in your existing CloudFormation stacks - chec
45
41
```
46
42
[`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 functionwould run in. SAM build in-turn looks at your AWS SAM template file forinformation about Lambda functions and layersin this project.
47
43
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:
50
46
```bash
51
47
$ sam deploy -g
52
48
```
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 forthe '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 toolin and then you can selectthe 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.
54
55
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.
56
57
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.
58
64
59
65
60
66
## Option 3: Deploy the AWS SAR app with AWS CDK<a name="option3"></a>
61
67
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):
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
66
78
$ aws configure
67
79
```
68
80
@@ -83,34 +95,21 @@ You can also integrate the SAR app in your existing CloudFormation stacks - chec
83
95
})
84
96
```
85
97
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 sourcein this repo. See the following pages for language-specific instructions.
87
99
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)
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)
See the [Csharp instructions](cdk/csharp/README.md)
112
111
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>
114
113
115
114
Simply add the `aws_serverlessapplicationrepository_cloudformation_stack` resource below to your Terraform code and deploy as usual through `terraform apply`.
116
115
@@ -137,11 +136,11 @@ See the [Terraform documentation](https://registry.terraform.io/providers/hashic
137
136
138
137
If you don't yet have a Terraform project, check out the [Terraform introduction](https://www.terraform.io/intro/index.html).
139
138
140
-
## Option 6: deploy natively with Terraform<a name="option6"></a>
139
+
## Option 5: Deploy natively with Terraform<a name="option5"></a>
141
140
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).
143
142
144
143
145
-
## How to execute the state machine once deployed?
144
+
## How to execute the state machine once deployed
146
145
147
-
See [here](README-EXECUTE.md).
146
+
See the [execution](README-EXECUTE.md) instructions to run the state machine.
Copy file name to clipboardExpand all lines: README-EXECUTE.md
+2-14
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# How to execute the state machine
2
2
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.
4
4
5
5
## Option 1: Execute the state machine programmatically (CLI)
6
6
@@ -10,13 +10,7 @@ Feel free to customize the `scripts/sample-execution-input.json`, and then run `
10
10
11
11
The script will start a state machine execution, wait for the execution to complete (polling), and then show the execution results.
12
12
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)
20
14
21
15
Once the state machine is deployed, you can execute it and provide an input object.
22
16
@@ -41,10 +35,4 @@ Click "**Start Execution**" again and the execution will start. In the next page
41
35
42
36
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.
43
37
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).
Copy file name to clipboardExpand all lines: README-INPUT-OUTPUT.md
+22-19
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,28 @@
3
3
Each execution of the state machine will require an input and will provide the corresponding output.
4
4
5
5
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
+
6
28
## State machine input (at execution time)
7
29
8
30
The state machine accepts the following input parameters:
@@ -25,25 +47,6 @@ The state machine accepts the following input parameters:
25
47
***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.
26
48
***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.
27
49
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.
Optionally, you could deploy your own custom visualization tool and configure the CloudFormation Parameter named `visualizationURL` with your own URL.
90
90
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.
Power Tuner UI repository: [mattymoomoo/aws-power-tuner-ui](https://github.com/mattymoomoo/aws-power-tuner-ui)
98
-
99
91
## Additional features, considerations, and internals
100
92
101
93
[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