amazon-web-services - AWS Nested Stacks - 引用父堆栈的资源

标签 amazon-web-services aws-api-gateway aws-cloudformation serverless-framework serverless

我试图通过堆栈参数将资源(ApiGatewayRestApi 和自定义授权者)传递到嵌套堆栈,但是,它们不断失败,并显示 Embedded stack <stack_name> was not successfully created: The following resource(s) failed to create 。这是我在无服务器中的设置:

父堆栈

{
    ...
    "NestedStack": {
    "Type": "AWS::CloudFormation::Stack",
    "Properties": {
      "Parameters": {
        "ServerlessDeploymentBucket": {
          "Ref": "ServerlessDeploymentBucket"
        },
        "ApiGatewayRestApi": {
          "Ref": "ApiGatewayRestApi"
        },
        "AuthDashjwtApiGatewayAuthorizer": {
          "Ref": "AuthDashjwtApiGatewayAuthorizer"
        },
      },
      "TemplateURL": "..."
    }
  },
}

嵌套堆栈

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Nested Stack",
  "Parameters": {
    "ServerlessDeploymentBucket": { "Type": "String" },
    "ApiGatewayRestApi": {
      "Description": "Rest API",
      "Type": "String"
    },
    "AuthDashjwtApiGatewayAuthorizer": { "Type": "String" },
  },
  "Resources": {
      "ApiGatewayMethodEventsEventidVarStreamsPost": {
        "Type": "AWS::ApiGateway::Method",
        "Properties": {
          "HttpMethod": "POST",
          "RequestParameters": {},
          "ResourceId": { "Ref": "ApiGatewayResourceEventsEventidVarStreams" },
          "RestApiId": { "Ref": "ApiGatewayRestApi" },
          "AuthorizationType": "CUSTOM",
          "AuthorizerId": { "Ref": "AuthDashjwtApiGatewayAuthorizer" },
          ...
        }
        ...
     }
     ...
}

我没有正确引用或传递参数吗?

根据评论更新 除非我遗漏了什么,否则控制台 CF 部分中的唯一错误消息是:

Embedded stack <stac_name> was not successfully created: The 
following resource(s) failed to create: [PatchDasheventLogGroup, 
PostDashstreamLogGroup, GetDashstreamsLogGroup, GetDasheventsLogGroup, 
ApiGatewayRestApi, GetDasheventLogGroup, PostDasheventLogGroup, 
AuthDashjwtApiGatewayAuthorizer]

就日志组而言,它们看起来像这样:

"GetDasheventLogGroup": {
  "Type": "AWS::Logs::LogGroup",
  "Properties": { 
     "LogGroupName": "/aws/lambda/live-api-local-get-event"
   }
}

更新2 日志组问题是由于这些日志已从父堆栈移动到嵌套堆栈并需要新名称。在 LogGroup我找到的文档:

If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.

这看起来可能已经解决了问题...需要更多测试来确认!

最佳答案

@speshak 的评论最终让我找到了答案。我不需要按 Failed 状态进行过滤,而是按 Deleted 进行过滤。这使我能够查看已创建的嵌套堆栈的日志,然后使用更具体的消息进行删除。

这最终向我展示的是,update-stack 进程正在将嵌套堆栈应用到我当前的设置,然后再从根堆栈中删除所有资源。所以真正的问题是我不小心尝试创建重复的资源 - AWS 在嵌套堆栈中看到与根堆栈匹配的资源,并因验证错误而被踢出,即使该资源已从根堆栈中删除。 ..最终。

关于amazon-web-services - AWS Nested Stacks - 引用父堆栈的资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48216035/

相关文章:

json - Cloudformation 列表和字符串::SecurityGroupIds 属性的值必须是字符串列表类型

amazon-web-services - Cfn-Lint : Property "ExecutionRoleArn" has no valid Refs to Resources at Resources/TaskDefinition/Properties/ExecutionRoleArn/Ref

amazon-web-services - AWS Cloudformation/Codepipeline 参数 : [ProjectId] must have values

c# - 使用 .NET SDK 的 Cloudfront 签名 URL 不适用于带有空格的 S3 内容处置文件名

java - 创建n个任务并在Spring Batch中并行执行它们

amazon-web-services - 安排 Docker 镜像在 AWS ECS 上定期运行?

java - 从AWS- Hadoop删除文件系统

amazon-web-services - AWS API Gateway 禁止连续请求

python - 返回 header 内容 - API 网关 + AWS Lambda

amazon-web-services - AWS 网关 API 和文件响应