amplify-backend
amplify-backend copied to clipboard
Amplify Gen2 Deploy fails when referencing Functions or Storage
Environment information
System:
OS: macOS 14.1
CPU: (8) arm64 Apple M3
Memory: 173.72 MB / 16.00 GB
Shell: /bin/zsh
Binaries:
Node: 20.13.1 - ~/.nvm/versions/node/v20.13.1/bin/node
Yarn: undefined - undefined
npm: 10.8.2 - ~/.nvm/versions/node/v20.13.1/bin/npm
pnpm: undefined - undefined
NPM Packages:
@aws-amplify/backend: 1.0.4
@aws-amplify/backend-cli: 1.1.1
aws-amplify: 6.4.0
aws-cdk: 2.149.0
aws-cdk-lib: 2.149.0
typescript: 5.5.3
AWS environment variables:
AWS_STS_REGIONAL_ENDPOINTS = regional
AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables
Description
Can anyone help here, as soon as i attempt to add services like Storage or Functions, it fails to build. Runs locally on sandbox fine, no typescript errors. Not even trying anything fancy just importing the libraries into the build.
Build below:
0
2024-08-07T07:28:20.063Z [INFO]: # Cloning repository: [email protected]:milesmarshall/amplify-vite-react-template.git
1
2024-08-07T07:28:21.125Z [INFO]:
2
2024-08-07T07:28:21.125Z [INFO]: Cloning into 'amplify-vite-react-template'...
3
2024-08-07T07:28:21.125Z [INFO]: # Switching to commit: 95575f4ba27ea4c26e9dde40557e2be2ce053e1e
4
2024-08-07T07:28:21.140Z [INFO]: Note: switching to '95575f4ba27ea4c26e9dde40557e2be2ce053e1e'.
5
You are in 'detached HEAD' state. You can look around, make experimental
6
changes and commit them, and you can discard any commits you make in this
7
state without impacting any branches by switching back to a branch.
8
If you want to create a new branch to retain commits you create, you may
9
do so (now or later) by using -c with the switch command. Example:
10
git switch -c <new-branch-name>
11
Or undo this operation with:
12
git switch -
13
Turn off this advice by setting config variable advice.detachedHead to false
14
HEAD is now at 95575f4 added storage
15
2024-08-07T07:28:21.217Z [INFO]: Successfully cleaned up Git credentials
16
2024-08-07T07:28:21.218Z [INFO]: # Checking for Git submodules at: /codebuild/output/src3867197661/src/amplify-vite-react-template/.gitmodules
17
2024-08-07T07:28:21.225Z [INFO]: # Retrieving environment cache...
18
2024-08-07T07:28:21.277Z [INFO]: # Retrieved environment cache
19
2024-08-07T07:28:21.278Z [INFO]: ---- Setting Up SSM Secrets ----
20
2024-08-07T07:28:21.278Z [INFO]: SSM params {"Path":"/amplify/d2ihq7kuu4ddhp/main/","WithDecryption":true}
21
2024-08-07T07:28:25.277Z [INFO]: # Patching NPM package '@aws-amplify/cli' from 12.8.2 to 12.12.6...
22
2024-08-07T07:29:04.972Z [INFO]: # Installed '@aws-amplify/[email protected]'
23
2024-08-07T07:29:05.085Z [INFO]: # Done patching NPM package '@aws-amplify/cli' to version 12.12.6
24
2024-08-07T07:29:05.091Z [INFO]: # Retrieving cache...
25
2024-08-07T07:30:19.839Z [INFO]: # Extracting cache...
26
2024-08-07T07:30:31.596Z [INFO]: # Extraction completed
27
2024-08-07T07:30:31.880Z [INFO]: # Retrieved cache
28
2024-08-07T07:30:34.747Z [INFO]: ## Starting Backend Build
29
# Starting phase: build
30
# Executing command: npm ci --cache .npm --prefer-offline
31
2024-08-07T07:30:53.300Z [WARNING]: npm
32
2024-08-07T07:30:53.305Z [WARNING]: WARN deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
33
2024-08-07T07:30:53.426Z [WARNING]: npm
34
2024-08-07T07:30:53.427Z [WARNING]: WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
35
2024-08-07T07:30:53.604Z [WARNING]: npm WARN
36
2024-08-07T07:30:53.604Z [WARNING]: deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead
37
2024-08-07T07:30:53.666Z [WARNING]: npm
38
2024-08-07T07:30:53.666Z [WARNING]: WARN deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
39
2024-08-07T07:30:53.916Z [WARNING]: npm WARN
40
2024-08-07T07:30:53.917Z [WARNING]: deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead
41
2024-08-07T07:30:53.931Z [WARNING]: npm
42
2024-08-07T07:30:53.931Z [WARNING]: WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
43
2024-08-07T07:30:53.979Z [WARNING]: npm WARN deprecated
44
2024-08-07T07:30:53.979Z [WARNING]: [email protected]: Glob versions prior to v9 are no longer supported
45
2024-08-07T07:30:54.003Z [WARNING]: npm WARN
46
2024-08-07T07:30:54.003Z [WARNING]: deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
47
2024-08-07T07:31:02.425Z [WARNING]: npm
48
2024-08-07T07:31:02.430Z [WARNING]: WARN deprecated [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
49
2024-08-07T07:31:04.321Z [INFO]: added 1486 packages, and audited 1603 packages in 29s
50
2024-08-07T07:31:04.322Z [INFO]: 169 packages are looking for funding
51
run `npm fund` for details
52
2024-08-07T07:31:04.437Z [INFO]: 29 high severity vulnerabilities
53
To address issues that do not require attention, run:
54
npm audit fix
55
To address all issues (including breaking changes), run:
56
npm audit fix --force
57
Run `npm audit` for details.
58
2024-08-07T07:31:04.484Z [INFO]: # Executing command: npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID
59
2024-08-07T07:31:09.492Z [INFO]:
60
2024-08-07T07:31:14.834Z [INFO]: amplify/backend.ts(4,26): error TS2307: Cannot find module './functions/say-hello/resource' or its corresponding type declarations.
61
2024-08-07T07:31:14.840Z [INFO]: amplify/backend.ts(5,25): error TS2307: Cannot find module './storage/resource' or its corresponding type declarations.
62
2024-08-07T07:31:14.875Z [INFO]:
63
2024-08-07T07:31:14.875Z [WARNING]: ampx pipeline-deploy
64
Command to deploy backends in a custom CI/CD pipeline. This command is not inten
65
ded to be used locally.
66
Options:
67
--debug Print debug logs to the console [boolean] [default: false]
68
--help Show help [boolean]
69
--branch Name of the git branch being deployed [string] [required]
70
--app-id The app id of the target Amplify app [string] [required]
71
--outputs-out-dir A path to directory where amplify_outputs is written. If no
72
t provided defaults to current process working directory.
73
[string]
74
--outputs-version Version of the configuration. Version 0 represents classic
75
amplify-cli config file amplify-configuration and 1 represe
76
nts newer config file amplify_outputs
77
[string] [choices: "0", "1"] [default: "1"]
78
--outputs-format amplify_outputs file format
79
[string] [choices: "mjs", "json", "json-mobile", "ts", "dart"]
80
2024-08-07T07:31:14.875Z [INFO]: SyntaxError: TypeScript validation check failed.
81
Resolution: Fix the syntax and type errors in your backend definition.
82
Cause:
83
2024-08-07T07:31:14.986Z [ERROR]: !!! Build failed
84
2024-08-07T07:31:14.986Z [ERROR]: !!! Error: Command failed with exit code 1
85
2024-08-07T07:31:14.986Z [INFO]: # Starting environment caching...
86
2024-08-07T07:31:14.987Z [INFO]: # Uploading environment cache artifact...
87
2024-08-07T07:31:15.086Z [INFO]: # Uploaded environment cache artifact
88
2024-08-07T07:31:15.086Z [INFO]: # Environment caching completed
Hey @milesmarshall, thank you for reaching out. Could you provide us some additional information or screenshot on how the backend and repository is currently setup.
Could you try adding ls -la amplify/ in the amplify.yml build specification before the deploy command?
Closing the thread due to inactivity. If you are still observing this error, feel free to reopen with the requested information.
Hello, I was facing the same issue: 'amplify/backend.ts(5,25): error TS2307: Cannot find module './storage/resource' or its corresponding type declarations.' during the deployment. I decided to follow a comment suggesting to run the following command before deploying: 'ls -la amplify/'. This command showed me that the storage folder was indeed missing. So, I checked my GitHub repository and saw that the folder was also missing there. After confirming it wasn't present, I did another push to the repository, and this time the folder appeared. As a result, the deployment was successful. Perhaps this is related to the fact that I recently made my repository private?