bazaarvoice / cloudformation-ruby-dsl

Ruby DSL for creating Cloudformation templates
Apache License 2.0
210 stars 76 forks source link

Allow nested code in interpolate() #106

Closed Carles-Figuerola closed 7 years ago

Carles-Figuerola commented 7 years ago

There seems to be no way for nested functions to be used inside an interpolated file.

Something like:

  - [ bash, -xc, "{{ fn_if('isExternal', 'AWS_REGION=ref(\'AWS::Region\') AWS_ROLE_ARN=arn:aws:iam::find_in_map(\'EnvToAccountNumber\', ref(\'Environment\'), \'AccountNumber\'):role/StockyardExternalAccess awssume ','' ) }}aws s3 cp s3://evac-chef-{{ ref('Environment') }}/s-evac.pem /" ]

something like this would be ideal:

  - [ bash, -xc, "{{ fn_if('isExternal', 'AWS_REGION={{ ref(\'AWS::Region\') }} AWS_ROLE_ARN=arn:aws:iam::{{ find_in_map(\'EnvToAccountNumber\', ref(\'Environment\'), \'AccountNumber\') }}:role/StockyardExternalAccess awssume ','' ) }}aws s3 cp s3://evac-chef-{{ ref('Environment') }}/s-evac.pem /" ]

but the regex that interpolate uses won't work for this as it will thing the nested function is closing the outer function:

    head, match, string = string.partition(/\{\{.*?\}\}/)