Automating cloud deployments around the world can become very tedious because each cloud provider API has quirks. Luckily, the world is moving beyond declarative cloud deployment automation into procedural orchestration. I’ll show how to Hashicorp’s terraform for an example IoT cloud deployment in the fastest growing cloud in the world: Alibaba’s “Aliyun” cloud, based out of China.
Hashicorp’s terraform allows DevOps to move beyond declarative infrastructure automation into procedural infrastructure automation. Rather than stating step by step how to set up a cloud deployment, wouldn’t you rather say “I want the cloud to look like this” and then have the utility figure out how to deploy that? The significant benefit to this model is that most cloud deployments are rarely static. As changes happen, you want to change control “what is the cloud deployment,” not the exact steps of how to get there.
Aliyun is a Chinese based cloud provider that operates globally with datacenters currently in China, USA, Singapore, Australia, Europe, UAE, and Japan. They offer many similar capabilities that can be found in other providers including Amazon Web Services, Microsoft Azure, Google Cloud Platform, and IBM Bluemix. However, their biggest strength is in the mainland China market where they are the dominant IaaS player.
Here is a reference IoT cloud deployment architecture diagram which includes a virtual private cloud, routers, load balancers, backend MQTT workers and https controllers.
Here is the link to my full “terraform-iot-aliyun” source code — check out the README.md to see how to get started. You can then follow “main” example to see how it all comes together. By editing the main/variables.tf, we can spin up new mqtt and https instances to scale from a small deployment to a full production workload. The best part is that you can configure the load balancers and all other components to dynamically react to this change without having to tediously declare these changes.
Here is a basic “minimal” example that may help you see the basics of terraform with an Aliyun provider: