Ресурс бессерверного API-шлюза не возвращается после удаления вручную на aws .com - PullRequest
1 голос
/ 09 февраля 2020

Я пытался удалить тестовый GET ресурс, который я создал вручную на AWS API-шлюзе, но он удалил мой POST, который находился в том же пути к ресурсу, и теперь, когда я sls deploy, этот лямбда-ресурс не является возвращаясь к списку ресурсов шлюза API:

functions:
  updateLibrary:
    environment:
      ...
    handler: updates/lambda.handler
    events:
      - http:
          path: library/updated
          method: post
          private: true

Отсутствует ресурс library/updated POST 100

AWS API Gateway Resources, missing resource

Как выглядит старое развертывание этапа разработки с ресурсом library/updated POST:

enter image description here

Что приводит к журналам sls deploy:

Serverless: Stack update finished...
Serverless: Invoke aws:info
Serverless: [AWS cloudformation 200 0.484s 0 retries] describeStacks({ StackName: '***********-********-***' })
Serverless: [AWS cloudformation 200 0.508s 0 retries] listStackResources({ StackName: '***********-********-***' })
Service Information
service: ***********-********
stage: dev
region: **-****-*
stack: ***********-********-***
resources: 26
api keys:
  None
endpoints:
  POST - https://**********.execute-api.**-****-*.amazonaws.com/dev/library/updated
  POST - https://**********.execute-api.**-****-*.amazonaws.com/dev/merge/approved
functions:
  updateLibrary: ***********-********-***-updateLibrary
  mergePR: ***********-********-***-mergePR
layers:
  None
Serverless: [AWS sts 200 0.452s 0 retries] getCallerIdentity({})
Serverless: [AWS apigateway 200 0.633s 0 retries] getRestApis({ position: undefined, limit: 500 })
Serverless: [AWS apigateway 200 0.404s 0 retries] getStage({ restApiId: '**********', stageName: 'dev' })
Serverless: [AWS apigateway 200 0.577s 0 retries] updateStage({ restApiId: '**********',
  stageName: 'dev',
  patchOperations: 
   [ { op: 'replace',
       path: '/accessLogSettings/destinationArn',
       value: 'arn:aws:logs:**-****-*:**************:log-group:/aws/api-gateway/***********-********-***' },
     { op: 'replace',
       path: '/accessLogSettings/format',
       value: '{"requestTime":"$context.requestTime","requestId":"$context.requestId","apiId":"$context.apiId","resourceId":"$context.resourceId","resourcePath":"$context.resourcePath","path":"$context.path","httpMethod":"$context.httpMethod","status":"$context.status","authLatency":"$context.authorizer.integrationLatency","integrationLatency":"$context.integrationLatency","integrationStatus":"$context.integrationStatus","responseLatency":"$context.responseLatency","responseLength":"$context.responseLength","errorMessage":"$context.error.message","format":"SLS_ACCESS_LOG","version":"1.0.0"}' },
     { op: 'replace', path: '/*/*/logging/dataTrace', value: 'true' },
     { op: 'replace', path: '/*/*/logging/loglevel', value: 'INFO' },
     [length]: 4 ] })
Serverless: Invoke aws:deploy:finalize
Serverless: [AWS s3 200 0.511s 0 retries] listObjectsV2({ Bucket: '***********-********-***-serverlessdeploymentbucket-**************',
  Prefix: 'serverless/***********-********/dev' })
Serverless: Removing old service artifacts from S3...
Serverless: [AWS s3 200 0.503s 0 retries] deleteObjects({ Bucket: '***********-********-***-serverlessdeploymentbucket-**************',
  Delete: 
   { Objects: 
      [ { Key: 'serverless/***********-********/dev/******************-2020-02-09T03:31:30.226Z/***********-********.zip' },
        { Key: 'serverless/***********-********/dev/******************-2020-02-09T03:31:30.226Z/compiled-cloudformation-template.json' },
        { Key: 'serverless/***********-********/dev/******************-2020-02-09T03:31:30.226Z/custom-resources.zip' },
        [length]: 3 ] } })
Serverless: Publishing service to the Serverless Dashboard...
Serverless: [AWS sts 200 0.432s 0 retries] getCallerIdentity({})
Serverless: [AWS cloudformation 200 0.49s 0 retries] describeStacks({ StackName: '***********-********-***' })
platform-sdk fetching: POST https://api.serverless.com/core/tenants/********/applications/******-*****-*******/services/***********-********/stages/dev/regions/**-****-*/deployments
Serverless: Successfully published your service to the Serverless Dashboard: https://dashboard.serverless.com/tenants/********/applications/******-*****-*******/services/***********-********/stage/dev/region/**-****-*

Я вижу:

  patchOperations: 
   [ { op: 'replace'

в этих журналах, возможно, он просто пытается выполнить операцию обновления и не пытается снова создать ресурс, потому что он думает, что вы уже там. Я пытался sls deploy --force, но тот же результат.

1 Ответ

2 голосов
/ 09 февраля 2020

Проблема вызвана тем, как Serverless обрабатывает, отслеживает и развертывает ваши функции и ресурсы. Когда вы удалили метод API Gateway, вы фактически изменили состояние своего приложения вручную, и оно в основном не синхронизировано c.

Чтобы решить эту проблему, в файле serverless.yaml закомментируйте весь метод что вы удалили вручную, и запустите sls deploy. По окончании раскомментируйте метод и sls разверните снова. На этот раз он должен развернуть ваш метод снова.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...