Skip to content

Commit

Permalink
workaroudn to tag TGW
Browse files Browse the repository at this point in the history
  • Loading branch information
lionelmace committed Oct 11, 2023
1 parent d6c978b commit 41fc9b4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions terraform/transit-gateway/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ terraform {
source = "IBM-Cloud/ibm"
version = "1.56.2"
}
http-full = {
source = "salrashid123/http-full"
}
}
}

provider "http-full" {}

provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
region = var.region
Expand Down
24 changes: 24 additions & 0 deletions terraform/transit-gateway/transit-gateway.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,28 @@ resource "ibm_tg_connection" "test_ibm_tg_connection2" {
network_type = "vpc"
name = "myconnection2"
network_id = ibm_is_vpc.vpc2.crn
}

## Workaround to tag transit gateway
##############################################################################
data "ibm_iam_auth_token" "tokendata" {}

data "http" "tag_resource" {
provider = http-full

url = "https://tags.global-search-tagging.cloud.ibm.com/v3/tags/attach?tag_type=user"
method = "POST"

request_headers = {
authorization = data.ibm_iam_auth_token.tokendata.iam_access_token
content-type = "application/json"
accept = "application/json"
}

request_body = jsonencode(
{
resources = [{ resource_id = "${ibm_tg_gateway.my_tgw.crn}" }]
tag_names = ["tf", "tag_2"]
}
)
}

0 comments on commit 41fc9b4

Please sign in to comment.