Skip to content

Commit 21166cb

Browse files
Update warning for ARM and AMD architectures on Amazon Linux (#347)
1 parent 7e156ef commit 21166cb

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Projects": [
3+
{
4+
"Name": "Amazon.Lambda.Tools",
5+
"Type": "Patch",
6+
"ChangelogMessages": [
7+
"Updated message related to self-contained runtimes with lambda functions"
8+
]
9+
}
10+
]
11+
}

src/Amazon.Lambda.Tools/LambdaPackager.cs

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ public static class LambdaPackager
4141
private static bool IsAmazonLinux(IToolLogger logger)
4242
{
4343
#if !NETCOREAPP3_1_OR_GREATER
44-
return false;
44+
return false;
45+
#else
46+
return IsAmazonLinux2(logger) || IsAmazonLinux2023(logger);
47+
#endif
48+
}
49+
50+
private static bool IsAmazonLinux2(IToolLogger logger)
51+
{
52+
#if !NETCOREAPP3_1_OR_GREATER
53+
return false;
4554
#else
4655
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
4756
{
@@ -55,6 +64,24 @@ private static bool IsAmazonLinux(IToolLogger logger)
5564
$"Linux distribution is Amazon Linux 2, NativeAOT container build is optional");
5665
return true;
5766
}
67+
}
68+
}
69+
70+
return false;
71+
#endif
72+
}
73+
74+
private static bool IsAmazonLinux2023(IToolLogger logger)
75+
{
76+
#if !NETCOREAPP3_1_OR_GREATER
77+
return false;
78+
#else
79+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
80+
{
81+
if (File.Exists(LinuxOSReleaseFile))
82+
{
83+
logger?.WriteLine($"Found {LinuxOSReleaseFile}");
84+
string readText = File.ReadAllText(LinuxOSReleaseFile);
5885
if (readText.Contains(AmazonLinuxNameInOSReleaseFile) && readText.Contains(AmazonLinux2023InOSReleaseFile))
5986
{
6087
logger?.WriteLine(
@@ -110,10 +137,19 @@ public static bool CreateApplicationBundle(LambdaToolsDefaults defaults, IToolLo
110137

111138
LogDeprecationMessagesIfNecessary(logger, targetFramework);
112139

113-
if (string.Equals(architecture, LambdaConstants.ARCHITECTURE_ARM64) && msbuildParameters != null && msbuildParameters.Contains("--self-contained true"))
140+
if (msbuildParameters != null && msbuildParameters.Contains("--self-contained true"))
114141
{
115-
logger.WriteLine("WARNING: There is an issue with self contained ARM based .NET Lambda functions using custom runtimes that causes functions to fail to run. The following GitHub issue has further information and workaround.");
116-
logger.WriteLine("https://github.com/aws/aws-lambda-dotnet/issues/920");
142+
if (string.Equals(architecture, LambdaConstants.ARCHITECTURE_ARM64) && IsAmazonLinux2(logger))
143+
{
144+
logger.WriteLine("WARNING: There is an issue with self-contained ARM-based .NET Lambda functions using custom runtimes on Amazon Linux 2 that causes functions to fail to run.");
145+
logger.WriteLine("For more information and workarounds, see: https://github.com/aws/aws-lambda-dotnet/issues/920");
146+
}
147+
else if (IsAmazonLinux2023(logger))
148+
{
149+
logger.WriteLine("WARNING: There is an issue with self-contained .NET Lambda functions using custom runtimes on Amazon Linux 2023 that causes functions to fail to run.");
150+
logger.WriteLine("This applies to both AMD and ARM architectures.");
151+
logger.WriteLine("For more information and workarounds, see: https://github.com/aws/aws-lambda-dotnet/issues/920");
152+
}
117153
}
118154

119155
if (string.IsNullOrEmpty(configuration))

0 commit comments

Comments
 (0)