Module: Tfrb::Resource::AwsIamRolePolicyAttachment
- Extended by:
- Tfrb::Resource
- Defined in:
- lib/tfrb/resource/aws_iam_role_policy_attachment.rb
Class Method Summary collapse
Methods included from Tfrb::Resource
aws_options, extended, get_custom_resource, get_state, import!, load_helpers!, preload, resolve_tfvar, set_default
Class Method Details
.load(base, environment_name, resource_type, new_resources) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tfrb/resource/aws_iam_role_policy_attachment.rb', line 6 def self.load(base, environment_name, resource_type, new_resources) new_resources.each do |resource_name, resource| client = ::Aws::IAM::Client.new((base, resource)) role_name = resolve_tfvar(base, resource_type, resource_name, 'role') next if role_name.empty? begin response = client.list_attached_role_policies({ role_name: role_name }) if response.attached_policies response.attached_policies.each do |attached_policy| next unless attached_policy.policy_arn == resolve_tfvar(base, resource_type, resource_name, 'policy_arn') id = "#{role_name}/#{attached_policy.policy_arn}" import!(base, resource_type, resource_name, id) end end rescue ::Aws::IAM::Errors::NoSuchEntity, NoMethodError # Does not exist to import end end end |