aws-amplify / aws-amplify/amplify-hosting

Deploy Steps failure

Open
#2,073 6 comments 0 reactions 0 assignees View on GitHub
ssr
Dominant language
Dockerfile
Stars
481
Forks
123
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-console/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-console/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-console/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

### App Id

d3eyxgyk7b3qii

### Region

us-east-2

### Amplify Console feature

Build settings

### Describe the bug

2021-07-20T19:06:56 [INFO]: Beginning deployment for application d3eyxgyk7b3qii, branch:dev, buildId 0000000317
2021-07-20T19:06:56 [INFO]: Cannot find any generated SSR resources to deploy. If you intend for your app to be SSR, please check your app Service Role permissions. Otherwise, please check out our docs on how to setup your app to be detected as SSG (https://docs.aws.amazon.com/amplify/latest/userguide/server-side-rendering-amplify.html#deploy-nextjs-app)

### Expected behavior

Deploy step should be finished successfully

### Reproduction steps

1. Commit anything to the code repo
2. Deploy, build setting is successful and it fails through Deploy step with following error

2021-07-20T19:06:56 [INFO]: Beginning deployment for application d3eyxgyk7b3qii, branch:dev, buildId 0000000317
2021-07-20T19:06:56 [INFO]: Cannot find any generated SSR resources to deploy. If you intend for your app to be SSR, please check your app Service Role permissions. Otherwise, please check out our docs on how to setup your app to be detected as SSG (https://docs.aws.amazon.com/amplify/latest/userguide/server-side-rendering-amplify.html#deploy-nextjs-app)

It started failing since yesterday but it has been working before that.

### Build Settings

```yaml
version: 1
frontend:
phases:
preBuild:
commands:
- npm install
# IMPORTANT - Please verify your build commands
build:
commands:
- npm run build
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: out
files:
- "**/*"
cache:
paths:
- node_modules/**/*
```

### Additional information

This our build steps
```

"web": "node scripts/set-next-env-config.js $npm_config_env dev",
"build": "node scripts/set-next-env-config.js $npm_config_env build && next build && next export",
"start-web": "node scripts/set-next-env-config.js $npm_config_env start",
```

and following code is used for setting environment variables, but it is not executed at the moment with amplify settings:

`#!/bin/node
const fs = require("fs");
const childProcess = require("child_process");

const environment = process.argv[2];

const nextCommand = process.argv[3];

let envPath = "";
if (environment == "local") envPath = "env/.env.local";
else if (environment == "dev") envPath = "env/.env.development";
else if (environment == "prod") envPath = "env/.env.production";
else if (environment == "preview") envPath = "env/.env.preview";
else envPath = "env/.env.development";
console.log("testing", environment);
if (environment == "local") {
nextBuild((message) => {
console.log(message);
if (nextCommand === "build") {
nextExport((message) => {
console.log(message);
});
}
});
} else {
try {
const file = fs.readFileSync(envPath, "utf8");
if (file) {
fs.writeFileSync(".env", file);
}
} catch (err) {
console.log(err);
}
// nextBuild((message) => {
// console.log(message);
// if (nextCommand === "build") {
// nextExport((message) => {
// console.log(message);
// });
// }
// });
}

function nextBuild(onSuccess) {
childProcess
.spawn("env-cmd", ["-f", envPath, "next", nextCommand], {
stdio: "inherit",
shell: true,
})
.on("exit", function (error) {
if (!error) {
onSuccess("----- Build Success! -----");
}
});
}

function nextExport(onSuccess) {
childProcess
.spawn("env-cmd", ["-f", envPath, "next", "export"], {
stdio: "inherit",
shell: true,
})
.on("exit", function (error) {
if (!error) {
onSuccess("----- Exported Successfully -----");
}
});
}`

Contributor guide

Open the contributing guide

Research direction

Start with the Amplify build settings and the package.json scripts shown in the report, especially npm run build, next build, next export, and the out baseDirectory. Compare the deployment log with the documented Next.js SSG setup linked in the issue. Done means the Deploy step completes and the generated site is recognized and deployed.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, next.js, node.js
Domain
ci-cd, cloud, devops, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.