copyright | lastupdated | keywords | subcollection | ||
---|---|---|---|---|---|
|
2024-07-16 |
direct link, terraform |
dl |
{{site.data.keyword.attribute-definition-list}}
{: #terraform-setup-dl}
Terraform on {{site.data.keyword.cloud}} enables predictable and consistent provisioning of {{site.data.keyword.cloud_notm}} services so that you can rapidly build complex, multitier cloud environments that follow Infrastructure as Code (IaC) principles. Similar to using the {{site.data.keyword.cloud_notm}} CLI or API and SDKs, you can automate the provisioning, update, and deletion of your Direct Link instances by using HashiCorp Configuration Language (HCL). {: shortdesc}
Looking for a managed Terraform on {{site.data.keyword.cloud}} solution? Try out {{site.data.keyword.bplong}}. With {{site.data.keyword.bpshort}}, you can use the Terraform scripting language that you are familiar with. You don't have to worry about setting up and maintaining the Terraform command line and the {{site.data.keyword.cloud}} Provider plug-in. {{site.data.keyword.bpshort}} also provides pre-defined Terraform templates that you can easily install from the {{site.data.keyword.cloud}} catalog. {: tip}
{: #install-terraform}
Before you begin, make sure that you have the required access to create and work with Direct Link resources.
-
Follow the Terraform on {{site.data.keyword.cloud}} getting started tutorial to install the Terraform CLI and configure the {{site.data.keyword.cloud}} Provider plug-in for Terraform. The plug-in abstracts the {{site.data.keyword.cloud}} APIs that are used to provision, update, or delete Direct Link service instances and resources.
-
Create a Terraform configuration file that is named
main.tf
. In this file, you add the configuration to create a Direct Link service instance and to assign a user an IAM access policy for that instance. For more information, see the Terraform documentation{: external}.The Direct Link resource in the following example is named
test_dl_routers
and is created as a Dedicated gateway in thedal10
location.For more information about arguments and attributes, see the
ibm_dl_gateway
{: external} usage example. {: note}data "ibm_dl_routers" "test_dl_routers" { offering_type = "dedicated" location_name = "dal10" } resource "ibm_dl_gateway" "test_dl_gateway" { bgp_asn = 64999 global = true metered = false name = "Gateway1" resource_group = "bf823d4f45b64ceaa4671bee0479346e" speed_mbps = 1000 type = "dedicated" cross_connect_router = data.ibm_dl_routers.test_dl_routers.cross_connect_routers[0].router_name location_name = data.ibm_dl_routers.test_dl_routers.location_name customer_name = "Customer1" carrier_name = "Carrier1" }
{: codeblock}
-
Initialize the Terraform CLI.
terraform init
{: pre}
-
Create a Terraform execution plan. The Terraform execution plan summarizes all the actions that need to be run to create the Direct Link instance in your account.
terraform plan
{: pre}
-
Create the Direct Link instance and IAM access policy in {{site.data.keyword.cloud_notm}}.
terraform apply
{: pre}
-
From the {{site.data.keyword.cloud_notm}} resource list{: external}, select the Direct Link instance that you created and note the instance ID.
-
Verify that the access policy is successfully assigned. For more information, see Reviewing assigned access in the console.