Skip to content

Commit

Permalink
fix: fix Go runtime for al2023
Browse files Browse the repository at this point in the history
  • Loading branch information
0.618 committed Apr 1, 2024
1 parent 8e2b361 commit 1d1fc99
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const ReadMeContent = `# Getting Started with Amplify CLI
This directory was generated by [Amplify CLI](https://docs.amplify.aws/cli).
Helpful resources:
- Amplify documentation: https://docs.amplify.aws
- Amplify CLI documentation: https://docs.amplify.aws/cli
- More details on this folder & generated files: https://docs.amplify.aws/cli/reference/files
- Join Amplify's community: https://amplify.aws/community/
- Amplify documentation: https://docs.amplify.aws.
- Amplify CLI documentation: https://docs.amplify.aws/cli.
- More details on this folder & generated files: https://docs.amplify.aws/cli/reference/files.
- Join Amplify's community: https://amplify.aws/community/.
`;

export function writeReadMeFile(readMeFilePath: string): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export const BIN = 'bin';
export const SRC = 'src';
export const DIST = 'dist';
export const MAIN_SOURCE = 'main.go';
export const MAIN_BINARY = 'main';
export const MAIN_BINARY_WIN = 'main.exe';
export const MAIN_BINARY = 'bootstrap';
export const MAIN_BINARY_WIN = 'bootstrap.exe';

export const BASE_PORT = 8900;
export const MAX_PORT = 9999;
Expand Down
10 changes: 2 additions & 8 deletions packages/amplify-go-function-runtime-provider/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const buildResource = async ({ buildType, srcRoot, lastBuildTimeStamp }:
fs.mkdirSync(outDir);
}

const envVars: any = {};
const envVars: any = { GOPROXY: 'direct' };

if (buildType === BuildType.PROD) {
envVars.GOOS = 'linux';
Expand All @@ -102,13 +102,7 @@ export const buildResource = async ({ buildType, srcRoot, lastBuildTimeStamp }:
executeCommand(['mod', 'tidy', '-v'], true, envVars, srcDir);
// Execute the build command, cwd must be the source file directory (Windows requires it)
// Details: https://github.com/aws/aws-lambda-go
executeCommand(['build', '-o', 'bootstrap', 'main.go'], true, envVars, srcDir);
// Compress this binary into a ZIP file deployment package, ready to deploy to Lambda
if (isWindows) {
executeCommand(['%USERPROFILE%Go\bin\build-lambda-zip.exe', '-o', 'lambda-handler.zip', 'bootstrap'], true, envVars, srcDir);
} else {
await execa('zip', ['lambda-handler.zip', 'bootstrap'], { cwd: srcDir, env: envVars });
}
executeCommand(['build', '-o', '../bin/bootstrap', 'main.go'], true, envVars, srcDir);

rebuilt = true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@aws-amplify/amplify-go-function-template-provider",
"version": "1.4.7",
"description": "Go 1.x templates supplied by the Amplify Team",
"description": "Go templates supplied by the Amplify Team",
"repository": {
"type": "git",
"url": "https://github.com/aws-amplify/amplify-cli.git",
Expand Down

0 comments on commit 1d1fc99

Please sign in to comment.