1

CircleCI と Claudia.js を実行して、node.js コードを AWS Lambda にデプロイしています。

これが私のpackage.json(スクリプト部分)です:

"scripts": {
    "deploy": "claudia create --handler lambda.handler --deploy-proxy-api --region eu-central-1",
    "update": "claudia update",
    "generate-proxy": "claudia generate-serverless-express-proxy --express-module server",
    "test": "./node_modules/.bin/mocha --reporter spec"
  },

私が走っているとき:

npm run update

ターミナルでは、問題なく更新できます。しかし、これを CircleCI で実行すると失敗します。

これが私の CircleCI 構成ファイル (.circleci/config.yml) です。

version: 1
jobs:
  build:
    machine:
      node:
        version: 6.11
    working_directory: ~/project
    steps:
      - checkout
      - run:
          name: install
          command: npm install
      - run:
          name: test
          command: npm run test
  build:
    steps:
      - run:
          name: generate-proxy
          command: npm run generate-proxy
      - run:
          name: update
          command: npm run update

CircleCI のエラーは次のとおりです。

#!/bin/bash -eo pipefail
npm run update

> xxx@0.1.0 update /home/circleci/project
> claudia update

loading Lambda config
loading Lambda config   lambda.getFunctionConfiguration FunctionName=xxx
loading Lambda config   lambda.setupRequestListeners
{ CredentialsError: Missing credentials in config
    at IncomingMessage.<anonymous> (/home/circleci/project/node_modules/aws-sdk/lib/util.js:864:34)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:926:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)
  message: 'Missing credentials in config',
  retryable: false,
  time: 2017-06-21T08:02:53.894Z,
  code: 'CredentialsError',
  originalError: 
   { message: 'Could not load credentials from any providers',
     retryable: false,
     time: 2017-06-21T08:02:53.894Z,
     code: 'CredentialsError' } }

以下を含む .aws/credentials というファイルがあります。

[claudia]
aws_access_key_id = xxxxxxx
aws_secret_access_key = xxxxxx

編集:

config.yml を CircleCI 2.0 のものに合わせて変更

version: 2
jobs:
  build:
    working_directory: ~/emailservice
    docker:
      - image: circleci/node:4.8.2
    steps:
      - checkout
      - run:
          name: update-npm
          command: 'sudo npm install -g npm@latest'
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: install
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run:
          name: test
          command: npm run test
      - store_artifacts:
          path: test-results.xml
          prefix: tests
      - store_artifacts:
          path: coverage
          prefix: coverage
      - store_test_results:
          path: test-results.xml
      - run:
          name: deploy_update
          command: npm run update

以前と同様に、資格情報を除いてすべてが機能します。

CircleCI のログファイル:

loading Lambda config
loading Lambda config   lambda.getFunctionConfiguration FunctionName=emailService
loading Lambda config   lambda.setupRequestListeners
{ [CredentialsError: Missing credentials in config]
  message: 'Missing credentials in config',
  code: 'CredentialsError',
  time: Thu Jun 22 2017 08:11:27 GMT+0000 (UTC),
  retryable: true,
  originalError: 
   { message: 'Could not load credentials from any providers',
     code: 'CredentialsError',
     time: Thu Jun 22 2017 08:11:27 GMT+0000 (UTC),
     retryable: true,
     originalError: 
      { message: 'Connection timed out after 1000ms',
        code: 'TimeoutError',
        time: Thu Jun 22 2017 08:11:27 GMT+0000 (UTC),
        retryable: true } } }
npm info lifecycle xxx_email_service@0.2.0~update: Failed to exec update script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! xxx_email_service@0.2.0 update: `claudia update`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the xxx_email_service@0.2.0 update script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/circleci/.npm/_logs/2017-06-22T08_11_27_089Z-debug.log
Exited with code 1

AWS のどこかに資格情報を追加する必要がありますか? ターミナルを使用して展開できます。

4

2 に答える 2

1

リポジトリで言及したファイルに資格情報を保存していますか? まず、おそらくすべきではありません。これはセキュリティ上ノーノーです。もしそうなら、それはにある必要があります~/.aws/credentials。現在の構成に基づいて、リポジトリ全体が のビルドにあり~/emailserviceます。awsディレクトリを作成してから、で資格情報を移動する必要がありますmv。何かのようなもの:

mkdir ~/.aws
mv ~/emailservice/my-creds-file ~/.aws/credenials

または、リポジトリにファイルを持たず、プライベート環境変数を使用することをお勧めします。このシナリオでは、CircleCI の Web UI で変数AWS_ACCESS_KEY_IDを設定します。AWS_SECRET_ACCESS_KEYAWS CLI は、実行時にこれらの認証情報を確認して使用します。

AWS CLI の認証方法は、http: //docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.htmlにあります。

謹んで、

Ricardo N Feliciano
CircleCI 開発者エバンジェリスト


元の応答:

エラーが発生した理由は 100% 正確にはわかりませんが、もっと大きな問題があるようです。その構成ファイルはまったく正しくないようです。CircleCI 1.0 と 2.0 の両方の概念と構成構文が、互換性のない方法で混在しています。https://circleci.com/docs/で構成構文を確認し、使用する CircleCI のバージョンを選択します。

その後、こちらまたはCircleCI Discussでトラブルシューティングを試みることができます。

于 2017-06-22T02:31:50.883 に答える