NoCredentialProviders: no valid providers in chain error in electron-updater with AWS S3
Asked Answered
R

3

7

I'm trying to implement autoupdate of my electron-react application using electron-updater and AWS S3 bucket. But getting error:

⨯ NoCredentialProviders: no valid providers in chain. Deprecated.
        For verbose messaging see aws.Config.CredentialsChainVerboseErrors
github.com/develar/app-builder/pkg/publisher.upload
        Y:/Documents/app-builder/pkg/publisher/s3.go:169
github.com/develar/app-builder/pkg/publisher.ConfigurePublishToS3Command.func1
        Y:/Documents/app-builder/pkg/publisher/s3.go:57
github.com/alecthomas/kingpin.(*actionMixin).applyActions
        C:/Users/develar/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/actions.go:28
github.com/alecthomas/kingpin.(*Application).applyActions
        C:/Users/develar/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:557
github.com/alecthomas/kingpin.(*Application).execute
        C:/Users/develar/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:390
github.com/alecthomas/kingpin.(*Application).Parse
        C:/Users/develar/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:222
main.main
        Y:/Documents/app-builder/main.go:90
runtime.main
        c:/go/src/runtime/proc.go:203
runtime.goexit
        c:/go/src/runtime/asm_amd64.s:1373  
  ⨯ NoCredentialProviders: no valid providers in chain. Deprecated.
        For verbose messaging see aws.Config.CredentialsChainVerboseErrors
github.com/develar/app-builder/pkg/publisher.upload
        Y:/Documents/app-builder/pkg/publisher/s3.go:169
github.com/develar/app-builder/pkg/publisher.ConfigurePublishToS3Command.func1
        Y:/Documents/app-builder/pkg/publisher/s3.go:57
github.com/alecthomas/kingpin.(*actionMixin).applyActions
        C:/Users/develar/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/actions.go:28
github.com/alecthomas/kingpin.(*Application).applyActions
        C:/Users/develar/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:557
github.com/alecthomas/kingpin.(*Application).execute
        C:/Users/develar/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:390
github.com/alecthomas/kingpin.(*Application).Parse
        C:/Users/develar/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:222
main.main
        Y:/Documents/app-builder/main.go:90
runtime.main
        c:/go/src/runtime/proc.go:203
runtime.goexit
        c:/go/src/runtime/asm_amd64.s:1373  
  ⨯ Cannot cleanup: 

Error #1 --------------------------------------------------------------------------------
Error: D:\directoryofmyapp\myappname\node_modules\app-builder-bin\win\x64\app-builder.exe exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
    at ChildProcess.<anonymous> (D:\directoryofmyapp\myappname\node_modules\builder-util\src\util.ts:243:14)
    at Object.onceWrapper (events.js:422:26)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1048:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)

Error #2 --------------------------------------------------------------------------------
Error: D:\directoryofmyapp\myappname\node_modules\app-builder-bin\win\x64\app-builder.exe exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
    at ChildProcess.<anonymous> (D:\directoryofmyapp\myappname\node_modules\builder-util\src\util.ts:243:14)
    at Object.onceWrapper (events.js:422:26)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1048:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)  stackTrace=

Here is my package.json:

{
  "name": "myappname",
  "version": "0.1.0",
  "private": true,
  "license": "MIT",
  "productName": "myappname",
  "author": "Bakhrom",
  "description": "myappname",
  "homepage": "./",
  "main": "./public/electron.js",
  "build": {
    "appId": "com.myappname.electron-app",
    "files": [
      "build/electron.js",
      "build/.env",
      "./~/.aws/credentials",
      "~/.aws/credentials",
      "./.env",
      ".env"
    ],
    "directories": {
      "buildResources": "./public/**/*"
    },
    "win": {
      "icon": "./public/img/favicon.png"
    },
    "publish": {
      "provider": "s3",
      "bucket": "mybucketname",
      "region": "ap-southeast-1"
    }
  },
  "dependencies": {
    "@fluentui/react": "^7.146.0",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2"
    "electron-is-dev": "^1.2.0",
    "electron-pos-printer": "^1.2.0",
    "electron-updater": "^4.3.5",
    ... other packages
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "node --expose-gc --max-old-space-size=1900 node_modules/react-scripts/scripts/build.js",
    "test": "react-scripts test",
    "dev": "concurrently \"npm start\" \"wait-on http://localhost:3000 && electron .\"",
    "electron-build": "npm run build && electron-builder build",
    "deploy": "npm run build && electron-builder build --win --publish always",
    "postinstall": "electron-builder install-app-deps"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "concurrently": "^5.3.0",
    "dotenv": "^8.2.0",
    "electron": "^9.1.0",
    "electron-builder": "^22.9.1",
    "electron-rebuild": "^2.3.2",
    "wait-on": "^5.2.1"
  }
}

I'm running the command below:

"deploy": "npm run build && electron-builder build --win --publish always"

The bucket is public. I can't figure out what is going on? I also mentioned aws_access_key_id and aws_secret_access_key in environment variables and ~/.aws/credentials file. But no result.

Ramsay answered 4/2, 2021 at 12:14 Comment(0)
L
3

As per the official documentation, you need to have something like this S3Options

AWS credentials are required, please see getting your credentials. Define AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. Or in the ~/.aws/credentials.

  "build":
    "publish": {
      "provider": "s3",
      "bucket": "bucket-name"
    }
  }
}

You export secrets into windows environment:

setx AWS_ACCESS_KEY_ID AKIAIOSFODNN7EXAMPLE
setx AWS_SECRET_ACCESS_KEY wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
setx AWS_DEFAULT_REGION us-west-2

You don't have to make the bucket Public unless you want to. Make sure the User's credentials you are using, have the following permissions at least to access the bucket:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "s3:AbortMultipartUpload",
                "s3:GetObject",
                "s3:GetObjectAcl",
                "s3:GetObjectVersion",
                "s3:ListMultipartUploadParts",
                "s3:PutObject",
                "s3:PutObjectAcl"
            ],
            "Resource": "arn:aws:s3:::bucketName/*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:ListBucketMultipartUploads",
                "s3:GetBucketLocation"
            ],
            "Resource": "arn:aws:s3:::bucketName"
        }
    ]
}

On the side note why you are bundling your credentials files

      "./~/.aws/credentials",
      "~/.aws/credentials",
Ludhiana answered 4/2, 2021 at 13:3 Comment(1)
I've downloaded and configured AWS CLIRamsay
B
0

Double-check the format of your ~/.aws/credential file.

For example in the AWS SDK, JavaScript correctly works with uppercase and lowercase params:

[profile]
AWS_ACCESS_KEY_ID=
or
[profile]
aws_access_key_id=

But in the AWS SDK, Go correctly works only lowercase params:

[profile]
aws_access_key_id=
aws_secret_access_key=

Electron-builder used the AWS SDK for Go in deployments.

Boost answered 13/11, 2021 at 11:2 Comment(0)
G
0

If you are doing aws sso login --profile abc and face this error you can simply use the profile name in the variable and terraform will use that.

export AWS_PROFILE=abc
Gman answered 7/11, 2023 at 12:13 Comment(1)
I'm also running into this issue. I'm using aws sso login --profile {{profile_name}} but still returns NoCredential error. I also tried using export but still same issue. This fails or returns an error when I attempt to run my container. I'm leveraging AWS Fargate.Jetton

© 2022 - 2024 — McMap. All rights reserved.