aws-amplify / aws-amplify/amplify-hosting
Go is not installed on AmazonLinux 2 when trying to build a Go function
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
** Please describe which feature you have a question about? **
I've created a GoLang function as documented. I can push it sucessfully from my computer. But when running amplifyPush from the console it seems it cannot build the function as go isn't available on the machine.
I have to install golang everytime which consumes time and money. It is akward that amplify console cannot natively build a go function.
**Amplify version**
latest 4.29.3
```
20-09-25T07:22:20.865Z [INFO]: # Ensuring NPM package '@aws-amplify/cli' is version: 'latest'
2020-09-25T07:22:27.719Z [INFO]: # Patching NPM package '@aws-amplify/cli' from 1.12.0 to 4.29.3...
```
**amplify.yml**
```
version: 0.1
backend:
phases:
build:
commands:
- "# Execute Amplify CLI with the helper script"
- amplifyPush --simple
frontend:
phases: [...]
```
**Build settings**

**Console output for the backend step**
```
2020-09-25T07:24:20.968Z [WARNING]: ✖ There was an error initializing your environment.
2020-09-25T07:24:20.970Z [INFO]: init failed
Error: Missing required dependencies to package myapp
at buildResource (/root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/build-resources.js:25:15)
at process._tickCallback (internal/process/next_tick.js:68:7)
2020-09-25T07:24:21.975Z [INFO]: Note: It is recommended to run this command from the root of your app directory
2020-09-25T07:24:25.676Z [WARNING]: - Initializing your environment: prhc
2020-09-25T07:24:25.697Z [WARNING]: (node:2066) ExperimentalWarning: The fs.promises API is experimental
2020-09-25T07:24:25.804Z [WARNING]: ✔ Initialized provider successfully.
2020-09-25T07:24:26.772Z [INFO]: go executable was not found in PATH, make sure it's available. It can be installed from https://golang.org/doc/install
2020-09-25T07:24:26.778Z [WARNING]: ✖ An error occurred when pushing the resources to the cloud
2020-09-25T07:24:26.778Z [WARNING]: ✖ There was an error initializing your environment.
2020-09-25T07:24:26.779Z [INFO]: init failed
2020-09-25T07:24:26.780Z [INFO]: Error: Missing required dependencies to package myapp
at buildResource (/root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/build-resources.js:25:15)
at process._tickCallback (internal/process/next_tick.js:68:7)
2020-09-25T07:24:26.792Z [ERROR]: !!! Build failed
2020-09-25T07:24:26.865Z [ERROR]: !!! Non-Zero Exit Code detected
2020-09-25T07:24:26.865Z [INFO]: # Starting environment caching...
2020-09-25T07:24:26.865Z [INFO]: # Environment caching completed
```
**Workaround**
As a workaround, I install go by running this code. But that's not ideal.
```
backend:
phases:
preBuild:
commands:
- "# Install required dependencies"
- "# jq is to create a proper parameters.json file"
- amazon-linux-extras enable golang1.11
- yum clean metadata
- yum -y install golang jq
```
Contributor guide
Research direction
Start with the backend build phase in amplify.yml and reproduce amplifyPush on the Amazon Linux 2 environment described in the console output. Trace the reported missing Go dependency and verify that a Go function builds without the manual amazon-linux-extras and yum workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, go, linux
- Domain
- build-system, ci-cd, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100