首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在aws.com上手动删除后无服务器应用编程接口网关资源未返回

在aws.com上手动删除后无服务器应用编程接口网关资源未返回
EN

Stack Overflow用户
提问于 2020-02-09 23:51:49
回答 1查看 952关注 0票数 2

我试图删除我在AWS API Gateway上手动创建的测试GET资源,但它删除了相同资源路径中的POST,现在当我sls deploy该lambda资源时,该资源不会回到API Gateway的资源列表中:

代码语言:javascript
复制
functions:
  updateLibrary:
    environment:
      ...
    handler: updates/lambda.handler
    events:
      - http:
          path: library/updated
          method: post
          private: true

缺少library/updated POST资源?

使用library/updated POST资源的开发阶段的旧部署是什么样子:

sls deploy日志的结果:

代码语言:javascript
复制
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/**-****-*

我看到了:

代码语言:javascript
复制
  patchOperations: 
   [ { op: 'replace'

在这些日志中,可能它只是在尝试执行更新操作,而不是再次尝试创建资源,因为它认为已经存在该资源。我尝试了sls deploy --force,但同样的结果。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-09 23:58:28

这个问题是由Serverless处理、跟踪和部署您的功能和资源的方式引起的。当您删除API Gateway方法时,您实际上手动更改了应用程序的状态,它基本上是不同步的。

要解决此问题,请在serverless.yaml文件中注释掉您手动删除的整个方法,然后运行sls deploy。完成后,取消对该方法的注释,并再次部署sls。这一次,它应该再次部署您的方法。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60138424

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档