【问题标题】:CommaDelimitedList to JSONArray propertyCommaDelimitedList 到 JSONArray 属性
【发布时间】:2021-12-30 07:08:06
【问题描述】:

我有一个 CommaDelimitedList,需要将它作为 JSONArray 放入策略 JSON 属性中:

  Parameters:
    ApiAllowedIps:
      Type: CommaDelimitedList

  RestApi:
    Type: AWS::ApiGateway::RestApi
    Properties:
      ...
      Policy: !Sub | 
        {
           ...
              "Condition": {
                  "NotIpAddress": {
                       "aws:SourceIp": [${ApiAllowedIps}]
                   }
              }
        }

我尝试了很多组合,但都没有成功。

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    通常您会为此使用 YAML,而不是 JSON。例如:

      Parameters:
        ApiAllowedIps:
          Type: CommaDelimitedList
    
      RestApi:
        Type: AWS::ApiGateway::RestApi
        Properties:
          ...
          Policy: 
            Version: "2012-10-17"
            Statement:
              - Effect: Allow
                Action: '*'
                Principal: '*'
                Resource: '*'
                Condition:
                  NotIpAddress:
                    aws:SourceIp: !Ref ApiAllowedIps      
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-29
    • 1970-01-01
    • 2013-03-05
    相关资源
    最近更新 更多