This is the main repo for the GreenLake terraform provider which provides terraform support fot GreenLake services.
See the INSTALL.md file for instructions on how to install the binaries manually.
- Terraform version >= v0.13 and 64-bit install terraform
- An API client to authenticate against GreenLake.
- Terraform basics. Terraform Introduction
-
Make sure you have the correct Terraform version installed; It must be v0.13 or later:
> terraform version > Terraform v0.15.3 > on linux_amd64
-
Create a Terraform file in your working directory, and reference the desired provider version from the terraform registry. For more information please consult the documentation:
terraform { required_providers { hpegl = { source = "HPE/hpegl" version = ">= 0.1.0-beta5" } } } provider "hpegl" { vmaas { location = "BLR" space_name = "Default" } } data "hpegl_vmaas_datastore" "c_3par" { cloud_id = data.hpegl_vmaas_cloud.cloud.id name = "Compute-Cluster-Vol0" } data "hpegl_vmaas_network" "blue_net" { name = "Blue-Net" } data "hpegl_vmaas_network" "green_net" { name = "green-net" } data "hpegl_vmaas_group" "default_group" { name = "default" } data "hpegl_vmaas_resource_pool" "cl_resource_pool" { cloud_id = data.hpegl_vmaas_cloud.cloud.id name = "ComputeResourcePool" } data "hpegl_vmaas_layout" "vmware" { name = "Vmware VM" instance_type_code = "vmware" } data "hpegl_vmaas_cloud" "cloud" { name = "HPE GreenLake VMaaS Cloud" } data "hpegl_vmaas_plan" "g1_small" { name = "G1-Small" } data "hpegl_vmaas_power_schedule" "weekday" { name = "DEMO_WEEKDAY" } data "hpegl_vmaas_template" "vanilla" { name = "vanilla-centos7-x86_64-09072020" } data "hpegl_vmaas_environment" "dev" { name = "Dev" } resource "hpegl_vmaas_instance" "quick_guide_instance" { name = "quick_guide_instance" cloud_id = data.hpegl_vmaas_cloud.cloud.id group_id = data.hpegl_vmaas_group.default_group.id layout_id = data.hpegl_vmaas_layout.vmware.id plan_id = data.hpegl_vmaas_plan.g1_small.id instance_type_code = data.hpegl_vmaas_layout.vmware.instance_type_code network { id = data.hpegl_vmaas_network.blue_net.id } volume { name = "root_vol" size = 10 datastore_id = data.hpegl_vmaas_datastore.c_3par.id root = true } config { resource_pool_id = data.hpegl_vmaas_resource_pool.cl_resource_pool.id template_id = data.hpegl_vmaas_template.vanilla.id no_agent = true create_user = false asset_tag = "vm_tag" } power = "poweron" }
-
Export API client credentials as environment variables:
export HPEGL_TENANT_ID=< tenant-id > export HPEGL_USER_ID=< API client id > export HPEGL_USER_SECRET=< API client secret > export HPEGL_IAM_SERVICE_URL=< GL iam service url, defaults to https://client.greenlake.hpe.com/api/iam >
-
Initialize Terraform working directory:
> terraform init
-
Deploy resources
> terraform apply