Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Fixed undefined method 'role_name' when running iamip #451

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions lib/terraforming/resource/iam_instance_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 2 additions & 4 deletions lib/terraforming/template/tf/iam_instance_profile.erb
Original file line number Diff line number Diff line change
@@ -1,10 +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 %>"
<%- if profile.roles[0] != nil -%>
role = "<%= profile.roles[0].role_name %>"
<%- end -%>
}
}<% end %>

<% end -%>