diff --git a/README.md b/README.md index 15697ef..9b612dd 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,6 @@ Before you apply your template, you can customize the following default variable |Variable Name|Description|Default Value| |-------------|-----------|-------------| -|`ibmcloud_api_key`|[Temp hack] to workaround IBM IS Provider (Image Create) gap. The APIKey of the IBM Cloud account where resources will be provisioned.|`None`| |`ibmcloud_vnf_svc_api_key`|The APIKey of the IBM Cloud NFV service account that is hosting the F5-BIGIP qcow2 image file.|`None`| |`generation`|The VPC Generation to target. Valid values are 2 or 1..|`2`| |`region`|The VPC Region that you want your VPC to be provisioned. To list available zones, run `ibmcloud is regions`.|`us-south`| diff --git a/backends.tf b/backends.tf index 428db0c..c17beb2 100644 --- a/backends.tf +++ b/backends.tf @@ -22,7 +22,7 @@ data "ibm_is_image" "ubuntu_18_image" { resource "ibm_is_instance" "backend_vsi" { count = 2 - name = "backend-vsi-0${count.index}" + name = "${var.vpc_name}-backend-vsi-0${count.index}" image = "${data.ibm_is_image.ubuntu_18_image.id}" profile = "cx2-2x4" diff --git a/compute.tf b/compute.tf index 35bb954..24f92e7 100644 --- a/compute.tf +++ b/compute.tf @@ -23,7 +23,7 @@ data "ibm_is_instance_profile" "f5_profile" { ############################################################################## resource "ibm_is_instance" "f5_vsi" { name = "${var.f5_vsi_name}" - image = "${data.ibm_is_image.f5_custom_image.id}" + image = "${ibm_is_image.f5_custom_image.id}" profile = "${data.ibm_is_instance_profile.f5_profile.name}" primary_network_interface = { diff --git a/image.tf b/image.tf index 6ad5c8a..51fe4bc 100644 --- a/image.tf +++ b/image.tf @@ -3,10 +3,8 @@ # - Creates IAM Authorization Policy in vnfsvc account # - Creates Custom Image in User account # -# Note: There are following gaps in ibm is provider and thus using Terraform tricks -# to overcome the gaps for the PoC sake. -# Gap1: IBM IS Provider missing resource implementation for is_image (Create, update, delete) -# Gap2: IBM IS provider missing data source to read logged user provider session info +# Note: There are following gaps in ibm is provider +# Gap1: : IBM IS provider missing data source to read logged user provider session info # example: account-id ############################################################################## @@ -35,54 +33,21 @@ resource "ibm_iam_authorization_policy" "authorize_image" { target_resource_instance_id = "${var.vnf_f5bigip_cos_instance_id}" } -############################################################################## -# Read Custom Image using the image name and visibility -############################################################################## -data "ibm_is_image" "f5_custom_image" { - depends_on = ["data.external.create_image_hack"] - name = "${var.f5_image_name}" - visibility = "private" -} +# ############################################################################## +# # Read Custom Image using the image name and visibility +# ############################################################################## +# data "ibm_is_image" "f5_custom_image" { +# depends_on = ["data.external.create_image_hack"] +# name = "${var.f5_image_name}" +# visibility = "private" +# } ############################################################################## # Create Custom Image -# Hack: Given ibm provider is missing ibm_is_image resource we using -# external data provider tricks and provisining the resource using bash script. ############################################################################## -data "external" "create_image_hack" { - depends_on = ["ibm_iam_authorization_policy.authorize_image"] - program = ["bash", "${path.module}/scripts/create-image-hack.sh"] - - query = { - ibmcloud_endpoint = "${var.ibmcloud_endpoint}" - ibmcloud_api_key = "${var.ibmcloud_api_key}" - generation = "${var.generation}" - region = "${data.ibm_is_region.region.name}" - resource_group_id = "${data.ibm_resource_group.rg.id}" - f5_image_name = "${var.f5_image_name}" - vnf_f5bigip_cos_image_url = "${var.vnf_f5bigip_cos_image_url}" - } +resource "ibm_is_image" "f5_custom_image" { + depends_on = ["ibm_iam_authorization_policy.authorize_image"] + name = "${var.f5_image_name}" + href = "${var.vnf_f5bigip_cos_image_url}" + operating_system = "centos-7-amd64" } - -# resource "null_resource" "null_custom_image" { -# # provisioner "local-exec" { -# # command = "${path.module}/scripts/create-image-hack.sh" -# # environment = { -# # ibmcloud_api_key = "${var.ibmcloud_api_key}" -# # generation = "${var.generation}" -# # region = "${var.region}" -# # resource_group_id = "${data.ibm_resource_group.rg.id}" -# # f5_image_name = "${var.f5_image_name}" -# # vnf_f5bigip_cos_image_url = "${var.vnf_f5bigip_cos_image_url}" -# # } -# # } -# # provisioner "local-exec" { -# # when = "destroy" -# # command = <