This paper investigates an efficient placement and chaining of Virtual Network Functions (VNFs) to provide cloud based IoT services with minimal resource usage cost. We take into account bandwidth capacity and link delay of network connection between clouds where VNFs are allocated and underlying IoT networks where sensors and IoT gateways are deployed. Regarding the constantly changing network dynamics, input traffic of service components is considered at the lower granularity level of messages based on the communication between each VNF and corresponding sensors via IoT gateways. From the algorithm perspective, the specific topology of multiple edge clouds is leveraged to improve the solution. In this paper, we present an NFV-based high-level architecture for a system that enables the deployment of IoT services across multiple edges and clouds. We formulate the VNF placement problem using a non-convex Integer Programming model. Taking into account different IoT topologies, we devise two algorithms for small- and large-scale networks to find the near optimal solution: i) a customized Markov approximation with two techniques, i.e., multi-start and batching, and a node ranking-based heuristic. Simulation and experimental results show that the proposed solution improves the cost up to 21% compared to state-of-the-art schemes.