在打字稿中部署项目时,CodePipeline 中出现“无法上传工件”错误

问题描述

我正在将 lambda 项目从 javascript 迁移到打字稿,但 CodeBuild 步骤在部署中总是失败,我不明白是什么原因导致问题

这是我的构建规范:

version: 0.2
phases:
  install:
    commands:
      - apt-get update
      - npm i yarn -g
      - yarn --ignore-engines
      - find ./node_modules -mtime +10950 -exec touch {} +
      - rm -rf ./docs
  build:
    commands:
      - yarn compile:server
      - aws cloudformation package
        --template-file templates/samTemplate.yaml
        --s3-bucket ${CFN_BUCKET}
        --output-template-file templates/outputSamTemplate.yaml
artifacts:
  type: zip
  files:
    - '**/*'


Unable to upload artifact ./../ referenced by CodeUri parameter of MyLambda resource.
'ascii' codec can't decode byte 0xe6 in position 1: ordinal not in range(128)

这是我的 lambda 的 CloudFormation 部分:

  MyLambda:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: !Sub "lambda"
      Role: !GetAtt LambdaRole.Arn
      CodeUri: ./../
      Handler: dist/handler/lambda.lambda
      Runtime: nodejs12.x
      Timeout: 30

有人知道可能会发生什么吗?

解决方法

查看documentation。您的代码路径似乎格式不正确。