lib/terraforming/resource/s3.rb in terraforming-0.0.1 vs lib/terraforming/resource/s3.rb in terraforming-0.0.2
- old
+ new
@@ -1,51 +1,53 @@
-module Terraforming::Resource
- class S3
- include Terraforming::Util
+module Terraforming
+ module Resource
+ class S3
+ include Terraforming::Util
- def self.tf(client = Aws::S3::Client.new)
- self.new(client).tf
- end
+ def self.tf(client = Aws::S3::Client.new)
+ self.new(client).tf
+ end
- def self.tfstate(client = Aws::S3::Client.new)
- self.new(client).tfstate
- end
+ def self.tfstate(client = Aws::S3::Client.new)
+ self.new(client).tfstate
+ end
- def initialize(client)
- @client = client
- end
+ def initialize(client)
+ @client = client
+ end
- def tf
- apply_template(@client, "tf/s3")
- end
+ def tf
+ apply_template(@client, "tf/s3")
+ end
- def tfstate
- resources = buckets.inject({}) do |result, bucket|
- result["aws_s3_bucket.#{module_name_of(bucket)}"] = {
- "type" => "aws_s3_bucket",
- "primary" => {
- "id" => bucket.name,
- "attributes" => {
- "acl" => "private",
- "bucket" => bucket.name,
- "id" => bucket.name
+ def tfstate
+ resources = buckets.inject({}) do |result, bucket|
+ result["aws_s3_bucket.#{module_name_of(bucket)}"] = {
+ "type" => "aws_s3_bucket",
+ "primary" => {
+ "id" => bucket.name,
+ "attributes" => {
+ "acl" => "private",
+ "bucket" => bucket.name,
+ "id" => bucket.name
+ }
}
}
- }
- result
+ result
+ end
+
+ generate_tfstate(resources)
end
- generate_tfstate(resources)
- end
+ private
- private
+ def buckets
+ @client.list_buckets.buckets
+ end
- def buckets
- @client.list_buckets.buckets
- end
-
- def module_name_of(bucket)
- normalize_module_name(bucket.name)
+ def module_name_of(bucket)
+ normalize_module_name(bucket.name)
+ end
end
end
end