Iterating over a file in Serverless Framework

28 views Asked by At

I am trying to deploy prefix list and ssm paramater using serverless (sls). Below is iplist.yml file inside ip/ folder

IPs:
  - Cidr: “10.0.0.1/32”
    Description: “Test ip1”
  - Cidr: "10.0.0.2/32"
    Description: “Test ip2”
  - Cidr: "10.0.0.3/32"
    Description: “Test ip3”

For prefix list entries, I am passing the file using ${file(ip/iplist.yml):Ip-entries} which is working but for creating the SSM parameter, I wanted to fetch all the IPs in a comma separated string, please suggest if it is possible in Serverless Framework?

service: test
provider:
  name: aws
  stackName: test-stack

resources:
  Resources:
    TestPrefixList:
      Type: AWS::EC2::PrefixList
      Properties:
        PrefixListName: test-pl
        AddressFamily: IPv4
        MaxEntries: 60
        Entries: ${file(ip/iplist.yml):IPs}

    TestParamater:
      Type: AWS::SSM::Parameter
      Properties:
        Name: test-param
        Type: StringList
        Value: <<WANTED TO GET COMMA-SEPARATED IPs LIKE - "10.0.0.1/32,10.0.0.2/32,10.0.0.3/32">>

0

There are 0 answers