Sha256: 59f47aa5c833de10d41811cda8361d300c87e0416b79ae1289434cb2bfcc6836

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

# Class that inherits this base class should implement:
#
#   initialize
#   iam_policy
#   logical_id
#   role_name
#
module Jets::Cfn::TemplateMappers::IamPolicy
  class BasePolicyMapper
    extend Memoist

    def properties
      properties = {
        AssumeRolePolicyDocument: {
          Version: "2012-10-17",
          Statement: [{
            Effect: "Allow",
            Principal: {Service: ["lambda.amazonaws.com"]},
            Action: ["sts:AssumeRole"]}
          ]},
        Path: "/"
      }
      properties[:Policies] = [
        PolicyName: iam_policy.policy_name,
        PolicyDocument: iam_policy.policy_document,
      ]
      properties[:RoleName] = role_name
      properties.deep_stringify_keys!
      properties
    end

    def namespace
      Jets.config.project_namespace.underscore
    end

    # Need to underscore and then classify again for this case:
    #   Jets::PreheatJob_policy => JetsPreheatJobPolicy
    # Or else you we get this:
    #   Jets::PreheatJob_policy => JetsPreheatjobPolicy
    def classify_name(text)
      text.gsub('::','_').underscore.classify
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jets-0.6.9 lib/jets/cfn/template_mappers/iam_policy/base_policy_mapper.rb
jets-0.6.8 lib/jets/cfn/template_mappers/iam_policy/base_policy_mapper.rb
jets-0.6.7 lib/jets/cfn/template_mappers/iam_policy/base_policy_mapper.rb
jets-0.6.6 lib/jets/cfn/template_mappers/iam_policy/base_policy_mapper.rb
jets-0.6.5 lib/jets/cfn/template_mappers/iam_policy/base_policy_mapper.rb
jets-0.6.4 lib/jets/cfn/template_mappers/iam_policy/base_policy_mapper.rb
jets-0.6.3 lib/jets/cfn/template_mappers/iam_policy/base_policy_mapper.rb
jets-0.6.2 lib/jets/cfn/template_mappers/iam_policy/base_policy_mapper.rb
jets-0.6.1 lib/jets/cfn/template_mappers/iam_policy/base_policy_mapper.rb
jets-0.6.0 lib/jets/cfn/template_mappers/iam_policy/base_policy_mapper.rb