Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLOUDGA-24745] Add support for integration type VICTORIAMETRICS #133

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

bhupendray-yb
Copy link
Contributor

@bhupendray-yb bhupendray-yb commented Nov 22, 2024

Summary:

  • Add support for integration type VICTORIAMETRICS.
  • Add TF data-source support for both Prometheus & VictoriaMetrics.

Resource Definition

resource "ybm_integration" "victoriametrics" {
  config_name = "victoriametrics-example"
  type        = "VICTORIAMETRICS"
  victoriametrics_spec = {
    endpoint = "http://yourcompany.com/"
  }
}

Terraform Plan

> tfp

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # ybm_integration.victoriametrics will be created
  + resource "ybm_integration" "victoriametrics" {
      + account_id           = (known after apply)
      + config_id            = (known after apply)
      + config_name          = "victoriametrics-example"
      + is_valid             = (known after apply)
      + project_id           = (known after apply)
      + type                 = "VICTORIAMETRICS"
      + victoriametrics_spec = {
          + endpoint = "http://yourcompany.com/"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Terraform Apply

> tfa -auto-approve

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # ybm_integration.victoriametrics will be created
  + resource "ybm_integration" "victoriametrics" {
      + account_id           = (known after apply)
      + config_id            = (known after apply)
      + config_name          = "victoriametrics-example"
      + is_valid             = (known after apply)
      + project_id           = (known after apply)
      + type                 = "VICTORIAMETRICS"
      + victoriametrics_spec = {
          + endpoint = "http://yourcompany.com/"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.
ybm_integration.victoriametrics: Creating...
tf ybm_integration.victoriametrics: Creation complete after 3s

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Terraform State

> tf state show ybm_integration.victoriametrics
# ybm_integration.victoriametrics:
resource "ybm_integration" "victoriametrics" {
    account_id           = "3b98d883-1b63-40ce-a4d7-8dc2d6e0ba53"
    config_id            = "ea375d4e-7f70-49f5-a187-68d6df7c4bd9"
    config_name          = "victoriametrics-example"
    is_valid             = true
    project_id           = "bebbcb6b-3927-4ac3-81ce-23bba0c75a2e"
    type                 = "VICTORIAMETRICS"
    victoriametrics_spec = {
        endpoint = "http://yourcompany.com/"
    }
}

Terraform Destroy

> tf destroy -auto-approve
ybm_integration.victoriametrics: Refreshing state...

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  # ybm_integration.victoriametrics will be destroyed
  - resource "ybm_integration" "victoriametrics" {
      - account_id           = "3b98d883-1b63-40ce-a4d7-8dc2d6e0ba53" -> null
      - config_id            = "60304dcb-9f44-4e0c-96bf-d9dc7f8b3375" -> null
      - config_name          = "victoriametrics-example" -> null
      - is_valid             = true -> null
      - project_id           = "bebbcb6b-3927-4ac3-81ce-23bba0c75a2e" -> null
      - type                 = "VICTORIAMETRICS" -> null
      - victoriametrics_spec = {
          - endpoint = "http://yourcompany.com/" -> null
        } -> null
    }

Plan: 0 to add, 0 to change, 1 to destroy.
ybm_integration.victoriametrics: Destroying...
ybm_integration.victoriametrics: Destruction complete after 2s

Destroy complete! Resources: 1 destroyed.

Data Source(Prometheus and Victoria Metrics):

Resource definition

data "ybm_integration" "vm_existing_resource" {
  config_name = "victoriametrics-example"
}


resource "ybm_integration" "victoriametrics2" {
  config_name = "victoriametrics-ds"
  type        = "VICTORIAMETRICS"
  victoriametrics_spec = {
    endpoint = data.ybm_integration.vm_existing_resource.victoriametrics_spec.endpoint
  }
}

Terraform apply

> tfa -auto-approve
data.ybm_integration.example_name: Reading...
data.ybm_integration.example_name: Read complete after 3s
ybm_integration.victoriametrics: Refreshing state...

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # ybm_integration.victoriametrics2 will be created
  + resource "ybm_integration" "victoriametrics2" {
      + account_id           = (known after apply)
      + config_id            = (known after apply)
      + config_name          = "victoriametrics-ds"
      + is_valid             = (known after apply)
      + project_id           = (known after apply)
      + type                 = "VICTORIAMETRICS"
      + victoriametrics_spec = {
          + endpoint = "http://yourcompany.com/"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.
ybm_integration.victoriametrics2: Creating...
ybm_integration.victoriametrics2: Creation complete after 2s

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Copy link
Contributor

@bansal01yash bansal01yash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@Siddarth-Baldwa Siddarth-Baldwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes lgtm.

Copy link
Collaborator

@posriniv posriniv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@bansal01yash bansal01yash merged commit f65a485 into main Nov 27, 2024
2 checks passed
@bansal01yash bansal01yash deleted the CLOUDGA-24745 branch November 27, 2024 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants