<commit_before>require_relative '../resource'

module Convection
  module DSL
    module Template
      module Resource
        ## Role DSL
        module IAMRole
          def policy(policy_name, &block)
            add_policy = Model::Mixin::Policy.new(:name => policy_name, :template => @template)
            add_policy.instance_exec(&block) if block

            policies << add_policy
          end

          ## Create an IAM Instance Profile for this role
          def with_instance_profile(&block)
            profile = Model::Template::Resource::IAMInstanceProfile.new("#{ name }Profile", @template)
            profile.role(self)
            profile.path(path)

            profile.instance_exec(&block) if block
            @instance_profile = profile
            @template.resources[profile.name] = profile
          end

          ## Add a canned trust policy for any AWS service
          def trust_service(name, policy_name = nil, &block)
            policy_name ||= "trust-#{name}-service"<commit_msg>Fix #129 - Add an assume_role_policy DSL method to iam_role<commit_after>require_relative '../resource'

module Convection
  module DSL
    module Template
      module Resource
        ## Role DSL
        module IAMRole
          def assume_role_policy(policy_name, &block)
            @trust_relationship = Model::Mixin::Policy.new(:name => policy_name, :template => @template)
            trust_relationship.instance_exec(&block) if block
          end

          def policy(policy_name, &block)
            add_policy = Model::Mixin::Policy.new(:name => policy_name, :template => @template)
            add_policy.instance_exec(&block) if block

            policies << add_policy
          end

          ## Create an IAM Instance Profile for this role
          def with_instance_profile(&block)
            profile = Model::Template::Resource::IAMInstanceProfile.new("#{ name }Profile", @template)
            profile.role(self)
            profile.path(path)

            profile.instance_exec(&block) if block
            @instance_profile = profile
            @template.resources[profile.name] = profile
          end

          ## Add a canned trust policy for any AWS service
          def trust_service(name, policy_name = nil, &block)
            policy_name ||= "trust-#{name}-service"
{'fraction_non_alphanumeric': 0.09267241379310345, 'fraction_numerical': 0.001293103448275862, 'mean_word_length': 2.292198581560284, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2491590', 'n_tokens_mistral': 604, 'n_tokens_neox': 586, 'n_words': 157}