Skip to content

Commit 5c4a2e7

Browse files
committed
Add guardian rule pages to website and link to them from tool
1 parent 100f814 commit 5c4a2e7

File tree

14 files changed

+192
-8
lines changed

14 files changed

+192
-8
lines changed

docs/no-default-memory.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
id: no-default-memory
3+
title: no-default-memory
4+
sidebar_label: no-default-memory
5+
---
6+
7+
# No Functions Have Memory Configuration Left as Default (no-default-memory)
8+
9+
Lambda Functions memory is configurable and should be configured for the use-case.
10+
This can impact the speed and running cost of the Lambda Function.
11+
12+
> **Note:** Any increase in memory size triggers an equivalent increase in CPU available to your function
13+
14+
---
15+
16+
## Suggested Actions:
17+
18+
- Look into your CloudWatch Logs for the Lambda function to find `Max Memory Used` [more information](https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html)
19+
20+
```
21+
REPORT RequestId: 3604209a-e9a3-11e6-939a-754dd98c7be3 Duration: 12.34 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 18 MB
22+
```
23+
24+
- Power-tune using [aws-lambda-power-tuning](https://github.com/alexcasalboni/aws-lambda-power-tuning)

docs/no-default-timeout.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
id: no-default-timeout
3+
title: no-default-timeout
4+
sidebar_label: no-default-timeout
5+
---
6+
7+
# No Functions Have Timeout Configuration Left as Default (no-default-timeout)
8+
9+
Lambda Function timeout is configurable and should be configured for the use-case.
10+
This can impact timeout errors, running costs and security (e.g. "Denial of Wallet").
11+
The default is 3 seconds in AWS, but 6 with the Serverless Framework.
12+
The maximum allowed value is 900 seconds.
13+
14+
< 5 seconds is generally suitable for API endpoints.
15+
16+
> **Note:** API Gateway has a limit of 29 seconds.
17+
18+
---
19+
20+
## Suggested Actions:
21+
22+
- Look into your CloudWatch Logs for the Lambda function to find `Duration` ([more information](https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html))
23+
24+
```
25+
REPORT RequestId: 3604209a-e9a3-11e6-939a-754dd98c7be3 Duration: 12.34 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 18 MB
26+
```
27+
28+
- Power-tune using [aws-lambda-power-tuning](https://github.com/alexcasalboni/aws-lambda-power-tuning)
29+
> **Note:** Any increase in memory size triggers an equivalent increase in CPU available to your function, which can be useful in lowering timeout.

docs/no-identical-code.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
id: no-identical-code
3+
title: no-identical-code
4+
sidebar_label: no-identical-code
5+
---
6+
7+
# No Functions Have Identical Deployment Code (no-identical-code)
8+
9+
Lambda Function should have their code packaged optimally as it may affect cold start times.
10+
Also, deploying a monolithic codebase is not advised.
11+
12+
---
13+
14+
## Suggested Actions:
15+
16+
- Look at your deployment artifact to see if there is code that should be removed.
17+
- If you're using the Serverless Framework specify individual packaging [more info](https://www.serverless.com/framework/docs/providers/aws/guide/packaging/):
18+
19+
```
20+
service: my-service
21+
22+
package:
23+
individually: true
24+
25+
```
26+
27+
- Use the `serverless package` command if you use the serverless framework.
28+
- Look in the `.serverless` directory to see the deployment artifacts.

docs/no-max-memory.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
id: no-max-memory
3+
title: no-max-memory
4+
sidebar_label: no-max-memory
5+
---
6+
7+
# No Functions Have Memory Configuration To Maximum Limit (no-max-memory)
8+
9+
Lambda Functions memory is configurable and should be configured for the use-case.
10+
This can impact the speed and running cost of the Lambda Function.
11+
12+
> **Note:** Any increase in memory size triggers an equivalent increase in CPU available to your function
13+
14+
---
15+
16+
## Suggested Actions:
17+
18+
- Look into your CloudWatch Logs for the Lambda function to find `Max Memory Used` [more information](https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html)
19+
20+
```
21+
REPORT RequestId: 3604209a-e9a3-11e6-939a-754dd98c7be3 Duration: 12.34 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 18 MB
22+
```
23+
24+
- Power-tune using [aws-lambda-power-tuning](https://github.com/alexcasalboni/aws-lambda-power-tuning)

docs/no-max-timeout.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
id: no-max-timeout
3+
title: no-max-timeout
4+
sidebar_label: no-max-timeout
5+
---
6+
7+
# No Functions Have Timeout Configuration To Maximum Limit (no-max-timeout)
8+
9+
Lambda Function timeout is configurable and should be configured for the use-case.
10+
Having it set at the maximum is rarely appropriate, unless processing a lot of data.
11+
The default is 3 seconds in AWS, but 6 with the Serverless Framework.
12+
The maximum allowed value is 900 seconds.
13+
14+
Having it set at the maximum can allow inefficient code to be released, increased billed duration in case of code errors and can lead to expensive cloud bills via "Denial of Wallet" attacks.
15+
16+
< 5 seconds is generally suitable for API endpoints.
17+
18+
---
19+
20+
## Suggested Actions:
21+
22+
- Look into your CloudWatch Logs for the Lambda function to find `Duration` ([more information](https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html))
23+
24+
```
25+
REPORT RequestId: 3604209a-e9a3-11e6-939a-754dd98c7be3 Duration: 12.34 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 18 MB
26+
```
27+
28+
- Power-tune using [aws-lambda-power-tuning](https://github.com/alexcasalboni/aws-lambda-power-tuning)
29+
> **Note:** Any increase in memory size triggers an equivalent increase in CPU available to your function, which can be useful in lowering timeout.

docs/no-shared-roles.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
id: no-shared-roles
3+
title: no-shared-roles
4+
sidebar_label: no-shared-roles
5+
---
6+
7+
# No Functions Have Shared IAM Roles (no-shared-roles)
8+
9+
IAM Roles allow granular access control to be specified per function.
10+
To ensure least privilege, one role should be used per function so that the underlying policy can be configured correctly.
11+
12+
---
13+
14+
## Suggested Actions:
15+
16+
- Define one IAM Role per Function and configure them to ensure least privilege.
17+
- If you're using the Serverless Framework, you can use the [serverless-iam-roles-per-function](https://github.com/functionalone/serverless-iam-roles-per-function) plugin.

src/guardian/rules/best_practices/no-default-memory/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class NoDefaultMemory {
1010
this.failureMessage =
1111
"The following functions have their memory set as default.";
1212
this.rulePage =
13-
"See (https://github.com/Theodo-UK/sls-dev-tools/blob/guardian-ci/src/guardian/rules/best_practices/no-default-memory/no-default-memory.MD) for impact and how to to resolve.";
13+
"See (https://theodo-uk.github.io/sls-dev-tools/docs/no-default-memory) for impact and how to to resolve.";
1414
}
1515

1616
hasDefaultMemory(lambdaFunction) {

src/guardian/rules/best_practices/no-default-timeout/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class NoDefaultTimeout {
1111
this.failureMessage =
1212
"The following functions have their timeout set as default.";
1313
this.rulePage =
14-
"See (https://github.com/Theodo-UK/sls-dev-tools/blob/guardian-ci/src/guardian/rules/best_practices/no-default-timeout/no-default-timeout.MD) for impact and how to to resolve.";
14+
"See (https://theodo-uk.github.io/sls-dev-tools/docs/no-default-timeout) for impact and how to to resolve.";
1515
}
1616

1717
hasDefaultTimeout(lambdaFunction) {

src/guardian/rules/best_practices/no-identical-code/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class NoIdenticalCode {
99
this.failureMessage =
1010
"The following functions have identical deployment code repeated in 1 or more other functions.";
1111
this.rulePage =
12-
"See (https://github.com/Theodo-UK/sls-dev-tools/blob/guardian-ci/src/guardian/rules/best_practices/no-identical-code/no-identical-code.MD) for impact and how to to resolve.";
12+
"See (https://theodo-uk.github.io/sls-dev-tools/docs/no-identical-code) for impact and how to to resolve.";
1313
this.codeShasEncountered = {};
1414
}
1515

src/guardian/rules/best_practices/no-max-memory/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class NoMaximumMemory {
1010
this.failureMessage =
1111
"The following functions have their memory set to the maximum limit.";
1212
this.rulePage =
13-
"See (https://github.com/Theodo-UK/sls-dev-tools/blob/guardian-ci/src/guardian/rules/best_practices/no-max-memory/no-max-memory.MD) for impact and how to to resolve.";
13+
"See (https://theodo-uk.github.io/sls-dev-tools/docs/no-max-memory) for impact and how to to resolve.";
1414
}
1515

1616
hasMaximumMemory(lambdaFunction) {

src/guardian/rules/best_practices/no-max-timeout/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class NoMaximumTimeout {
1010
this.failureMessage =
1111
"The following functions have their timeout set as the maximum.";
1212
this.rulePage =
13-
"See (https://github.com/Theodo-UK/sls-dev-tools/blob/guardian-ci/src/guardian/rules/best_practices/no-max-timeout/no-max-timeout.MD) for impact and how to to resolve.";
13+
"See (https://theodo-uk.github.io/sls-dev-tools/docs/no-max-timeout) for impact and how to to resolve.";
1414
}
1515

1616
hasMaximumTimeout(lambdaFunction) {

src/guardian/rules/best_practices/no-shared-roles/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class NoSharedRoles {
99
this.failureMessage =
1010
"The following functions have roles used by 1 or more other functions.";
1111
this.rulePage =
12-
"See (https://github.com/Theodo-UK/sls-dev-tools/blob/guardian-ci/src/guardian/rules/best_practices/no-shared-roles/no-shared-roles.MD) for impact and how to to resolve.";
12+
"See (https://theodo-uk.github.io/sls-dev-tools/docs/no-shared-roles) for impact and how to to resolve.";
1313
this.IAMRolesEncountered = {};
1414
}
1515

website/i18n/en.json

+26-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,30 @@
55
"previous": "Previous",
66
"tagline": "Dev tools for the serverless world",
77
"docs": {
8+
"no-default-memory": {
9+
"title": "no-default-memory",
10+
"sidebar_label": "no-default-memory"
11+
},
12+
"no-default-timeout": {
13+
"title": "no-default-timeout",
14+
"sidebar_label": "no-default-timeout"
15+
},
16+
"no-identical-code": {
17+
"title": "no-identical-code",
18+
"sidebar_label": "no-identical-code"
19+
},
20+
"no-max-memory": {
21+
"title": "no-max-memory",
22+
"sidebar_label": "no-max-memory"
23+
},
24+
"no-max-timeout": {
25+
"title": "no-max-timeout",
26+
"sidebar_label": "no-max-timeout"
27+
},
28+
"no-shared-roles": {
29+
"title": "no-shared-roles",
30+
"sidebar_label": "no-shared-roles"
31+
},
832
"pricing": {
933
"title": "Cloudwatch Pricing",
1034
"sidebar_label": "Cloudwatch Pricing"
@@ -19,7 +43,8 @@
1943
},
2044
"categories": {
2145
"Installation and Use": "Installation and Use",
22-
"Pricing": "Pricing"
46+
"Pricing": "Pricing",
47+
"Guardian Rules": "Guardian Rules"
2348
}
2449
},
2550
"pages-strings": {

website/sidebars.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
{
22
"docs": {
33
"Installation and Use": ["README"],
4-
"Pricing": ["pricing"]
4+
"Pricing": ["pricing"],
5+
"Guardian Rules": [
6+
"no-max-timeout",
7+
"no-max-memory",
8+
"no-shared-roles",
9+
"no-identical-code",
10+
"no-default-memory",
11+
"no-default-timeout"
12+
]
513
}
614
}

0 commit comments

Comments
 (0)