Sha256: 138bf7be6c49ecfc0b5f69de5eb7c12553e6785b45fb8c52aa217b72ceb0c4af

Contents?: true

Size: 884 Bytes

Versions: 15

Compression:

Stored size: 884 Bytes

Contents

module Jets::Cfn::Resource::Iam
  class Policy < Jets::Cfn::Base
    def initialize(role)
      @role = role
    end
    delegate :policy_document, :policy_name, :role_logical_id, :replacements, to: :@role

    def policy_logical_id
      role_logical_id.sub(/Role$/, "Policy")
    end

    def definition
      logical_id = policy_logical_id

      # Do not assign pretty role_name because long controller names might hit the 64-char
      # limit. Also, IAM roles are global, so assigning role names prevents cross region deploys.
      definition = {
        logical_id => {
          Type: "AWS::IAM::Policy",
          Properties: {
            Roles: [Ref: role_logical_id.camelize],
            PolicyName: "#{policy_name[0..127]}", # required, limited to 128-chars
            PolicyDocument: policy_document,
          }
        }
      }

      definition
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

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