class Terraforming::Resource::IAMRole
Public Class Methods
new(client)
click to toggle source
# File lib/terraforming/resource/iam_role.rb, line 14 def initialize(client) @client = client end
tf(client: Aws::IAM::Client.new)
click to toggle source
# File lib/terraforming/resource/iam_role.rb, line 6 def self.tf(client: Aws::IAM::Client.new) self.new(client).tf end
tfstate(client: Aws::IAM::Client.new)
click to toggle source
# File lib/terraforming/resource/iam_role.rb, line 10 def self.tfstate(client: Aws::IAM::Client.new) self.new(client).tfstate end
Public Instance Methods
tf()
click to toggle source
# File lib/terraforming/resource/iam_role.rb, line 18 def tf apply_template(@client, "tf/iam_role") end
tfstate()
click to toggle source
# File lib/terraforming/resource/iam_role.rb, line 22 def tfstate iam_roles.inject({}) do |resources, role| attributes = { "arn" => role.arn, "assume_role_policy" => prettify_policy(role.assume_role_policy_document, breakline: true, unescape: true), "id" => role.role_name, "name" => role.role_name, "path" => role.path, "unique_id" => role.role_id, } resources["aws_iam_role.#{module_name_of(role)}"] = { "type" => "aws_iam_role", "primary" => { "id" => role.role_name, "attributes" => attributes } } resources end end
Private Instance Methods
iam_roles()
click to toggle source
# File lib/terraforming/resource/iam_role.rb, line 47 def iam_roles @client.list_roles.map(&:roles).flatten end
module_name_of(role)
click to toggle source
# File lib/terraforming/resource/iam_role.rb, line 51 def module_name_of(role) normalize_module_name(role.role_name) end