parameters: (self, stack_id, logical_resource_id, expected_type=None, optional=False)
return_statement: return physical_id
docstring: Map a logical resource id to a physical resource id.
docstring_summary: Map a logical resource id to a physical resource id.
docstring_tokens: Map a logical resource id to a physical resource id .
function: def get_physical_resource_id(self, stack_id, logical_resource_id, expected_type=None, optional=False):
          """Map a logical resource id to a physical resource id."""
  
          if stack_id is None:
              if optional:
                  return None
              else:
                  raise ValueError('No stack_id provided.')
  
          cf = self.context.aws.client('cloudformation', region=util.get_region_from_arn(stack_id))
  
          try:
              res = cf.describe_stack_resource(
                  StackName=stack_id,
                  LogicalResourceId=logical_resource_id)
          except ClientError as e:
              if optional and e.response['Error']['Code'] == 'ValidationError':
                  return None
              raise HandledError('Could not get the id for the {} resource from the {} stack.'.format(logical_resource_id, stack_id), e)
  
          physical_id = res['StackResourceDetail'].get('PhysicalResourceId', None)
  
          if physical_id is None:
              if not optional:
                  raise HandledError('Could not get the id for the {} resource from the {} stack.'.format(logical_resource_id, stack_id))
          else:
              if expected_type:
                  if res['StackResourceDetail'].get('ResourceType', None) != expected_type:
                      raise HandledError('The {} resource in stack {} does not have type {} (it has type {})'.format(logical_resource_id, stack_id, expected_type,
                                                                                                                     res['StackResourceDetail'].get(
                                                                                                                         'ResourceType', '(unknown)')))
  
          return physical_id
function_tokens: def get_physical_resource_id ( self , stack_id , logical_resource_id , expected_type = None , optional = False ) : if stack_id is None : if optional : return None else : raise ValueError ( 'No stack_id provided.' ) cf = self . context . aws . client ( 'cloudformation' , region = util . get_region_from_arn ( stack_id ) ) try : res = cf . describe_stack_resource ( StackName = stack_id , LogicalResourceId = logical_resource_id ) except ClientError as e : if optional and e . response [ 'Error' ] [ 'Code' ] == 'ValidationError' : return None raise HandledError ( 'Could not get the id for the {} resource from the {} stack.' . format ( logical_resource_id , stack_id ) , e ) physical_id = res [ 'StackResourceDetail' ] . get ( 'PhysicalResourceId' , None ) if physical_id is None : if not optional : raise HandledError ( 'Could not get the id for the {} resource from the {} stack.' . format ( logical_resource_id , stack_id ) ) else : if expected_type : if res [ 'StackResourceDetail' ] . get ( 'ResourceType' , None ) != expected_type : raise HandledError ( 'The {} resource in stack {} does not have type {} (it has type {})' . format ( logical_resource_id , stack_id , expected_type , res [ 'StackResourceDetail' ] . get ( 'ResourceType' , '(unknown)' ) ) ) return physical_id