Class: Terraforming::Resource::IAMPolicy
- Inherits:
-
Object
- Object
- Terraforming::Resource::IAMPolicy
show all
- Includes:
- Util
- Defined in:
- lib/terraforming/resource/iam_policy.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) ⇒ IAMPolicy
Returns a new instance of IAMPolicy.
14
15
16
|
# File 'lib/terraforming/resource/iam_policy.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.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.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.rb', line 18
def tf
apply_template(@client, "tf/iam_policy")
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.rb', line 22
def tfstate
iam_policies.inject({}) do |resources, policy|
version = iam_policy_version_of(policy)
attributes = {
"id" => policy.arn,
"name" => policy.policy_name,
"path" => policy.path,
"description" => iam_policy_description(policy),
"policy" => prettify_policy(version.document, breakline: true, unescape: true),
}
resources["aws_iam_policy.#{module_name_of(policy)}"] = {
"type" => "aws_iam_policy",
"primary" => {
"id" => policy.arn,
"attributes" => attributes
}
}
resources
end
end
|