From 1eacacecc657bae11643427966ef9b178f5441fc Mon Sep 17 00:00:00 2001 From: Liam Rahav Date: Mon, 24 Jun 2019 17:47:13 -0700 Subject: [PATCH] Added IAM Role descriptions --- lib/terraforming/resource/iam_role.rb | 1 + lib/terraforming/template/tf/iam_role.erb | 1 + spec/lib/terraforming/resource/iam_role_spec.rb | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/lib/terraforming/resource/iam_role.rb b/lib/terraforming/resource/iam_role.rb index 6127c002..93d59175 100644 --- a/lib/terraforming/resource/iam_role.rb +++ b/lib/terraforming/resource/iam_role.rb @@ -29,6 +29,7 @@ def tfstate "name" => role.role_name, "path" => role.path, "unique_id" => role.role_id, + "description" => role.description, } resources["aws_iam_role.#{module_name_of(role)}"] = { "type" => "aws_iam_role", diff --git a/lib/terraforming/template/tf/iam_role.erb b/lib/terraforming/template/tf/iam_role.erb index 418c32d4..e91eda61 100644 --- a/lib/terraforming/template/tf/iam_role.erb +++ b/lib/terraforming/template/tf/iam_role.erb @@ -1,6 +1,7 @@ <% iam_roles.each do |role| -%> resource "aws_iam_role" "<%= module_name_of(role) %>" { name = "<%= role.role_name %>" + description = "<%= role.description %>" path = "<%= role.path %>" assume_role_policy = < diff --git a/spec/lib/terraforming/resource/iam_role_spec.rb b/spec/lib/terraforming/resource/iam_role_spec.rb index c1cb21f4..5d9ec62b 100644 --- a/spec/lib/terraforming/resource/iam_role_spec.rb +++ b/spec/lib/terraforming/resource/iam_role_spec.rb @@ -16,6 +16,7 @@ module Resource arn: "arn:aws:iam::123456789012:role/hoge_role", create_date: Time.parse("2015-04-01 12:34:56 UTC"), assume_role_policy_document: "%7B%22Version%22%3A%222008-10-17%22%2C%22Statement%22%3A%5B%7B%22Sid%22%3A%22%22%2C%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22ec2.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D", + description: "hoge description", }, { path: "/system/", @@ -24,6 +25,7 @@ module Resource arn: "arn:aws:iam::345678901234:role/fuga_role", create_date: Time.parse("2015-05-01 12:34:56 UTC"), assume_role_policy_document: "%7B%22Version%22%3A%222008-10-17%22%2C%22Statement%22%3A%5B%7B%22Sid%22%3A%221%22%2C%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22elastictranscoder.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D", + description: "fuga description", }, ] end @@ -37,6 +39,7 @@ module Resource expect(described_class.tf(client: client)).to eq <<-EOS resource "aws_iam_role" "hoge_role" { name = "hoge_role" + description = "hoge description" path = "/" assume_role_policy = < { "arn" => "arn:aws:iam::123456789012:role/hoge_role", "assume_role_policy" => "{\n \"Version\": \"2008-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Principal\": {\n \"Service\": \"ec2.amazonaws.com\"\n },\n \"Action\": \"sts:AssumeRole\"\n }\n ]\n}\n", + "description" => "hoge description", "id" => "hoge_role", "name" => "hoge_role", "path" => "/", @@ -103,6 +108,7 @@ module Resource "attributes" => { "arn" => "arn:aws:iam::345678901234:role/fuga_role", "assume_role_policy" => "{\n \"Version\": \"2008-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"1\",\n \"Effect\": \"Allow\",\n \"Principal\": {\n \"Service\": \"elastictranscoder.amazonaws.com\"\n },\n \"Action\": \"sts:AssumeRole\"\n }\n ]\n}\n", + "description" => "fuga description", "id" => "fuga_role", "name" => "fuga_role", "path" => "/system/",