-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
examples/ibm-power/main.tf
Outdated
resource "ibm_pi_workspace" "powervs_service_instance" { | ||
pi_name = var.workspace_name | ||
pi_datacenter = var.datacenter | ||
pi_resource_group_id = var.resource_group_id |
There was a problem hiding this comment.
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, ...
There was a problem hiding this comment.
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.
examples/ibm-power/main.tf
Outdated
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 |
There was a problem hiding this comment.
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
examples/ibm-power/main.tf
Outdated
|
||
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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" { |
There was a problem hiding this comment.
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.
type = string | ||
default = "<e.g dal>" | ||
} | ||
variable "zone" { | ||
description = "Zone of Service" | ||
type = string | ||
default = "<e.g 12>" | ||
default = "<e.g dal12>" |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made changes
There was a problem hiding this 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.
examples/ibm-power/main.tf
Outdated
# 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" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 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" | |
} |
Opened this in the main terraform repo so closing this. |
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