Sha256: 958ce1c337f823ef008ab846dd4837de0d5d29b69598af7e9d974ea75d41d7f8

Contents?: true

Size: 863 Bytes

Versions: 15

Compression:

Stored size: 863 Bytes

Contents

# Implements:
#
#   template - uses @definition to build a CloudFormation template section
#
class Jets::Stack
  class Resource
    include Definition

    def template
      template = camelize(standarize(@definition))
      template = replace_placeholers(template)
      template
    end

    # CloudFormation Resources reference: https://amzn.to/2NKg6ip
    def standarize(definition)
      Jets::Cfn::Resource::Standardizer.new(definition).template
    end

    def replace_placeholers(template)
      attributes = template.values.first
      s3_key = attributes.dig(:Properties,:Code,:S3Key)
      if s3_key == "code_s3_key_placeholder"
        checksum = Jets::Builders::Md5.checksums["stage/code"]
        code_zip = "code-#{checksum}.zip"
        attributes[:Properties][:Code][:S3Key] = "jets/code/#{code_zip}"
      end
      template
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/stack/resource.rb
jets-5.0.12 lib/jets/stack/resource.rb
jets-5.0.11 lib/jets/stack/resource.rb
jets-5.0.10 lib/jets/stack/resource.rb
jets-5.0.9 lib/jets/stack/resource.rb
jets-5.0.8 lib/jets/stack/resource.rb
jets-5.0.7 lib/jets/stack/resource.rb
jets-5.0.6 lib/jets/stack/resource.rb
jets-5.0.5 lib/jets/stack/resource.rb
jets-5.0.4 lib/jets/stack/resource.rb
jets-5.0.3 lib/jets/stack/resource.rb
jets-5.0.2 lib/jets/stack/resource.rb
jets-5.0.1 lib/jets/stack/resource.rb
jets-5.0.0 lib/jets/stack/resource.rb
jets-5.0.0.beta1 lib/jets/stack/resource.rb