terraform-provider-ovh icon indicating copy to clipboard operation
terraform-provider-ovh copied to clipboard

Add resource & data source instance

Open Tiboau opened this issue 6 months ago • 0 comments

Description

Add resource and datasource for instance(s)

Type of change

Please delete options that are not relevant.

  • [x] New feature (non-breaking change which adds functionality)
  • [x] Documentation update

How Has This Been Tested?

export OVH_CLOUD_PROJECT_SERVICE_TEST="AAA"
export OVH_CLOUD_PROJECT_REGION_TEST="XXX"
export OVH_CLOUD_PROJECT_IMAGE_ID_TEST="YYYY"
export OVH_CLOUD_PROJECT_FLAVOR_ID_TEST="ZZZZZ"
export OVH_CLOUD_PROJECT_SSH_NAME_TEST="UUUUU"
export OVH_CLOUD_PROJECT_INSTANCE_NAME_TEST="VVVVVV"

➜  terraform-provider-ovh git:(resource_cloud_project_instance.go) make testacc TESTARGS="-run TestAccCloudProjectInstance_basic"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run TestAccCloudProjectInstance_basic -timeout 600m -p 10
?       github.com/ovh/terraform-provider-ovh   [no test files]
?       github.com/ovh/terraform-provider-ovh/ovh/helpers       [no test files]
?       github.com/ovh/terraform-provider-ovh/ovh/types [no test files]
=== RUN   TestAccCloudProjectInstance_basic
    provider_test.go:398: Read Cloud Project /cloud/project/bad3308a4b4d4dcba4d15d5b082d7225 -> status: 'ok', desc: 'Production'
--- PASS: TestAccCloudProjectInstance_basic (55.30s)
PASS
ok      github.com/ovh/terraform-provider-ovh/ovh       55.310s
testing: warning: no tests to run
PASS
ok      github.com/ovh/terraform-provider-ovh/ovh/helpers/hashcode      (cached) [no tests to run]
export OVH_CLOUD_PROJECT_SERVICE_TEST="AAA"
export OVH_CLOUD_PROJECT_REGION_TEST="XXX"
➜  terraform-provider-ovh git:(resource_cloud_project_instance.go) make testacc TESTARGS="-run TestAccDataSourceCloudProjecInstances_basic"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run TestAccDataSourceCloudProjecInstances_basic -timeout 600m -p 10
?       github.com/ovh/terraform-provider-ovh   [no test files]
?       github.com/ovh/terraform-provider-ovh/ovh/helpers       [no test files]
?       github.com/ovh/terraform-provider-ovh/ovh/types [no test files]
=== RUN   TestAccDataSourceCloudProjecInstances_basic
    provider_test.go:398: Read Cloud Project /cloud/project/bad3308a4b4d4dcba4d15d5b082d7225 -> status: 'ok', desc: 'Production'
--- PASS: TestAccDataSourceCloudProjecInstances_basic (6.78s)
PASS
ok      github.com/ovh/terraform-provider-ovh/ovh       6.788s
testing: warning: no tests to run
PASS
ok      github.com/ovh/terraform-provider-ovh/ovh/helpers/hashcode      (cached) [no tests to run]
export OVH_CLOUD_PROJECT_SERVICE_TEST="AAA"
export OVH_CLOUD_PROJECT_REGION_TEST="XXX"
export OVH_CLOUD_PROJECT_INSTANCE_ID_TEST="YYYY"
➜  terraform-provider-ovh git:(resource_cloud_project_instance.go) make testacc TESTARGS="-run TestAccDataSourceCloudProjecInstances_basic"
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run TestAccDataSourceCloudProjecInstancesbasic -timeout 600m -p 10
?       github.com/ovh/terraform-provider-ovh   [no test files]
?       github.com/ovh/terraform-provider-ovh/ovh/helpers       [no test files]
?       github.com/ovh/terraform-provider-ovh/ovh/types [no test files]
testing: warning: no tests to run
PASS
ok      github.com/ovh/terraform-provider-ovh/ovh       0.011s [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/ovh/terraform-provider-ovh/ovh/helpers/hashcode      0.003s [no tests to run]

Test Configuration:

  • Terraform version: terraform version: Terraform vx.y.z
  • Existing HCL configuration you used:
resource "ovh_cloud_project_instance" "instance" {
    region = "BHS5"
    billing_period = "hourly"
    boot_from {
        image_id = "7ec6515e-b390-41f8-a26a-cca7e223ca2d"
    }
    flavor {
        flavor_id = "ac6f8199-3595-446f-bfc7-c80cdfcf9cbe"
    }
    name = "haproxy"
    ssh_key {
        name = "ovh_cloud"
    }
    network {
        public = true
    }   
}

data "ovh_cloud_project_instances" "instances" {
   region = ovh_cloud_project_instance.instance.region
}

data "ovh_cloud_project_instance" "desc" {
   region = ovh_cloud_project_instance.instance.region
   instance_id = ovh_cloud_project_instance.instance.id
}

Checklist:

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] I have made corresponding changes to the documentation
  • [x] My changes generate no new warnings or issues
  • [x] I have added acceptance tests that prove my fix is effective or that my feature works
  • [x] New and existing acceptance tests pass locally with my changes
  • [x] I ran succesfully go mod vendor if I added or modify go.mod file

Tiboau avatar Jul 26 '24 13:07 Tiboau