gpt4 book ai didi

amazon-web-services - 无法在 Cloudformation 模板中为 AWS::ApiGateway::Resource 指定资源标识符

转载 作者:行者123 更新时间:2023-12-03 07:40:07 25 4
gpt4 key购买 nike

我正在使用 SAM 部署一个简单的 Hello world 应用程序。一个具有一个 API 端点,这将触发一个返回文本 hello world 的 lambda 函数。我定义了以下资源:

  1. IAM 角色,以便 APIGateway 可以调用 lambda 函数。
  2. AWS::ApiGateway::RestApi
  3. AWS::ApiGateway::资源
  4. AWS::ApiGateway::方法
  5. AWS::Serverless::函数

诚然,我还不知道 2. 和 3. 之间的功能差异。

sam部署期间,我看到以下错误。

ROLLBACK_IN_PROGRESS                              AWS::CloudFormation::Stack                        go-hello-world                                    The following resource(s) failed to create:     
[HelloWorldAPIResource,
HelloWorldFunctionRole]. Rollback requested by
user.
CREATE_FAILED AWS::IAM::Role HelloWorldFunctionRole Resource creation cancelled
CREATE_FAILED AWS::ApiGateway::Resource HelloWorldAPIResource Resource handler returned message: "Invalid
Resource identifier specified (Service:
ApiGateway, Status Code: 404, Request ID:
62f34d79-86ab-47fd-85b1-5fbb55071520, Extended
Request ID: null)" (RequestToken:
9633d7db-7b6d-881b-f54e-ca0114862fd8,
HandlerErrorCode: NotFound)

这意味着 AWS::ApiGateway::Resource 未获取对 AWS::ApiGateway::RestApi 的有效引用。

这是我的template.yml中的相关部分

  HelloWorldAPI:
Type: AWS::ApiGateway::RestApi
Properties:
Name: HelloWorldApi

HelloWorldAPIResource:
Type: AWS::ApiGateway::Resource
Properties:
RestApiId: !Ref HelloWorldAPI
ParentId: "/"
PathPart: hello

总的来说,我对 CloudFormation 和 AWS 都很陌生,非常感谢任何帮助。

最佳答案

应该是:

 ParentId: !GetAtt HelloWorldAPI.RootResourceId

关于amazon-web-services - 无法在 Cloudformation 模板中为 AWS::ApiGateway::Resource 指定资源标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71081939/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com