1. Packages
  2. Ibm Provider
  3. API Docs
  4. getComputeReservedCapacity
ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud

ibm.getComputeReservedCapacity

Explore with Pulumi AI

ibm logo
ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud

    Retrieve information of an existing reserved group as a read-only data source.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ibm from "@pulumi/ibm";
    
    const reservedcapacityds = ibm.getComputeReservedCapacity({
        mostRecent: true,
        name: "reservedgroup",
    });
    
    import pulumi
    import pulumi_ibm as ibm
    
    reservedcapacityds = ibm.get_compute_reserved_capacity(most_recent=True,
        name="reservedgroup")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ibm/ibm"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ibm.LookupComputeReservedCapacity(ctx, &ibm.LookupComputeReservedCapacityArgs{
    			MostRecent: pulumi.BoolRef(true),
    			Name:       "reservedgroup",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ibm = Pulumi.Ibm;
    
    return await Deployment.RunAsync(() => 
    {
        var reservedcapacityds = Ibm.GetComputeReservedCapacity.Invoke(new()
        {
            MostRecent = true,
            Name = "reservedgroup",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ibm.IbmFunctions;
    import com.pulumi.ibm.inputs.GetComputeReservedCapacityArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var reservedcapacityds = IbmFunctions.getComputeReservedCapacity(GetComputeReservedCapacityArgs.builder()
                .mostRecent(true)
                .name("reservedgroup")
                .build());
    
        }
    }
    
    variables:
      reservedcapacityds:
        fn::invoke:
          function: ibm:getComputeReservedCapacity
          arguments:
            mostRecent: true
            name: reservedgroup
    

    The following example shows how you can use this data source to reference the reserved group ID in the ibm.ComputeVmInstance resource because the numeric IDs are often unknown.

    import * as pulumi from "@pulumi/pulumi";
    import * as ibm from "@pulumi/ibm";
    
    const vm1 = new ibm.ComputeVmInstance("vm1", {reservedCapacityId: data.ibm_compute_placement_group.group.id});
    
    import pulumi
    import pulumi_ibm as ibm
    
    vm1 = ibm.ComputeVmInstance("vm1", reserved_capacity_id=data["ibm_compute_placement_group"]["group"]["id"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ibm/ibm"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ibm.NewComputeVmInstance(ctx, "vm1", &ibm.ComputeVmInstanceArgs{
    			ReservedCapacityId: pulumi.Any(data.Ibm_compute_placement_group.Group.Id),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ibm = Pulumi.Ibm;
    
    return await Deployment.RunAsync(() => 
    {
        var vm1 = new Ibm.ComputeVmInstance("vm1", new()
        {
            ReservedCapacityId = data.Ibm_compute_placement_group.Group.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ibm.ComputeVmInstance;
    import com.pulumi.ibm.ComputeVmInstanceArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var vm1 = new ComputeVmInstance("vm1", ComputeVmInstanceArgs.builder()
                .reservedCapacityId(data.ibm_compute_placement_group().group().id())
                .build());
    
        }
    }
    
    resources:
      vm1:
        type: ibm:ComputeVmInstance
        properties:
          reservedCapacityId: ${data.ibm_compute_placement_group.group.id}
    

    Using getComputeReservedCapacity

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getComputeReservedCapacity(args: GetComputeReservedCapacityArgs, opts?: InvokeOptions): Promise<GetComputeReservedCapacityResult>
    function getComputeReservedCapacityOutput(args: GetComputeReservedCapacityOutputArgs, opts?: InvokeOptions): Output<GetComputeReservedCapacityResult>
    def get_compute_reserved_capacity(id: Optional[str] = None,
                                      most_recent: Optional[bool] = None,
                                      name: Optional[str] = None,
                                      opts: Optional[InvokeOptions] = None) -> GetComputeReservedCapacityResult
    def get_compute_reserved_capacity_output(id: Optional[pulumi.Input[str]] = None,
                                      most_recent: Optional[pulumi.Input[bool]] = None,
                                      name: Optional[pulumi.Input[str]] = None,
                                      opts: Optional[InvokeOptions] = None) -> Output[GetComputeReservedCapacityResult]
    func LookupComputeReservedCapacity(ctx *Context, args *LookupComputeReservedCapacityArgs, opts ...InvokeOption) (*LookupComputeReservedCapacityResult, error)
    func LookupComputeReservedCapacityOutput(ctx *Context, args *LookupComputeReservedCapacityOutputArgs, opts ...InvokeOption) LookupComputeReservedCapacityResultOutput

    > Note: This function is named LookupComputeReservedCapacity in the Go SDK.

    public static class GetComputeReservedCapacity 
    {
        public static Task<GetComputeReservedCapacityResult> InvokeAsync(GetComputeReservedCapacityArgs args, InvokeOptions? opts = null)
        public static Output<GetComputeReservedCapacityResult> Invoke(GetComputeReservedCapacityInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetComputeReservedCapacityResult> getComputeReservedCapacity(GetComputeReservedCapacityArgs args, InvokeOptions options)
    public static Output<GetComputeReservedCapacityResult> getComputeReservedCapacity(GetComputeReservedCapacityArgs args, InvokeOptions options)
    
    fn::invoke:
      function: ibm:index/getComputeReservedCapacity:getComputeReservedCapacity
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    The name of the reserved capacity.
    Id string
    (String) The ID of the virtual guest.
    MostRecent bool
    For multiple VM instances, you can set this argument to true to import only the most recently created instance.
    Name string
    The name of the reserved capacity.
    Id string
    (String) The ID of the virtual guest.
    MostRecent bool
    For multiple VM instances, you can set this argument to true to import only the most recently created instance.
    name String
    The name of the reserved capacity.
    id String
    (String) The ID of the virtual guest.
    mostRecent Boolean
    For multiple VM instances, you can set this argument to true to import only the most recently created instance.
    name string
    The name of the reserved capacity.
    id string
    (String) The ID of the virtual guest.
    mostRecent boolean
    For multiple VM instances, you can set this argument to true to import only the most recently created instance.
    name str
    The name of the reserved capacity.
    id str
    (String) The ID of the virtual guest.
    most_recent bool
    For multiple VM instances, you can set this argument to true to import only the most recently created instance.
    name String
    The name of the reserved capacity.
    id String
    (String) The ID of the virtual guest.
    mostRecent Boolean
    For multiple VM instances, you can set this argument to true to import only the most recently created instance.

    getComputeReservedCapacity Result

    The following output properties are available:

    Datacenter string
    (String) The data center in which reserved capacity resides.
    Flavor string
    Id string
    (String) The ID of the virtual guest.
    Instances double
    (int) Number of VSI instances this capacity reservation can support.
    Name string
    Pod string
    (String) The pod in which reserved capacity resides.
    VirtualGuests List<GetComputeReservedCapacityVirtualGuest>
    (List of Objects) A nested block describes the VSIs attached to the reserved capacity.
    MostRecent bool
    Datacenter string
    (String) The data center in which reserved capacity resides.
    Flavor string
    Id string
    (String) The ID of the virtual guest.
    Instances float64
    (int) Number of VSI instances this capacity reservation can support.
    Name string
    Pod string
    (String) The pod in which reserved capacity resides.
    VirtualGuests []GetComputeReservedCapacityVirtualGuest
    (List of Objects) A nested block describes the VSIs attached to the reserved capacity.
    MostRecent bool
    datacenter String
    (String) The data center in which reserved capacity resides.
    flavor String
    id String
    (String) The ID of the virtual guest.
    instances Double
    (int) Number of VSI instances this capacity reservation can support.
    name String
    pod String
    (String) The pod in which reserved capacity resides.
    virtualGuests List<GetComputeReservedCapacityVirtualGuest>
    (List of Objects) A nested block describes the VSIs attached to the reserved capacity.
    mostRecent Boolean
    datacenter string
    (String) The data center in which reserved capacity resides.
    flavor string
    id string
    (String) The ID of the virtual guest.
    instances number
    (int) Number of VSI instances this capacity reservation can support.
    name string
    pod string
    (String) The pod in which reserved capacity resides.
    virtualGuests GetComputeReservedCapacityVirtualGuest[]
    (List of Objects) A nested block describes the VSIs attached to the reserved capacity.
    mostRecent boolean
    datacenter str
    (String) The data center in which reserved capacity resides.
    flavor str
    id str
    (String) The ID of the virtual guest.
    instances float
    (int) Number of VSI instances this capacity reservation can support.
    name str
    pod str
    (String) The pod in which reserved capacity resides.
    virtual_guests Sequence[GetComputeReservedCapacityVirtualGuest]
    (List of Objects) A nested block describes the VSIs attached to the reserved capacity.
    most_recent bool
    datacenter String
    (String) The data center in which reserved capacity resides.
    flavor String
    id String
    (String) The ID of the virtual guest.
    instances Number
    (int) Number of VSI instances this capacity reservation can support.
    name String
    pod String
    (String) The pod in which reserved capacity resides.
    virtualGuests List<Property Map>
    (List of Objects) A nested block describes the VSIs attached to the reserved capacity.
    mostRecent Boolean

    Supporting Types

    GetComputeReservedCapacityVirtualGuest

    Domain string
    (String) The domain of the virtual guest.
    Hostname string
    (String) The hostname of the virtual guest.
    Id double
    (String) The ID of the virtual guest.
    Domain string
    (String) The domain of the virtual guest.
    Hostname string
    (String) The hostname of the virtual guest.
    Id float64
    (String) The ID of the virtual guest.
    domain String
    (String) The domain of the virtual guest.
    hostname String
    (String) The hostname of the virtual guest.
    id Double
    (String) The ID of the virtual guest.
    domain string
    (String) The domain of the virtual guest.
    hostname string
    (String) The hostname of the virtual guest.
    id number
    (String) The ID of the virtual guest.
    domain str
    (String) The domain of the virtual guest.
    hostname str
    (String) The hostname of the virtual guest.
    id float
    (String) The ID of the virtual guest.
    domain String
    (String) The domain of the virtual guest.
    hostname String
    (String) The hostname of the virtual guest.
    id Number
    (String) The ID of the virtual guest.

    Package Details

    Repository
    ibm ibm-cloud/terraform-provider-ibm
    License
    Notes
    This Pulumi package is based on the ibm Terraform Provider.
    ibm logo
    ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud