Home > Net >  CommaDelimitedList to JSONArray property
CommaDelimitedList to JSONArray property

Time:12-30

I have a CommaDelimitedList and need to put it into a policy JSON property as JSONArray:

  Parameters:
    ApiAllowedIps:
      Type: CommaDelimitedList

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

I tried many combinations but without success.

CodePudding user response:

Normally you would use YAML for that, not JSON. For example:

  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      
  • Related