diff --git a/image.tf b/image.tf index 2fcd7d0..7a7062b 100644 --- a/image.tf +++ b/image.tf @@ -19,6 +19,7 @@ locals { user_acct_id = "${substr(element(split("a/", data.ibm_is_subnet.f5_subnet1.resource_crn), 1), 0, 32)}" apikey = "${var.ibmcloud_svc_api_key}" instance_id = "${var.vnf_cos_instance_id}" + image_url="${var.region == "us-south" ? var.vnf_cos_image_url_us_south : var.region == "eu-de" ? var.vnf_cos_image_url_eu_de : var.region == "eu-gb" ? var.vnf_cos_image_url_eu_gb : var.vnf_cos_image_url_us_east }" } ############################################################################## @@ -43,7 +44,6 @@ data "external" "authorize_policy_for_image" { program = ["bash", "${path.module}/scripts/create_auth.sh"] query = { - ibmcloud_endpoint = "${var.ibmcloud_endpoint}" ibmcloud_svc_api_key = "${local.apikey}" source_service_account = "${local.user_acct_id}" source_service_name = "is" @@ -62,7 +62,7 @@ resource "random_uuid" "test" { } resource "ibm_is_image" "f5_custom_image" { depends_on = ["data.external.authorize_policy_for_image", "random_uuid.test"] - href = "cos://${var.region}/vnf-f5-${var.region}/${var.vnf_cos_image_name}" + href = "${local.image_url}" name = "${var.vnf_vpc_image_name}-${substr(random_uuid.test.result,0,8)}" operating_system = "centos-7-amd64" resource_group = "${data.ibm_resource_group.rg.id}" @@ -79,7 +79,6 @@ data "external" "delete_auth_policy_for_image" { query = { id = "${lookup(data.external.authorize_policy_for_image.result, "id")}" - ibmcloud_endpoint = "${var.ibmcloud_endpoint}" ibmcloud_svc_api_key = "${local.apikey}" region = "${data.ibm_is_region.region.name}" } diff --git a/provider.tf b/provider.tf index dcaadf5..56a0b24 100644 --- a/provider.tf +++ b/provider.tf @@ -20,7 +20,7 @@ variable "ibmcloud_svc_api_key" { variable "region" { default="" - description = "The Region where F5 virtual server to be provisioned in. To list available regions, run `ibmcloud is regions`." + description = "The Region where F5 virtual server to be provisioned in. To list available regions, run `ibmcloud is regions`. Supported regions are eu-de, eu-gb, us-south, us-east " } variable "generation" { diff --git a/scripts/create_auth.sh b/scripts/create_auth.sh index a1ba18f..3cc5c46 100644 --- a/scripts/create_auth.sh +++ b/scripts/create_auth.sh @@ -32,13 +32,12 @@ source_service_name="" source_service_account="" source_resource_type="" roles="" -ibmcloud_endpoint="" ibmcloud_svc_api_key="" region="" function parse_input() { _log "## Entering function: ${FUNCNAME[0]}" - eval "$(jq -r '@sh "ibmcloud_endpoint=\(.ibmcloud_endpoint) ibmcloud_svc_api_key=\(.ibmcloud_svc_api_key) region=\(.region) source_service_name=\(.source_service_name) target_service_name=\(.target_service_name) roles=\(.roles) source_service_account=\(.source_service_account) source_resource_type=\(.source_resource_type) target_resource_instance_id=\(.target_resource_instance_id)"')" + eval "$(jq -r '@sh "ibmcloud_svc_api_key=\(.ibmcloud_svc_api_key) region=\(.region) source_service_name=\(.source_service_name) target_service_name=\(.target_service_name) roles=\(.roles) source_service_account=\(.source_service_account) source_resource_type=\(.source_resource_type) target_resource_instance_id=\(.target_resource_instance_id)"')" _log "## Exiting function: ${FUNCNAME[0]}" } @@ -58,7 +57,7 @@ function is_policy_exist() { function login() { _log "## Entering function: ${FUNCNAME[0]}" # Login to IBMCloud for given region and resource-group - ibmcloud login -a "$ibmcloud_endpoint" --apikey "$ibmcloud_svc_api_key" -r "$region" &> "$MSG_FILE" + ibmcloud login -a "cloud.ibm.com" --apikey "$ibmcloud_svc_api_key" -r "$region" &> "$MSG_FILE" _log "## Exiting function: ${FUNCNAME[0]}" } diff --git a/scripts/delete_auth.sh b/scripts/delete_auth.sh index 8bd6152..4677a9e 100644 --- a/scripts/delete_auth.sh +++ b/scripts/delete_auth.sh @@ -5,7 +5,6 @@ set -e # TO-DO comments on input variables -ibmcloud_endpoint="" ibmcloud_svc_api_key="" region="" id="" @@ -34,14 +33,14 @@ function _log() { function parse_input() { _log "## Entering function: ${FUNCNAME[0]}" - eval "$(jq -r '@sh "id=\(.id) ibmcloud_endpoint=\(.ibmcloud_endpoint) ibmcloud_svc_api_key=\(.ibmcloud_svc_api_key) region=\(.region)"')" + eval "$(jq -r '@sh "id=\(.id) ibmcloud_svc_api_key=\(.ibmcloud_svc_api_key) region=\(.region)"')" _log "## Exiting function: ${FUNCNAME[0]}" } function login() { _log "## Entering function: ${FUNCNAME[0]}" # Login to IBMCloud for given region and resource-group - ibmcloud login -a "$ibmcloud_endpoint" --apikey "$ibmcloud_svc_api_key" -r "$region" &> "$MSG_FILE" + ibmcloud login -a "cloud.ibm.com" --apikey "$ibmcloud_svc_api_key" -r "$region" &> "$MSG_FILE" _log "## Exiting function: ${FUNCNAME[0]}" } diff --git a/scripts/delete_custom_image.sh b/scripts/delete_custom_image.sh index 84556df..710372c 100644 --- a/scripts/delete_custom_image.sh +++ b/scripts/delete_custom_image.sh @@ -36,14 +36,7 @@ function parse_input() { ## selecting the riaas endpoint based on the IBM Region and assigning to script variable. ## function select_riaas_endpoint() { - #if [ "$ibmcloud_endpoint" == "cloud.ibm.com" ] - #then - # rias_endpoint="https://us-south.iaas.cloud.ibm.com" - #else - # rias_endpoint="https://us-south-stage01.iaasdev.cloud.ibm.com" - #fi rias_endpoint="https://$region.iaas.cloud.ibm.com" - } #### diff --git a/variables.tf b/variables.tf index d06c6ca..ed64df0 100644 --- a/variables.tf +++ b/variables.tf @@ -62,7 +62,22 @@ variable "vnf_profile" { description = "The profile of compute CPU and memory resources to be used when provisioning F5-BIGIP VSI. To list available profiles, run `ibmcloud is instance-profiles`." } -variable "ibmcloud_endpoint" { - default = "cloud.ibm.com" - description = "The IBM Cloud environmental variable 'cloud.ibm.com' or 'test.cloud.ibm.com'" +variable "vnf_cos_image_url_eu_de" { + default="" + description = "The COS image object SQL URL for F5-BIGIP qcow2 image in Frankfurt(eu-de) region" } + +variable "vnf_cos_image_url_us_south" { + default = "" + description = "The COS image object SQL URL for F5-BIGIP qcow2 image in Dallas(us-south) region" +} + +variable "vnf_cos_image_url_us_east" { + default = "" + description="The COS image object SQL URL for F5-BIGIP qcow2 image in Washington DC(us-east) region " +} + +variable "vnf_cos_image_url_eu_gb" { + default = "" + description="The COS image object SQL URL for F5-BIGIP qcow2 image in London (eu-gb) region " +} \ No newline at end of file