Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update terraform example #5050

Merged
merged 8 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 49 additions & 35 deletions examples/ibm-power/main.tf
Original file line number Diff line number Diff line change
@@ -1,49 +1,64 @@
data "ibm_pi_image" "data_source_image" {
pi_cloud_instance_id = var.cloud_instance_id
# Create a workspace
resource "ibm_resource_instance" "location" {
name = var.workspace_name
resource_group_id = var.resource_group_id
location = var.datacenter
service = "power-iaas"
plan = "power-virtual-server-group"
}

# Create an image
resource "ibm_pi_image" "image" {
pi_cloud_instance_id = ibm_resource_instance.location.guid
pi_image_name = var.image_name
pi_image_id = var.image_id
}
resource "ibm_pi_key" "key" {
pi_cloud_instance_id = var.cloud_instance_id
pi_key_name = var.ssh_key_name
pi_ssh_key = var.ssh_key_rsa
data "ibm_pi_image" "data_source_image" {
pi_cloud_instance_id = ibm_resource_instance.location.guid
pi_image_name = resource.ibm_pi_image.image.pi_image_name
}
data "ibm_pi_key" "data_source_key" {
depends_on = [ibm_pi_key.key]

pi_cloud_instance_id = var.cloud_instance_id
pi_key_name = var.ssh_key_name
}
resource "ibm_pi_network" "network" {
pi_cloud_instance_id = var.cloud_instance_id
# Create a network
resource "ibm_pi_network" "private_network" {
pi_cloud_instance_id = ibm_resource_instance.location.guid
pi_network_name = var.network_name
pi_network_type = var.network_type
count = var.network_count
pi_cidr = var.network_cidr
pi_dns = [var.network_dns]
pi_network_mtu = 2000
}
data "ibm_pi_public_network" "data_source_network" {
depends_on = [ibm_pi_network.network]

pi_cloud_instance_id = var.cloud_instance_id
data "ibm_pi_network" "data_source_private_network" {
pi_cloud_instance_id = ibm_resource_instance.location.guid
pi_network_name = resource.ibm_pi_network.private_network.pi_network_name
}

# Create a volume
resource "ibm_pi_volume" "volume" {
pi_cloud_instance_id = var.cloud_instance_id
pi_cloud_instance_id = ibm_resource_instance.location.guid
pi_volume_name = var.volume_name
pi_volume_type = var.volume_type
pi_volume_size = var.volume_size
pi_volume_shareable = var.volume_shareable
}
data "ibm_pi_volume" "data_source_volume" {
depends_on = [ibm_pi_volume.volume]
pi_cloud_instance_id = ibm_resource_instance.location.guid
pi_volume_name = resource.ibm_pi_volume.volume.pi_volume_name
}

pi_cloud_instance_id = var.cloud_instance_id
pi_volume_name = var.volume_name
# Create an ssh key
resource "ibm_pi_key" "key" {
pi_cloud_instance_id = ibm_resource_instance.location.guid
pi_key_name = var.ssh_key_name
pi_ssh_key = var.ssh_key_rsa
}
data "ibm_pi_key" "data_source_key" {
pi_cloud_instance_id = ibm_resource_instance.location.guid
pi_key_name = resource.ibm_pi_key.key.pi_key_name
}
resource "ibm_pi_instance" "instance" {
depends_on = [data.ibm_pi_image.data_source_image,
data.ibm_pi_key.data_source_key,
data.ibm_pi_volume.data_source_volume,
data.ibm_pi_public_network.data_source_network]

pi_cloud_instance_id = var.cloud_instance_id
# Create an instance
resource "ibm_pi_instance" "instance" {
pi_cloud_instance_id = ibm_resource_instance.location.guid
pi_instance_name = var.instance_name
pi_memory = var.memory
pi_processors = var.processors
Expand All @@ -52,13 +67,12 @@ resource "ibm_pi_instance" "instance" {
pi_sys_type = var.sys_type
pi_image_id = data.ibm_pi_image.data_source_image.id
pi_key_pair_name = data.ibm_pi_key.data_source_key.id
pi_network { network_id = data.ibm_pi_public_network.data_source_network.id }
pi_network {
network_id = data.ibm_pi_network.data_source_private_network.id
}
pi_volume_ids = [data.ibm_pi_volume.data_source_volume.id]
}

data "ibm_pi_instance" "data_source_instance" {
depends_on = [ibm_pi_instance.instance]

pi_cloud_instance_id = var.cloud_instance_id
pi_instance_name = var.instance_name
}
pi_cloud_instance_id = ibm_resource_instance.location.guid
pi_instance_name = resource.ibm_pi_instance.instance.pi_instance_name
}
137 changes: 80 additions & 57 deletions examples/ibm-power/variables.tf
Original file line number Diff line number Diff line change
@@ -1,65 +1,95 @@
// Service / Account
## Service // Account
variable "ibm_cloud_api_key" {
description = "API Key"
type = string
default = "<key>"
}
variable "region" {
description = "Reigon of Service"
description = "Region of Service"
type = string
default = "<e.g dal>"
}
variable "zone" {
description = "Zone of Service"
type = string
default = "<e.g 12>"
default = "<e.g dal12>"
}
variable "cloud_instance_id" {
description = "Cloud Instance ID of Service"
type = string
default = "<cid>"

## Workspace
variable "workspace_name" {
description = "Workspace Name"
type = string
default = "<name>"
}
# See available datacenter regions at: https://cloud.ibm.com/apidocs/power-cloud#endpoint
variable "datacenter" {
description = "Datacenter Region"
type = string
default = "<region>"
}
variable "resource_group_id" {
description = "Resource Group ID"
type = string
default = "<name>"
}

// Image
## Image
variable "image_name" {
description = "Name of the image to be used"
description = "Name of the image in the image catalog"
type = string
default = "<name>"
}
variable "image_id" {
description = "ID of the image in the image catalog"
type = string
default = "<id>"
}

// Instance
variable "instance_name" {
description = "Name of the instance"
## Private Network
variable "network_name" {
description = "Name of the network"
type = string
default = "<name>"
}
variable "memory" {
description = "Instance memory"
type = number
default = 1
variable "network_type" {
description = "Type of a network"
type = string
default = "vlan"
}
variable "processors" {
description = "Instance processors"
type = number
default = 1
variable "network_cidr" {
description = "Network in CIDR notation"
type = string
default = "<e.g 192.168.0.0/24>"
}
variable "proc_type" {
description = "Instance ProcType"
variable "network_dns" {
description = "Comma seaparated list of DNS Servers to use for this network"
type = string
default = "<e.g shared>"
default = "<e.g 10.1.0.68>"
}
variable "storage_type" {
description = "The storage type to be used"

## Volume
variable "volume_name" {
description = "Name of the volume"
type = string
default = "<e.g tier1>"
default = "<name>"
}
variable "sys_type" {
description = "Instance System Type"
variable "volume_size" {
description = "Size of a volume"
type = number
default = 1
}
variable "volume_shareable" {
description = "Is a volume shareable"
type = bool
default = true
}
variable "volume_type" {
description = "Type of a volume"
type = string
default = "<e.g s922>"
default = "<e.g tier3>"
}

// SSH Key
## SSH Key
variable "ssh_key_name" {
description = "Name of the ssh key to be used"
type = string
Expand All @@ -71,41 +101,34 @@ variable "ssh_key_rsa" {
default = "<rsa value>"
}

// Network
variable "network_name" {
description = "Name of the network"
## Instance
variable "instance_name" {
description = "Name of the instance"
type = string
default = "<name>"
}
variable "network_type" {
description = "Type of a network"
type = string
default = "<e.g pub-vlan>"
variable "memory" {
description = "Instance memory"
type = number
default = 1
}
variable "network_count" {
description = "Number of networks to provision"
variable "processors" {
description = "Instance processors"
type = number
default = 1
}

// Volume
variable "volume_name" {
description = "Name of the volume"
variable "proc_type" {
description = "Instance ProcType"
type = string
default = "<name>"
}
variable "volume_size" {
description = "Size of a volume"
type = number
default = 0.25
default = "<e.g shared>"
}
variable "volume_shareable" {
description = "Is a volume shareable"
type = bool
default = true
variable "storage_type" {
description = "The storage type to be used"
type = string
default = "<e.g tier3>"
}
variable "volume_type" {
description = "Type of a volume"
variable "sys_type" {
description = "Instance System Type"
type = string
default = "<e.g ssd>"
}
default = "<e.g s922>"
}
7 changes: 6 additions & 1 deletion examples/ibm-power/versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
terraform {
required_version = ">= 0.13"
}

terraform {
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
version = "<desired_provider_version>"
}
}
}
}
Loading