CommaDelimitedList 到 JSONArray 属性

CommaDelimitedList to JSONArray property

我有一个 CommaDelimitedList,需要将其放入策略 JSON 属性 作为 JSONA​​rray:

  Parameters:
    ApiAllowedIps:
      Type: CommaDelimitedList

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

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

通常您会为此使用 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