From ce754d06cf3d228c4adb52a57ce087da7590bf65 Mon Sep 17 00:00:00 2001 From: Avolynsk Date: Thu, 4 Apr 2019 22:00:01 +0300 Subject: [PATCH 1/3] Fixed undefined method 'role_name' when running iamip --- .../resource/iam_instance_profile.rb | 20 +++++++++++-------- .../template/tf/iam_instance_profile.erb | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/terraforming/resource/iam_instance_profile.rb b/lib/terraforming/resource/iam_instance_profile.rb index 7adb7f63..fc751b6e 100644 --- a/lib/terraforming/resource/iam_instance_profile.rb +++ b/lib/terraforming/resource/iam_instance_profile.rb @@ -26,18 +26,22 @@ def tfstate "id" => profile.instance_profile_name, "name" => profile.instance_profile_name, "path" => profile.path, - "role" => profile.roles[0].role_name, "roles.#" => profile.roles.length.to_s, } - resources["aws_iam_instance_profile.#{module_name_of(profile)}"] = { - "type" => "aws_iam_instance_profile", - "primary" => { - "id" => profile.instance_profile_name, - "attributes" => attributes + if profile.roles.length > 0 + attributes["role"] = profile.roles[0].role_name + end + if attributes["role"] + resources["aws_iam_instance_profile.#{module_name_of(profile)}"] = { + "type" => "aws_iam_instance_profile", + "primary" => { + "id" => profile.instance_profile_name, + "attributes" => attributes + } } - } - + end resources + end end diff --git a/lib/terraforming/template/tf/iam_instance_profile.erb b/lib/terraforming/template/tf/iam_instance_profile.erb index 079463a6..5bfe5140 100644 --- a/lib/terraforming/template/tf/iam_instance_profile.erb +++ b/lib/terraforming/template/tf/iam_instance_profile.erb @@ -1,8 +1,8 @@ <% iam_instance_profiles.each do |profile| -%> -resource "aws_iam_instance_profile" "<%= module_name_of(profile) %>" { +<% if profile.roles.length > 0 %>resource "aws_iam_instance_profile" "<%= module_name_of(profile) %>" { name = "<%= profile.instance_profile_name %>" path = "<%= profile.path %>" role = "<%= profile.roles[0].role_name %>" -} +}<% end %> <% end -%> From b490d7ce8c6c5b6f4f5b04ef0177029448a4a43c Mon Sep 17 00:00:00 2001 From: avolynskiy Date: Mon, 22 Apr 2019 22:11:32 +0300 Subject: [PATCH 2/3] fix iam_instance_profile.erb --- lib/terraforming/template/tf/iam_instance_profile.erb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/terraforming/template/tf/iam_instance_profile.erb b/lib/terraforming/template/tf/iam_instance_profile.erb index 6a19d746..30d9b144 100644 --- a/lib/terraforming/template/tf/iam_instance_profile.erb +++ b/lib/terraforming/template/tf/iam_instance_profile.erb @@ -2,13 +2,8 @@ <% if profile.roles.length > 0 %>resource "aws_iam_instance_profile" "<%= module_name_of(profile) %>" { name = "<%= profile.instance_profile_name %>" path = "<%= profile.path %>" - <%- if profile.roles[0] != nil -%> role = "<%= profile.roles[0].role_name %>" -<<<<<<< HEAD }<% end %> -======= - <%- end -%> -} ->>>>>>> 50e09f973ec01ccb0751741eed4d78acb1c3cdb3 <% end -%> + From c13ad6189f5bdb6d6692cc66d69467662581bcb1 Mon Sep 17 00:00:00 2001 From: avolynskiy Date: Mon, 22 Apr 2019 22:29:14 +0300 Subject: [PATCH 3/3] remove redundant new_line --- lib/terraforming/template/tf/iam_instance_profile.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/terraforming/template/tf/iam_instance_profile.erb b/lib/terraforming/template/tf/iam_instance_profile.erb index 30d9b144..5bfe5140 100644 --- a/lib/terraforming/template/tf/iam_instance_profile.erb +++ b/lib/terraforming/template/tf/iam_instance_profile.erb @@ -6,4 +6,3 @@ }<% end %> <% end -%> -