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 powervs terraform example with workspace creation #20

Closed
wants to merge 8 commits into from

Conversation

ismirlia
Copy link
Collaborator

This pull request updates the main powervs terraform example to include workspace creation and corrects some errors.

This is in response to this issue: IBM-Cloud#4913

resource "ibm_pi_workspace" "powervs_service_instance" {
pi_name = var.workspace_name
pi_datacenter = var.datacenter
pi_resource_group_id = var.resource_group_id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use:
data "ibm_resource_group" "group" {
name = "test"
}

And specify the id attribute of the data.ibm_resource_group.group This way the user doesn't have to guess if they need to supply the crn, or guid, or id, ...

Copy link
Collaborator Author

@ismirlia ismirlia Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed how workspace is created.

pi_cloud_instance_id = var.cloud_instance_id
pi_key_name = var.ssh_key_name
pi_cloud_instance_id = ibm_pi_workspace.powervs_service_instance.id
pi_image_name = var.image_name

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the depends_on and use data.igm_pi_image.pi_image_name for the data.ibm_pi_image.pi_image_name


pi_cloud_instance_id = var.cloud_instance_id
pi_cloud_instance_id = ibm_pi_workspace.powervs_service_instance.id
pi_network_name = var.network_name

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the user know what the network_name is going to be? Would it work to create the public network instead of using data?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A user can specify the network name to be whatever they want it to be regardless if it a public or private network.

@@ -34,16 +45,18 @@ resource "ibm_pi_volume" "volume" {
data "ibm_pi_volume" "data_source_volume" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it required to create a volume with a resource, and then access it with a data? The attributes of the resource should be used.

examples/ibm-power/main.tf Outdated Show resolved Hide resolved
type = string
default = "<e.g dal>"
}
variable "zone" {
description = "Zone of Service"
type = string
default = "<e.g 12>"
default = "<e.g dal12>"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variables have defaults that work. If you want to force the user to provide the value do not specify the default. It you want it to work without supplying a value use a string like "dal12"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think default is fine because it shows the user what kind of information goes into that field. Without giving an example in the default field, it might be confusing to say what kind of inputs are accepted.

default = "<name>"
}
variable "datacenter" {
description = "Datacenter Region"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide a link to the docs where a user could find the list of data centers to choose from

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made changes

Copy link
Collaborator

@michaelkad michaelkad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few things comes to mind, we could just remove data for most of them and just use resource directly instead of having data for them.

resource "ibm_pi_image" "image" {...}
...
resource "ibm_pi_instance" "instance" { 
pi_image_id          = ibm_pi_image.image.image_id
}

I believe that will be enough to remove depends_on since we will be referencing them directly and terraform would understand the dependency.

Comment on lines 1 to 8
# 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"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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"
}
data "ibm_resource_group" "group" {
name = var.resource_group
}
# Create a workspace
resource "ibm_resource_instance" "location" {
name = var.workspace_name
resource_group_id = data.ibm_resource_group.group.id
location = var.datacenter
service = "power-iaas"
plan = "power-virtual-server-group"
}

examples/ibm-power/main.tf Outdated Show resolved Hide resolved
examples/ibm-power/main.tf Outdated Show resolved Hide resolved
@ismirlia ismirlia requested a review from michaelkad January 5, 2024 16:04
@ismirlia
Copy link
Collaborator Author

Opened this in the main terraform repo so closing this.

@ismirlia ismirlia closed this Jan 16, 2024
@michaelkad michaelkad deleted the terraform-example branch May 28, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants