Skip to content

Commit

Permalink
remove ibmcloud endpoint variable and add variables for multi region …
Browse files Browse the repository at this point in the history
…support
  • Loading branch information
pkrishn1-pk committed Apr 27, 2020
1 parent c964a5d commit 9eec9b3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 20 deletions.
5 changes: 2 additions & 3 deletions image.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 }"
}

##############################################################################
Expand All @@ -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"
Expand All @@ -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}"
Expand All @@ -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}"
}
Expand Down
2 changes: 1 addition & 1 deletion provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
5 changes: 2 additions & 3 deletions scripts/create_auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]}"
}

Expand All @@ -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]}"
}

Expand Down
5 changes: 2 additions & 3 deletions scripts/delete_auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ set -e

# TO-DO comments on input variables

ibmcloud_endpoint=""
ibmcloud_svc_api_key=""
region=""
id=""
Expand Down Expand Up @@ -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]}"
}

Expand Down
7 changes: 0 additions & 7 deletions scripts/delete_custom_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

}

####
Expand Down
21 changes: 18 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
}

0 comments on commit 9eec9b3

Please sign in to comment.