lib/terraforming/resource/iam_policy.rb in terraforming-0.0.5 vs lib/terraforming/resource/iam_policy.rb in terraforming-0.1.0
- old
+ new
@@ -1,34 +1,34 @@
module Terraforming
module Resource
class IAMPolicy
include Terraforming::Util
- def self.tf(client = Aws::IAM::Client.new)
+ def self.tf(client: Aws::IAM::Client.new)
self.new(client).tf
end
- def self.tfstate(client = Aws::IAM::Client.new)
- self.new(client).tfstate
+ def self.tfstate(client: Aws::IAM::Client.new, tfstate_base: nil)
+ self.new(client).tfstate(tfstate_base)
end
def initialize(client)
@client = client
end
def tf
apply_template(@client, "tf/iam_policy")
end
- def tfstate
+ def tfstate(tfstate_base)
resources = iam_policies.inject({}) do |result, policy|
version = iam_policy_version_of(policy)
attributes = {
"id" => policy.arn,
"name" => policy.policy_name,
"path" => policy.path,
- "policy" => CGI.unescape(version.document),
+ "policy" => prettify_policy(version.document, true),
}
result["aws_iam_policy.#{policy.policy_name}"] = {
"type" => "aws_iam_policy",
"primary" => {
"id" => policy.arn,
@@ -37,10 +37,10 @@
}
result
end
- generate_tfstate(resources)
+ generate_tfstate(resources, tfstate_base)
end
private
def iam_policies