===============
Getting Started
===============


Prerequisite:

 - Install terraform following the guide at https://developer.hashicorp.com/terraform/install


1. Add [opentelekomcloud/opentelekomcloud](https://registry.terraform.io/providers/opentelekomcloud/opentelekomcloud/latest/docs) to your `required_providers`.

.. code-block::

    # provider.tf
    terraform {
       required_providers {
          opentelekomcloud = {
             source = "opentelekomcloud/opentelekomcloud"
             version = ">= 1.23.2"
          }
       }
    }


2. Run `terraform init -upgrade` to download the provider.
3. Add the provider and supply your `tenant_name` and `domain_name` for minimum configuration.

.. code-block::

    # provider.tf
    provider "opentelekomcloud" {
       # OpenTelekomCloud Provider Documentation:
       # https://registry.terraform.io/providers/opentelekomcloud/opentelekomcloud/latest/docs
       # domain_name = "..."
       # tenant_name = "..."
       # auth_url    = "https://iam.eu-de.otc.t-systems.com/v3"
       # user_name   = "..."
       # password    = "..."
    }

5. [Authenticate](https://registry.terraform.io/providers/opentelekomcloud/opentelekomcloud/latest/docs#authentication) either by providing `user_name` and `password` in the previous file or setting them as environment variables.

.. code-block::

    # Linux
    OS_USERNAME="<your_username>"
    OS_PASSWORD="<your_password"
    # Windows
    $env:OS_USERNAME="<your_username>"
    $env:OS_PASSWORD="<your_password"

7. Create your first resource.

.. code-block::

    # main.tf

    # Create an Elastic Cloud Server resource
    resource "opentelekomcloud_compute_instance_v2" "debian_ecs" {
       name        = "debian_ecs"
       image_name  = "Standard_Debian_12_latest"
       flavor_name = "s3.medium.1"
       key_pair        = "kp_ecs"
       security_groups = ["default"]
       network {
          name = "network_ecs"
       }
    }

