edit-icon download-icon

Virtual Private Cloud

Last Updated: Mar 20, 2018

Virtual Private Cloud (VPC) is a private network established in Alibaba Cloud. VPCs are logically isolated from other virtual networks in Alibaba Cloud. You have full control over your VPC, such as specifying the IP address range of your VPC, and configuring route tables and network gateways. You can also use Alibaba Cloud resources such as ECS, RDS, and SLB in your own VPC. For more information, see VPC documentation.

This tutorial uses the CreateVpc API of VPC to show you how to use Alibaba Cloud C++ SDK to call VPC APIs.

  1. #include <iostream>
  2. #include <alibabacloud/core/AlibabaCloud.h>
  3. #include <alibabacloud/vpc/VpcClient.h>
  4. using namespace AlibabaCloud;
  5. using namespace AlibabaCloud::Vpc;
  6. int main(int argc, char** argv)
  7. {
  8. // Initialize the SDK
  9. AlibabaCloud::InitializeSdk();
  10. // Create a client instance
  11. ClientConfiguration configuration("<your-region-id>");
  12. VpcClient client("<your-access-key-id>", "<your-access-key-secret>", configuration);
  13. // Create and initiate the CreateVpcRequest
  14. Model::CreateVpcRequest createRequest;
  15. auto createOutcome = client.createVpc(createRequest);
  16. if (createOutcome.isSuccess())
  17. {
  18. std::string vpcId = createOutcome.result().getVpcId();
  19. // Create and initiate the DescribeVpcAttributeRequest
  20. Model::DescribeVpcAttributeRequest describeRequest;
  21. describeRequest.setVpcId(vpcId);
  22. auto describeOutcome = client.describeVpcAttribute(describeRequest);
  23. if (describeOutcome.isSuccess())
  24. std::cout << "vpcId:" << vpcId << std::endl;
  25. }
  26. // Close the SDK
  27. AlibabaCloud::ShutdownSdk();
  28. return 0;
  29. }
Thank you! We've received your feedback.