简体   繁体   English

参数名称的AWS Cloudformation嵌套堆栈参数类型不存在

[英]AWS Cloudformation nested stack parameter type for parameter name does not exist

I'm trying to deploy a parent and nested stacks to AWS with cloudformation. 我正在尝试使用cloudformation将父堆栈和嵌套堆栈部署到AWS。 The parent stack looks like this 父堆栈看起来像这样

AWSTemplateFormatVersion: '2010-09-09'

Parameters:
  VPC:
    Description: Choose which VPC the Lambda-functions should be deployed to
    Type: AWS::EC2::VPC::Id
    Default: vpc-sdjkfnsdjklfn

  Subnets:
    Description: Choose which subnets Lambda-functions should be deployed to
    Type: CommaDelimitedList
    Default: "subnet-sdoifno, subnet-sdofjnsdo"

  SecurityGroup:
    Description: Select the Security Group to use for the Lambda-functions
    Type: AWS::EC2::SecurityGroup::Id
    Default: sg-sdklfnsdkl

  Role:
    Description: Role for Lambda functions
    Type: String
    Default: arn:aws:iam::dlfksd:role/ssdfnsdo

Resources:
  RestApi:
      Type: AWS::ApiGateway::RestApi
      Properties:
        Name: "my-api"
        Description: "SPP Lambda API"

  Stack1:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: 'https://s3.amazonaws.com/bucket/template1.yml'
      Parameters:
        VPC: !Ref VPC
        Subnets: !Join
                   - ','
                   - !Ref Subnets
        SecurityGroup: !Ref SecurityGroup
        Role: !Ref Role
        RestApi: !Ref RestApi
        ApiResourceParent: !GetAtt "RestApi.RootResourceId"

The child stack looks like this 子堆栈看起来像这样

AWSTemplateFormatVersion: '2010-09-09'

Parameters:
  VPC:
    Type: AWS::EC2::VPC::Id

  Subnets:
    Type: CommaDelimitedList

  SecurityGroup:
    Type: AWS::EC2::SecurityGroup::Id

  Role:
    Type: String

  RestApi:
    Type: AWS::ApiGateway::RestApi

  ApiResourceParent:
     Type: AWS::ApiGateway::Resource

Resources:

    Fucntion:
        Type: AWS::Lambda::Function
        Properties:
          Code:
            S3Bucket: bucket
            S3Key: node_lambdas.zip
          Handler: Function.handler
          Role: !Ref Role
          Runtime: nodejs6.10
          Timeout: 300
          VpcConfig:
            SecurityGroupIds:
              - !Ref SecurityGroup
            SubnetIds: !Ref Subnets
          #Policies: AWSLambdaDynamoDBExecutionRole

    Permission:
        Type: AWS::Lambda::Permission
        Properties:
          Action: lambda:InvokeFunction
          FunctionName: !GetAtt "Function.Arn"
          Principal: "apigateway.amazonaws.com"
          SourceArn: !Sub "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${RestApi}/*/*/*"
    Resource:
         Type: AWS::ApiGateway::Resource
         Properties:
           RestApiId: !Ref RestApi
           ParentId: !Ref ApiResourceParent
           PathPart: addadjustments

When I run aws cloudformation deploy --template-file parent-stack.yml --stack-name spp-lambda --region us-east-1 --capabilities CAPABILITY_IAM I get the following error 当我运行aws cloudformation deploy --template-file parent-stack.yml --stack-name spp-lambda --region us-east-1 --capabilities CAPABILITY_IAM出现以下错误

Embedded stack arn:aws:cloudformation:us-east-1:771653148224:stack/spp-lambda-Stack1-97M9BLBUM3A5/4a454a50-c274-11e8-b49c-500c28903236 was not successfully created: Parameter validation failed: parameter type AWS::ApiGateway::RestApi for parameter name RestApi does not exist, parameter type AWS::ApiGateway::Resource for parameter name ApiResourceParent does not exist 嵌入式堆栈arn:aws:cloudformation:us-east-1:771653148224:stack / spp-lambda-Stack1-97M9BLBUM3A5 / 4a454a50-c274-11e8-b49c-500c28903236未成功创建:参数验证失败:参数类型AWS :: ApiGateway参数名称RestApi的:: RestApi不存在,参数名称ApiResourceParent的参数类型AWS :: ApiGateway :: Resource不存在

It doesn't complain about the parameters that are explicitly defined in the parent template. 它不会抱怨父模板中明确定义的参数。 I want the parameters it is complaining about to be created and passed dynamically as I won't know the values before hand. 我想动态创建和传递它抱怨的参数,因为我事先不知道这些值。 What am I doing wrong? 我究竟做错了什么?

Although some of the AWS resource type are supported as a cloudformation parameter type, it doesn't mean all resource type are supported. 尽管将某些AWS资源类型支持为cloudformation参数类型,但这并不意味着支持所有资源类型。

You are trying to reference API gateway value as an AWS-specific parameter type, but it is not supported: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html#aws-specific-parameter-types 您正在尝试将API网关值引用为特定于AWS的参数类型,但不支持它: https : //docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html#aws-具体的参数类型

I believe using String as the type is sufficient. 我相信使用String作为类型就足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM