Commit b147e8d0 authored by Daisuke Fujita's avatar Daisuke Fujita

Generate IAM user tfstate

parent 1afc6ed7
......@@ -20,7 +20,26 @@ module Terraforming
end
def tfstate
resources = iam_users.inject({}) do |result, user|
attributes = {
"arn"=> user.arn,
"id" => user.user_name,
"name" => user.user_name,
"path" => user.path,
"unique_id" => user.user_id,
}
result["aws_iam_user.#{user.user_name}"] = {
"type" => "aws_iam_user",
"primary" => {
"id" => user.user_name,
"attributes" => attributes
}
}
result
end
generate_tfstate(resources)
end
private
......
......@@ -50,7 +50,7 @@ resource "aws_iam_user" "fuga" {
end
describe ".tfstate" do
xit "should generate tfstate" do
it "should generate tfstate" do
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
......@@ -81,7 +81,7 @@ resource "aws_iam_user" "fuga" {
"arn"=> "arn:aws:iam::345678901234:user/fuga",
"id" => "fuga",
"name" => "fuga",
"path" => "/",
"path" => "/system/",
"unique_id" => "OPQRSTUVWXYZA8901234",
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment