class Terraforming::Resource::IAMGroup

Public Class Methods

new(client) click to toggle source
# File lib/terraforming/resource/iam_group.rb, line 14
def initialize(client)
  @client = client
end
tf(client: Aws::IAM::Client.new) click to toggle source
# File lib/terraforming/resource/iam_group.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_group.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_group.rb, line 18
def tf
  apply_template(@client, "tf/iam_group")
end
tfstate() click to toggle source
# File lib/terraforming/resource/iam_group.rb, line 22
def tfstate
  iam_groups.inject({}) do |resources, group|
    attributes = {
      "arn" => group.arn,
      "id" => group.group_name,
      "name" => group.group_name,
      "path" => group.path,
      "unique_id" => group.group_id,
    }
    resources["aws_iam_group.#{module_name_of(group)}"] = {
      "type" => "aws_iam_group",
      "primary" => {
        "id" => group.group_name,
        "attributes" => attributes
      }
    }

    resources
  end
end

Private Instance Methods

iam_groups() click to toggle source
# File lib/terraforming/resource/iam_group.rb, line 45
def iam_groups
  @client.list_groups.map(&:groups).flatten
end
module_name_of(group) click to toggle source
# File lib/terraforming/resource/iam_group.rb, line 49
def module_name_of(group)
  normalize_module_name(group.group_name)
end