aws-amplify / aws-amplify/amplify-cli
Amplify does not recognize function created in a separate git branch
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
**Which Category is your question related to?**
Function
**Amplify CLI Version**
5.3.1
**What AWS Services are you utilizing?**
Api, function, storage, auth,
**Provide additional details e.g. code snippets**
Help needed with an amplify push issue, please! :pray:
- A colleague and I were working on two different envs (**envA** and **envB**), in __separate git branches__ (**br1** and **br2**).
- We __both added (different) functions__ in each env (let's called function **funX** and **funY**). We both performed an `amplify push` in each one env and did git pushes while progressing work.
- At some point we wanted to __merge__ our developments because we know there would have been issues in amplify
- Basically I have merged his branch in my branch, locally. There were __git conflicts__, in particular in **backend-config.json**. Having both added functions, the conflict was in the function section of course.
- We manually __merged the conflicts, very carefully__, i.e. I am 100% that file is syntactically correct and both functions are correctly declared.
- I then run an `amplify push`, which worked successfully.
- However the `amplify status` __does not list my colleague's function (funB)...__ of course it was available in the backend-config.json and the related folder under amplify/function was there. Therefore my env (envA) did not build that lambda in the cloud.. and of course this causes errors (the lambda is invoked by the react frontend but it's not there)
I don't know how to get out from that situation!
**What is the correct procedure to handle such scenario??**
Should I have used an amplify command to merge envB in envA? Shouldn't be enough the git merge and then a push?
Some more attempts on that:
- Given that the function was missing in my env, I then tried to an `amplify add function` to manually create the missing function (funY)... I noticed that after this, funY was added to my env (envA) in the team-provider-info.json. Of course the folder for funY was already in my amplify folder and amplify kept that.. it did just override some files (e.g. adding basic permissions for that function and removing the permission my colleague had assigned to it).. so I then inspected the diff in git and made sure to (very carefully) discard some of the changes made by the *amplify add* the original settings from my colleague. However performing another amplify push at this point, I got an error...
```CREATE_FAILED LambdaFunction AWS::Lambda::Function Thu Sep 02 2021 16:21:28 GMT+0200 (Central European Summer Time) Resource handler returned message: "1 validation error detected: Value '[functionapibtlambdalayerArn]' at 'layers' failed to satisfy constraint: Member must satisfy constraint: [Member must have length less than or equal to 140, Member must have length greater than or equal to 1, Member must satisfy regular expression pattern: (arn:[a-zA-Z0-9-]+:lambda:[a-zA-Z0-9-]+:\d{12}:layer:[a-zA-Z0-9-_]+:[0-9]+)|(arn:[a-zA-Z0-9-]+:lambda:::awslayer:[a-zA-Z0-9-_]+)] (Service: Lambda, Status Code: 400, Request ID: f95b5be8-09a2-45b6-95f8-599862736793, Extended Request ID: null)" (RequestToken: 9c0f7b52-c7ed-b32b-84c0-8e9c6e281ad6, HandlerErrorCode: InvalidRequest)
```
Contributor guide
Assessment
This issue has not been assessed yet.