Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services AWS Cloudformation模板for AWS::ApiGateway::Resource:如何为RequestParameter创建动态密钥?_Amazon Web Services_Templates_Amazon Cloudformation_Aws Api Gateway_Querystringparameter - Fatal编程技术网

Amazon web services AWS Cloudformation模板for AWS::ApiGateway::Resource:如何为RequestParameter创建动态密钥?

Amazon web services AWS Cloudformation模板for AWS::ApiGateway::Resource:如何为RequestParameter创建动态密钥?,amazon-web-services,templates,amazon-cloudformation,aws-api-gateway,querystringparameter,Amazon Web Services,Templates,Amazon Cloudformation,Aws Api Gateway,Querystringparameter,我正在创建一个cloudformation嵌套模板,该模板创建一个AWS::ApiGateway::Method。该方法具有从父堆栈接收作为参数的名称的查询字符串,如下所示: Parameters: #...other parameters queryStringName: Type: String queryStringMandatory Type: String AllowedValues: [true,false] R

我正在创建一个cloudformation嵌套模板,该模板创建一个
AWS::ApiGateway::Method
。该方法具有从父堆栈接收作为参数的名称的查询字符串,如下所示:

Parameters:
    #...other parameters
    queryStringName:
        Type: String
    queryStringMandatory
        Type: String
        AllowedValues: [true,false]
Resources:
    ApiGatewayMethod:
        Type: 'AWS::ApiGatewayMethod::Method'
        Properties:
        #... other properties
        RequestParameters:
            # here I want to inject somehow the queryStringName into the key definition
            method.request.querystring.{$queryStringName}: !Ref queryStringMandatory #doesnt work
RequestParameters:
  method.request.querystring.queryStringName: true
问题在于,当前定义查询字符串的方式如下:

Parameters:
    #...other parameters
    queryStringName:
        Type: String
    queryStringMandatory
        Type: String
        AllowedValues: [true,false]
Resources:
    ApiGatewayMethod:
        Type: 'AWS::ApiGatewayMethod::Method'
        Properties:
        #... other properties
        RequestParameters:
            # here I want to inject somehow the queryStringName into the key definition
            method.request.querystring.{$queryStringName}: !Ref queryStringMandatory #doesnt work
RequestParameters:
  method.request.querystring.queryStringName: true
其中true表示查询字符串是否为必填项。通过这种方式,queryString名称位于左侧部分(键定义部分),您不能在那里使用内部函数或
!Ref

是否有我遗漏的东西或有解决方法?

我不知道有“解决方法”。对我来说,这更像是AWS云开发工具包的一个用例。您可以使用标准代码(例如Python)动态生成CloudFormation模板,然后将i输入到部署步骤中,这正是您想要实现的。类似于为您创建的AWS代码管道或microservice会根据您的需要返回正确的CF模板:我不知道有什么“解决方法”。对我来说,这更像是AWS云开发工具包的一个用例。您可以使用标准代码(例如Python)动态生成CloudFormation模板,然后将i输入到部署步骤中,这正是您想要实现的。类似于为您创建的AWS代码行或microservice会根据您的需要返回正确的CF模板: