lib/bolt/plugin/terraform.rb
# Format the list of resources into a list of [name, attribute map]
# pairs. This method handles both version 4 and earlier statefiles, doing
# the appropriate munging based on the shape of the data.
Format the list of resources into a list of [name, attribute map]
pairs. This method handles both version 4 and earlier statefiles, doing
the appropriate munging based on the shape of the data.
Format the list of resources into a list of [ name attribute map ] pairs . This method handles both version 4 and earlier statefiles doing the appropriate munging based on the shape of the data .
def extract_resources(state)
        if state['version'] >= 4
          state.fetch('resources', []).flat_map do |resource_set|
            prefix = "#{resource_set['type']}.#{resource_set['name']}"
            resource_set['instances'].map do |resource|
              instance_name = prefix
              instance_name += ".#{resource['index_key']}" if resource['index_key']
              [instance_name, resource['attributes']]
            end
          end
        else
          state.fetch('modules', {}).flat_map do |mod|
            mod.fetch('resources', {}).map do |name, resource|
              [name, resource.dig('primary', 'attributes')]
            end
          end
        end
      end
def extract_resources ( state ) if state [ 'version' ] >= 4 state . fetch ( 'resources' , [ ] ) . flat_map do | resource_set | prefix = "#{resource_set['type']}.#{resource_set['name']}" resource_set [ 'instances' ] . map do | resource | instance_name = prefix instance_name += ".#{resource['index_key']}" if resource [ 'index_key' ] [ instance_name , resource [ 'attributes' ] ] end end else state . fetch ( 'modules' , { } ) . flat_map do | mod | mod . fetch ( 'resources' , { } ) . map do | name , resource | [ name , resource . dig ( 'primary' , 'attributes' ) ] end end end end
Format the list of resources into a list of [name, attribute map]
pairs.
Format the list of resources into a list of [ name attribute map ] pairs .
state