question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deployment to AWS results in Permanent Redirect error

See original GitHub issue

Describe the bug

Serverless deploy results in:

PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
    at Request.extractError (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/services/s3.js:837:35)
    at Request.callListeners (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/request.js:688:14)
    at Request.transition (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/request.js:690:12)
    at Request.callListeners (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
    at Request.emit (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/request.js:688:14)
    at Request.transition (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/root/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0/node_modules/@sls-next/s3-static-assets/node_modules/aws-sdk/lib/request.js:38:9) {
  code: 'PermanentRedirect',
  region: 'us-east-1',
  time: 2021-06-18T11:12:06.199Z,
  requestId: '93A8YNZG8N7Q1Q63',
  extendedRequestId: 'YNxh1Se5YqoTlqc+0VHbNw7IaL/VUypr5aO6NCr8w4eqMOo/40ZLdwQZ9S3NN1KbU+Qs8LGiL58=',
  cfId: 'rdIFedJdAXXPw1Ic7Edy8GGmqqqkPJlJ8ieiEN3b2CPR0Tr1bjnetQ==',
  statusCode: 301,
  retryable: false,
  retryDelay: 78.28970486390303

We’ve not changed anything that we can readily identify and it happens only in some deploys mostly on one AWS environment. Mostly the failure have been on a test environment, but we’ve also seen the failure happen on our dev environment.

It worked briefly when we upgraded from 1.17 -> 1.18 and carried on failing after. Most deployments are failing now, but not all.

Actual behavior

See above

Expected behavior

It should deploy to AWS

Steps to reproduce

We have no idea. We have smaller nextjs projects that are deploying fine and continue to do so into the environments affected.

Also, we spent the morning debugging it and it magically fixed itself this morning. Submitting issue on the basis we’d dearly love to know what happened, but accept that might be asking too much from the universe…

Screenshots/Code/Logs

admin:
  component: '@sls-next/serverless-component@1.17'
  inputs:
    description: 'DT+ Trials App on Lambda@Edge'
    name:
      defaultLambda: trials-app-default
      apiLambda: trials-app-api
    policy: 'arn:aws:iam::690642816946:policy/admin-app-systems-manager-read'
    bucketName: ${env.TRIALS_DEPLOYMENT_BUCKET}
    memorySize: 1024
    AccelerateConfiguration:
      AccelerationStatus: Enabled

Versions

Additional context

Checklist

  • You have reviewed the README and FAQs, which answers several common questions.
  • Please first try using the most recent latest or alpha @sls-next/serverless-component release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the old serverless-next.js component and the serverless-next.js plugin are deprecated and no longer maintained.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
dphangcommented, Jun 18, 2021

No workaround yet - I am trying to see why it’s still failing even when setting regional s3 endpoint above. Updated in PR: https://github.com/serverless-nextjs/serverless-next.js/pull/1263

1reaction
dphangcommented, Jun 19, 2021

Hopefully fixed by this: https://github.com/serverless-nextjs/serverless-next.js/pull/1263, ran e2e tests a few times and it seems stable?

Though we shouldn’t need to manually set endpoint but maybe there’s a bug in AWS sdk?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using redirects - AWS Amplify Hosting
Redirects enable a web server to reroute navigation from one URL to another. Common reasons for using redirects include: to customize the appearance...
Read more >
Jekyll App Deployment Results in many HTTP 301 Redirects
I have a Jekyll site that runs perfectly locally. When I try to deploy it with amplify many of the CSS and Javascript...
Read more >
How to Fix The ERR_TOO_MANY_REDIRECTS Error - Kinsta
The ERR_TOO_MANY_REDIRECTS is, as the error suggests, caused by too many redirects, resulting in a redirect loop.
Read more >
Create redirects for GitLab Pages
All paths must start with a forward slash / . · A default status code of 301 is applied if no status code...
Read more >
Rails Elastic Beanstalk nginx 301 redirect - Stack Overflow
I've been able to successfully deploy and run an empty rails app using this guide: AWS Rails Elastic Beanstalk. Region: us-west-2 Platform: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found