-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
class UseArm { | ||
constructor(AWS, stackName, stackFunctions, SLS) { | ||
this.name = "use-arm"; | ||
this.AWS = AWS; | ||
this.stackName = stackName; | ||
this.stackFunctions = stackFunctions; | ||
this.result = false; | ||
this.failingResources = []; | ||
this.armArchitecture = "arm64"; | ||
this.SLS = SLS; | ||
this.failureMessage = | ||
"The following functions do not use an arm64 architecture."; | ||
this.rulePage = | ||
"See (https://theodo-uk.github.io/sls-dev-tools/docs/no-default-memory) for impact and how to to resolve."; | ||
} | ||
|
||
hasArmArchitecture(lambdaFunction) { | ||
return lambdaFunction.Architectures[0] === this.armArchitecture; | ||
} | ||
|
||
async run() { | ||
console.log(this.stackFunctions); | ||
try { | ||
const notArmFunctions = this.stackFunctions.reduce( | ||
(acc, current) => | ||
this.hasArmArchitecture(current) ? acc : [...acc, current], | ||
[] | ||
); | ||
|
||
this.failingResources = notArmFunctions.map((lambda) => ({ | ||
arn: lambda.FunctionArn, | ||
architecture: lambda.Architectures[0], | ||
})); | ||
|
||
if (notArmFunctions.length > 0) { | ||
this.result = false; | ||
} else { | ||
this.result = true; | ||
} | ||
} catch (e) { | ||
console.error(e); | ||
this.result = false; | ||
} | ||
return this.result; | ||
} | ||
} | ||
|
||
export default UseArm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# All functions have an arm64 architecture | ||
|
||
Lambdas Functions default architecture is x86_64 but should be configure to arm64. | ||
Lambda functions that use arm64 architecture (AWS Graviton2 processor) can achieve significantly better price and performance than the equivalent function running on x86_64 architecture. | ||
|
||
--- | ||
|
||
## Suggested Actions: | ||
|
||
- Look into your function in your Lambda service to find `Architectures` in the code tab Runtime Settings. [more information](https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html#foundation-arch-adv) |