Sha256: afdd54ae49a6a9cc6d3fe044c7bc3c5deeaf4b0f49f4e3ca23a0323340f60702

Contents?: true

Size: 886 Bytes

Versions: 13

Compression:

Stored size: 886 Bytes

Contents

module Jets::Resource::Iam
  class Policy < Jets::Resource::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],
            policy_name: "#{policy_name[0..127]}", # required, limited to 128-chars
            policy_document: policy_document,
          }
        }
      }

      definition
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
jets-4.0.12 lib/jets/resource/iam/policy.rb
jets-4.0.11 lib/jets/resource/iam/policy.rb
jets-4.0.10 lib/jets/resource/iam/policy.rb
jets-4.0.9 lib/jets/resource/iam/policy.rb
jets-4.0.8 lib/jets/resource/iam/policy.rb
jets-4.0.7 lib/jets/resource/iam/policy.rb
jets-4.0.6 lib/jets/resource/iam/policy.rb
jets-4.0.5 lib/jets/resource/iam/policy.rb
jets-4.0.4 lib/jets/resource/iam/policy.rb
jets-4.0.3 lib/jets/resource/iam/policy.rb
jets-4.0.2 lib/jets/resource/iam/policy.rb
jets-4.0.1 lib/jets/resource/iam/policy.rb
jets-4.0.0 lib/jets/resource/iam/policy.rb