Class: Terraforming::Resource::IAMPolicyAttachment
- Inherits:
-
Object
- Object
- Terraforming::Resource::IAMPolicyAttachment
show all
- Includes:
- Util
- Defined in:
- lib/terraforming/resource/iam_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
Returns a new instance of IAMPolicyAttachment.
14
15
16
|
# File 'lib/terraforming/resource/iam_policy_attachment.rb', line 14
def initialize(client)
@client = client
end
|
Class Method Details
.tf(client: Aws::IAM::Client.new) ⇒ Object
6
7
8
|
# File 'lib/terraforming/resource/iam_policy_attachment.rb', line 6
def self.tf(client: Aws::IAM::Client.new)
self.new(client).tf
end
|
.tfstate(client: Aws::IAM::Client.new) ⇒ Object
10
11
12
|
# File 'lib/terraforming/resource/iam_policy_attachment.rb', line 10
def self.tfstate(client: Aws::IAM::Client.new)
self.new(client).tfstate
end
|
Instance Method Details
#tf ⇒ Object
18
19
20
|
# File 'lib/terraforming/resource/iam_policy_attachment.rb', line 18
def tf
apply_template(@client, "tf/iam_policy_attachment")
end
|
#tfstate ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/terraforming/resource/iam_policy_attachment.rb', line 22
def tfstate
iam_policy_attachments.inject({}) do |resources, policy_attachment|
attributes = {
"id" => policy_attachment[:name],
"name" => policy_attachment[:name],
"policy_arn" => policy_attachment[:arn],
"groups.#" => policy_attachment[:entities].policy_groups.length.to_s,
"users.#" => policy_attachment[:entities].policy_users.length.to_s,
"roles.#" => policy_attachment[:entities].policy_roles.length.to_s,
}
resources["aws_iam_policy_attachment.#{module_name_of(policy_attachment)}"] = {
"type" => "aws_iam_policy_attachment",
"primary" => {
"id" => policy_attachment[:name],
"attributes" => attributes
}
}
resources
end
end
|