Giter Site home page Giter Site logo

Comments (5)

cmaxwellau avatar cmaxwellau commented on July 20, 2024 1

Surely this can be closed now

from cfndsl.

stevenjack avatar stevenjack commented on July 20, 2024

@rprieto I know the pain you feel it's a real pain creating the userdata scripts line-by-line when you need to interpolate stack params inside the file.

Currently it's not something cfndsl supports natively. I think as you mentioned in your last comment, it's not that being able to turn a file into the string type cfndsl expects would be difficult but more how we express all the different types such as FindInMap in the file you'd like to parse being the harder part.

Let me have a think about this, there might be a more elegant way around it. @howech any thoughts?

from cfndsl.

rprieto avatar rprieto commented on July 20, 2024

Thanks for getting back to me, keen to see how the conversation progresses!

from cfndsl.

howech avatar howech commented on July 20, 2024

Cfndsl adds a fake function called "FnFormat" that turns interpolates strings with %{tag} style tags into Fn::Join and Fn::Ref functions as required. For instance FnFormat ( "Hello %{world}") would turn into the cfn jason {"Fn::Join":["", ["Hello ", {"Ref": "world"}]}. Between that an ruby ' File.read call, you can probably get a long way towards what you are looking for.

from cfndsl.

herebebogans avatar herebebogans commented on July 20, 2024

The addition of FnSub() now makes this pretty simple - variables in template get interpolated via ${} tags at CF runtime. So for your example.

cfndsl template

USER_DATA=File.read('userdata.sh')
....snipped...
UserData FnBase64(FnSub(USER_DATA))

userdata.sh

#!/bin/bash -vx
/opt/aws/bin/cfn-init -s ${AWS::StackId} -r LaunchConfig --region ${AWS::Region}
sh /tmp/setup.sh
sleep 5
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource ServiceFleet --region ${AWS::Region}

from cfndsl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.