Sha256: 454c57009bd47e0d1eaefe4586c96bbd78f9e8d27f1aa8cd8bd53f59037c97e4

Contents?: true

Size: 1.48 KB

Versions: 21

Compression:

Stored size: 1.48 KB

Contents

class Jets::Cfn::TemplateMappers
  class ChildMapper
    attr_reader :path
    def initialize(path, s3_bucket)
      # "#{Jets.build_root}/templates/demo-dev-posts_controller.yml"
      @path = path
      @s3_bucket = s3_bucket
    end

    # common parameters to all child stacks
    def parameters
      parameters = {
        # YAML.dump converts it to a string
        # !GetAtt Base.Outputs.IamRole => "!GetAtt Base.Outputs.IamRole"
        # But post processing of the template fixes this
        IamRole: "!GetAtt IamRole.Arn",
        S3Bucket: "!Ref S3Bucket",
      }
    end

    # Example: PostsController
    def logical_id
      regexp = Regexp.new(".*#{Jets.config.project_namespace}-")
      contoller_name = @path.sub(regexp, '').sub('.yml', '')
      # map the path to a camelized logical_id. Example:
      #   /tmp/jets/demo/templates/demo-dev-2-posts_controller.yml to
      #   PostsController
      contoller_name.underscore.camelize
    end

    def template_url
      # here's where it gets interesting with the bucket. The bucket will
      # need to exist for the child templates.  But wont be created until the stack
      # has been first launched.  We can create the bucket in a separate stack
      # And then grab it and then store it in a cache file.
      basename = File.basename(@path)
      # IE: https://s3.amazonaws.com/[bucket]/jets/cfn-templates/demo-dev-posts_controller.yml"
      "https://s3.amazonaws.com/#{@s3_bucket}/jets/cfn-templates/#{basename}"
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
jets-0.7.1 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.7.0 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.6.9 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.6.8 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.6.7 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.6.6 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.6.5 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.6.4 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.6.3 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.6.2 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.6.1 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.6.0 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.5.8 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.5.7 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.5.6 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.5.5 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.5.4 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.5.3 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.5.2 lib/jets/cfn/template_mappers/child_mapper.rb
jets-0.5.1 lib/jets/cfn/template_mappers/child_mapper.rb