Class: PracticeTerraforming::Resource::IAMGroupPolicyAttachment

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/practice_terraforming/resource/iam_group_policy_attachment.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

#apply_template, #name_from_tag, #normalize_module_name, #prettify_policy, #template_path

Constructor Details

#initialize(client) ⇒ IAMGroupPolicyAttachment

Returns a new instance of IAMGroupPolicyAttachment.



20
21
22
# File 'lib/practice_terraforming/resource/iam_group_policy_attachment.rb', line 20

def initialize(client)
  @client = client
end

Class Method Details

.tf(client: Aws::IAM::Client.new) ⇒ Object

TODO: Select appropriate Client class from here: docs.aws.amazon.com/sdkforruby/api/index.html



10
11
12
# File 'lib/practice_terraforming/resource/iam_group_policy_attachment.rb', line 10

def self.tf(client: Aws::IAM::Client.new)
  self.new(client).tf
end

.tfstate(client: Aws::IAM::Client.new) ⇒ Object

TODO: Select appropriate Client class from here: docs.aws.amazon.com/sdkforruby/api/index.html



16
17
18
# File 'lib/practice_terraforming/resource/iam_group_policy_attachment.rb', line 16

def self.tfstate(client: Aws::IAM::Client.new)
  self.new(client).tfstate
end

Instance Method Details

#tfObject



24
25
26
# File 'lib/practice_terraforming/resource/iam_group_policy_attachment.rb', line 24

def tf
  apply_template(@client, "tf/iam_group_policy_attachment")
end

#tfstateObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/practice_terraforming/resource/iam_group_policy_attachment.rb', line 28

def tfstate
  iam_group_policy_attachments.inject({}) do |resources, group_policy_attachment|
    attributes = {
      "id" => group_policy_attachment[:name],
      "policy_arn" => group_policy_attachment[:policy_arn],
      "group" => group_policy_attachment[:group]
    }
    resources["aws_iam_group_policy_attachment.#{module_name_of(group_policy_attachment)}"] = {
      "type" => "aws_iam_group_policy_attachment",
      "primary" => {
        "id" => group_policy_attachment[:name],
        "attributes" => attributes
      }
    }

    resources
  end
end