Skip to content

Instantly share code, notes, and snippets.

@chiradeep
Last active January 11, 2020 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiradeep/eb4367f7b03bebe412a3 to your computer and use it in GitHub Desktop.
Save chiradeep/eb4367f7b03bebe412a3 to your computer and use it in GitHub Desktop.
Working terraform VPC config
provider "cloudstack" {
api_url = "http://localhost:8080/client/api"
api_key = "tZTPtxAfbZfTrIiIDe4XHfZupjlCoVYy3JnIfvlqyxWvHbVJ9TDw8UWxQ_INj6r5NWGglLMYHX4hN33sMuoI1g"
secret_key = "9u1bizzTQrfhnp3Y_Cs-Zu9uiOr-nAmRcN5Eo6Pp8dlbeKgq_V0TqUqhDdDGgrXFqzT8yZ731UUPTPDeFKLzzQ"
}
resource "cloudstack_vpc" "default" {
name = "test-vpc"
display_text = "test-vpc"
cidr = "10.0.0.0/16"
vpc_offering = "Default VPC Offering"
zone = "zone001"
}
resource "cloudstack_network_acl" "default" {
name = "test-acl"
vpc = "test-vpc"
}
resource "cloudstack_network" "subnet-1" {
name = "subnet-1"
display_text = "subnet-1"
cidr = "10.0.10.0/24"
network_offering = "DefaultIsolatedNetworkOfferingForVpcNetworks"
#aclid = "${cloudstack_network_acl.default.id}"
zone = "zone001"
vpc = "${cloudstack_vpc.default.id}"
}
resource "cloudstack_network" "subnet-2" {
name = "subnet-2"
display_text = "subnet-2"
cidr = "10.0.20.0/24"
network_offering = "DefaultIsolatedNetworkOfferingForVpcNetworks"
#aclid = "${cloudstack_network_acl.default.id}"
vpc = "${cloudstack_vpc.default.id}"
zone = "zone001"
}
resource "cloudstack_instance" "vm01" {
zone = "zone001"
service_offering = "t1.micro"
template = "CentOS6.5"
name = "vm01-subnet-1"
network = "${cloudstack_network.subnet-1.id}"
}
resource "cloudstack_instance" "vm02" {
zone = "zone001"
service_offering = "t1.micro"
template = "CentOS6.5"
name = "vm02-subnet-2"
network = "${cloudstack_network.subnet-2.id}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment