Giter VIP home page Giter VIP logo

Comments (7)

troyready avatar troyready commented on June 21, 2024 1

I'm interesting in doing this as well, for exactly the reason you mentioned (alongside chosen parameter values for the stack) -- it'd be nice to have a representation of the deployed infrastructure in revision control.

Would you be open to a pull request along those lines? Thus far I've experimented with a quick hack, and have the ARGV options (e.g. stack name) check for global variables as well, e.g.,

$stack_name = "myfancy_stack"

template do

  value AWSTemplateFormatVersion: '2010-09-09'
  value Description: 'blah'
 ...
end.exec!

I'd obviously be open to doing it more correctly though (variables passed around the methods? moving the standalone methods to a class that could share the variables?).

from cloudformation-ruby-dsl.

jonaf avatar jonaf commented on June 21, 2024

Hi @z0mbix , there's currently not any way to do that. What's the motivation? Would you like to keep the stack name in source control?

from cloudformation-ruby-dsl.

SaltwaterC avatar SaltwaterC commented on June 21, 2024

Tried the ARGV way for a while, but now I'm trying to make all the stacks available as library calls which makes ARGV a non thread-safe option. So far, I ended up monkey-patching TemplateDSL:

class TemplateDSL
  def name(stack_name)
    @stack_name = stack_name
  end
end

Adding stack_name as attr_accessor (it's already defined as attr_reader) doesn't make instance_eval happy, hence the explicit setter with a different name. The templates now read something like:

template do
  name 'foo'
  value AWSTemplateFormatVersion: '2010-09-09'
  # ...
end

from cloudformation-ruby-dsl.

jonaf avatar jonaf commented on June 21, 2024

I like the format of the resulting template from your example, @SaltwaterC . I think I'd rather see if we can swap to an attr_accessor in the actual implementation, but I like where this is headed.

from cloudformation-ruby-dsl.

SaltwaterC avatar SaltwaterC commented on June 21, 2024

I went the setter way because attr_* doesn't play nice with instance_eval.

from cloudformation-ruby-dsl.

temujin9 avatar temujin9 commented on June 21, 2024

@SaltwaterC I like this, and it doesn't feel like it would break anything too hard. Can I encourage you to turn this monkey-patch into a pull request, instead?

from cloudformation-ruby-dsl.

temujin9 avatar temujin9 commented on June 21, 2024

Turns out this entirely unnecessary: you can just manually set using:

template do
  @stack_name = 'foo'
  [...]
end

and it works fine without any code changes.

from cloudformation-ruby-dsl.

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.