class Terraforming::Resource::IAMGroupPolicy
Public Class Methods
new(client)
click to toggle source
# File lib/terraforming/resource/iam_group_policy.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_policy.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_policy.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_policy.rb, line 18 def tf apply_template(@client, "tf/iam_group_policy") end
tfstate()
click to toggle source
# File lib/terraforming/resource/iam_group_policy.rb, line 22 def tfstate iam_group_policies.inject({}) do |resources, policy| attributes = { "group" => policy.group_name, "id" => iam_group_policy_id_of(policy), "name" => policy.policy_name, "policy" => prettify_policy(policy.policy_document, breakline: true, unescape: true) } resources["aws_iam_group_policy.#{unique_name(policy)}"] = { "type" => "aws_iam_group_policy", "primary" => { "id" => iam_group_policy_id_of(policy), "attributes" => attributes } } resources end end
Private Instance Methods
iam_group_policies()
click to toggle source
# File lib/terraforming/resource/iam_group_policy.rb, line 64 def iam_group_policies iam_groups.map do |group| iam_group_policy_names_in(group).map { |policy_name| iam_group_policy_of(group, policy_name) } end.flatten end
iam_group_policy_id_of(policy)
click to toggle source
# File lib/terraforming/resource/iam_group_policy.rb, line 48 def iam_group_policy_id_of(policy) "#{policy.group_name}:#{policy.policy_name}" end
iam_group_policy_names_in(group)
click to toggle source
# File lib/terraforming/resource/iam_group_policy.rb, line 56 def iam_group_policy_names_in(group) @client.list_group_policies(group_name: group.group_name).policy_names end
iam_group_policy_of(group, policy_name)
click to toggle source
# File lib/terraforming/resource/iam_group_policy.rb, line 60 def iam_group_policy_of(group, policy_name) @client.get_group_policy(group_name: group.group_name, policy_name: policy_name) end
iam_groups()
click to toggle source
# File lib/terraforming/resource/iam_group_policy.rb, line 52 def iam_groups @client.list_groups.map(&:groups).flatten end
unique_name(policy)
click to toggle source
# File lib/terraforming/resource/iam_group_policy.rb, line 44 def unique_name(policy) "#{normalize_module_name(policy.group_name)}_#{normalize_module_name(policy.policy_name)}" end