/**
  * Return the physical resource id of a resource specified in a CloudFormation
  * stack.
  *
  * @param string $stackName Name or id of the stack.
  * @param string $resourceName Name of resource as specified in the
  *     template.
  * @return string Phyiscal resource id.
  */
 public function getCloudFormationPhysicalResourceIdByResourceName($stackName, $resourceName)
 {
     if (!strlen($stackName)) {
         throw new InvalidArgumentException(sprintf('Stack name passed to "%s" must be a non-zero length string', __FUNCTION__));
     }
     if (!strlen($resourceName)) {
         throw new InvalidArgumentException(sprintf('Resource name passed to "%s" must be a non-zero length string', __FUNCTION__));
     }
     try {
         $response = $this->cloudFormation->describeStackResource(['StackName' => $stackName, 'LogicalResourceId' => $resourceName]);
     } catch (CloudFormation\Exception\CloudFormationException $e) {
         if (preg_match('#Stack \'.*?\' does not exist#', $e->getMessage())) {
             return null;
         }
         throw new $e();
     }
     if (!isset($response['StackResourceDetail'])) {
         throw new RuntimeException(sprintf('No resource with name "%s" found in stack "%s".', $resourceName, $stackName));
     }
     return $response['StackResourceDetail']['PhysicalResourceId'];
 }