Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error (412 Precondition Failed) when creating artifact #29

Closed
paambaati opened this issue Jun 13, 2022 · 5 comments · Fixed by #33
Closed

Error (412 Precondition Failed) when creating artifact #29

paambaati opened this issue Jun 13, 2022 · 5 comments · Fixed by #33

Comments

@paambaati
Copy link

On deploying to Vercel and using S3 storage, I get this error when trying to run turbo commands –

{
	"severity": "WARNING",
	"level": 40,
	"time": 1655122987166,
	"pid": 9,
	"hostname": "169.254.33.177",
	"reqId": "q-nGx8L1TCaa2laKhCeJRA-25",
	"data": {
		"message": "Access Denied",
		"code": "AccessDenied",
		"region": null,
		"time": "2022-06-13T12:23:07.166Z",
		"requestId": "KRFCEX6FM17HZD2Z",
		"extendedRequestId": "xYHj4oepC5Eu4oD0QcrQcTGCbOyITRXV7rp2JSXa1RwAVSOKsiI0b2gkABewiDxQXa7GN+8RUGM=",
		"statusCode": 403,
		"retryable": false,
		"retryDelay": 26.181109834484474
	},
	"isBoom": true,
	"isServer": false,
	"output": {
		"statusCode": 412,
		"payload": {
			"statusCode": 412,
			"error": "Precondition Failed",
			"message": "Error during the artifact creation"
		},
		"headers": {}
	},
	"stack": "Error: Error during the artifact creation\n    at Object.handler (/vercel/path0/src/plugins/remote-cache/routes/put-artifact.ts:29:31)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)",
	"type": "Error",
	"message": "Error during the artifact creation"
}

I've made sure the environment variables are correctly set up, the IAM credentials are right, and that the user has full adminstrator access on AWS.

@fox1t
Copy link
Collaborator

fox1t commented Jun 16, 2022

Hi. Would you mind providing a reproduction repository?

@paambaati
Copy link
Author

@fox1t I just clicked on the Deploy to Vercel button and set up the environment variables. The repository is exactly the same as this.

@dlehmhus
Copy link
Contributor

dlehmhus commented Jun 23, 2022

I ran into the same issue. I think the problem is, that the vercel deploy link contains S3_ACCESS_KEY and S3_SECRET_KEY instead of AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. But those AWS_ vars can not be set on vercel, because they are protected.

According to the docs the aws-sdk doesn't look for those S3_ vars. I'm not sure if that was different in the past?
One easy fix could be sticking with the S3_ vars and settings those manually.

// src/plugins/remote-cache/storage/s3.ts
// ...
export function createS3({ bucket, endpoint }: S3Options) {
  aws.config.update({
    accessKeyId: process.env.S3_ACCESS_KEY,
    secretAccessKey: process.env.S3_SECRET_KEY,
    region: process.env.S3_REGION,
    signatureVersion: 'v4',
  })

  const client = new aws.S3({
// ...

@fox1t
Copy link
Collaborator

fox1t commented Jun 28, 2022

This is a good point! We should remap the AWS_ to S3_ ones. Would you mind open a PR?

@fox1t
Copy link
Collaborator

fox1t commented Jun 28, 2022

#31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants