Skip to content

Commit

Permalink
chore: Update default memory size to 512 in Amazon.Lambda.Annotations (
Browse files Browse the repository at this point in the history
  • Loading branch information
96malhar authored Apr 4, 2024
1 parent 255081d commit 45aba15
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private void ApplyLambdaFunctionDefaults(string lambdaFunctionPath, string prope

_templateWriter.SetToken($"{propertiesPath}.Runtime", runtime);
_templateWriter.SetToken($"{propertiesPath}.CodeUri", "");
_templateWriter.SetToken($"{propertiesPath}.MemorySize", 256);
_templateWriter.SetToken($"{propertiesPath}.MemorySize", 512);
_templateWriter.SetToken($"{propertiesPath}.Timeout", 30);
_templateWriter.SetToken($"{propertiesPath}.Policies", new List<string>{"AWSLambdaBasicExecutionRole"}, TokenType.List);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down Expand Up @@ -44,7 +44,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down Expand Up @@ -44,7 +44,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down Expand Up @@ -76,7 +76,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down Expand Up @@ -108,7 +108,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down Expand Up @@ -140,7 +140,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down Expand Up @@ -173,7 +173,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"Tool": "Amazon.Lambda.Annotations"
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand All @@ -29,7 +29,7 @@
"Tool": "Amazon.Lambda.Annotations"
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 50,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 50,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Properties": {
"Runtime": "dotnet8",
"CodeUri": ".",
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Properties": {
"Runtime": "provided.al2",
"CodeUri": ".",
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Properties": {
"Runtime": "provided.al2",
"CodeUri": ".",
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down Expand Up @@ -44,7 +44,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down Expand Up @@ -76,7 +76,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down Expand Up @@ -108,7 +108,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down Expand Up @@ -137,7 +137,7 @@
"Tool": "Amazon.Lambda.Annotations"
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand All @@ -157,7 +157,7 @@
"Tool": "Amazon.Lambda.Annotations"
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand All @@ -177,7 +177,7 @@
"Tool": "Amazon.Lambda.Annotations"
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
]
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"Tool": "Amazon.Lambda.Annotations"
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Properties": {
"Runtime": "provided.al2",
"CodeUri": ".",
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"Tool": "Amazon.Lambda.Annotations"
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"Tool": "Amazon.Lambda.Annotations"
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"Tool": "Amazon.Lambda.Annotations"
},
"Properties": {
"MemorySize": 256,
"MemorySize": 512,
"Timeout": 30,
"Policies": [
"AWSLambdaBasicExecutionRole"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,40 @@ public class CloudFormationWriterTests
[Theory]
[InlineData(CloudFormationTemplateFormat.Json)]
[InlineData(CloudFormationTemplateFormat.Yaml)]
public void ApplyLambdaFunctionDefaultProperties(CloudFormationTemplateFormat templateFormat)
{
// ARRANGE
var mockFileManager = GetMockFileManager(string.Empty);
var lambdaFunctionModel = GetLambdaFunctionModel("MyAssembly::MyNamespace.MyType::Handler",
"TestMethod", 0, 0, null, null);
var cloudFormationWriter = GetCloudFormationWriter(mockFileManager, _directoryManager, templateFormat, _diagnosticReporter);
var report = GetAnnotationReport(new List<ILambdaFunctionSerializable>() { lambdaFunctionModel });
ITemplateWriter templateWriter = templateFormat == CloudFormationTemplateFormat.Json ? new JsonWriter() : new YamlWriter();

// ACT
cloudFormationWriter.ApplyReport(report);

// ASSERT
templateWriter.Parse(mockFileManager.ReadAllText(ServerlessTemplateFilePath));
const string functionPath = "Resources.TestMethod";
const string propertiesPath = "Resources.TestMethod.Properties";

Assert.Equal("AWS::Serverless::Function", templateWriter.GetToken<string>($"{functionPath}.Type"));
Assert.Equal("Amazon.Lambda.Annotations", templateWriter.GetToken<string>($"{functionPath}.Metadata.Tool"));

Assert.Equal("MyAssembly::MyNamespace.MyType::Handler", templateWriter.GetToken<string>($"{propertiesPath}.Handler"));
Assert.Equal(512, templateWriter.GetToken<int>($"{propertiesPath}.MemorySize"));
Assert.Equal(30, templateWriter.GetToken<int>($"{propertiesPath}.Timeout"));
Assert.Equal(new List<string> { "AWSLambdaBasicExecutionRole" }, templateWriter.GetToken<List<string>>($"{propertiesPath}.Policies"));
Assert.Equal("Zip", templateWriter.GetToken<string>($"{propertiesPath}.PackageType"));
Assert.Equal(".", templateWriter.GetToken<string>($"{propertiesPath}.CodeUri"));
Assert.False(templateWriter.Exists("ImageUri"));
Assert.False(templateWriter.Exists("ImageConfig"));
}

[Theory]
[InlineData(CloudFormationTemplateFormat.Json)]
[InlineData(CloudFormationTemplateFormat.Yaml)]
public void AddSingletonFunctionToEmptyTemplate(CloudFormationTemplateFormat templateFormat)
{
// ARRANGE
Expand Down
Loading

0 comments on commit 45aba15

Please sign in to comment.