1. Packages
  2. Castai Provider
  3. API Docs
  4. Reservations
castai 7.44.1 published on Monday, Mar 31, 2025 by castai

castai.Reservations

Explore with Pulumi AI

Reservation represents cloud service provider reserved instances that can be used by CAST AI autoscaler.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as castai from "@pulumi/castai";
import * as fs from "fs";

const test = new castai.Reservations("test", {reservationsCsv: fs.readFileSync("./reservations.csv", "utf8")});
Copy
import pulumi
import pulumi_castai as castai

test = castai.Reservations("test", reservations_csv=(lambda path: open(path).read())("./reservations.csv"))
Copy
package main

import (
	"os"

	"github.com/pulumi/pulumi-terraform-provider/sdks/go/castai/v7/castai"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func readFileOrPanic(path string) pulumi.StringPtrInput {
	data, err := os.ReadFile(path)
	if err != nil {
		panic(err.Error())
	}
	return pulumi.String(string(data))
}

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := castai.NewReservations(ctx, "test", &castai.ReservationsArgs{
			ReservationsCsv: pulumi.String(readFileOrPanic("./reservations.csv")),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Pulumi;
using Castai = Pulumi.Castai;

return await Deployment.RunAsync(() => 
{
    var test = new Castai.Reservations("test", new()
    {
        ReservationsCsv = File.ReadAllText("./reservations.csv"),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.castai.Reservations;
import com.pulumi.castai.ReservationsArgs;
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 test = new Reservations("test", ReservationsArgs.builder()
            .reservationsCsv(Files.readString(Paths.get("./reservations.csv")))
            .build());

    }
}
Copy
resources:
  test:
    type: castai:Reservations
    properties:
      reservationsCsv:
        fn::readFile: ./reservations.csv
Copy

Reservations CSV structure

The file should be made up of reservation entries with comma separated values with the first row being column headers.

  • count (String) - amount of reserved instances
  • end_date (String) - end date of reservation
  • instance_type (String) - reserved instance type
  • name (String) - unique reservation name in region for specific instance type
  • price (String) - reservation price
  • provider (String) - reservation cloud provider (gcp, aws, azure)
  • region (String) - reservation region
  • start_date (String) - start date of reservation
  • zone_id (String) - reservation zone id
  • zone_name (String) - reservation zone name

Example CSV file:

name,provider,region,instance_type,price,count,start_date,end_date,zone_id,zone_name
reservation1,aws,us-east-1,c5n.large,,1,2020-01-01T00:00:00Z,2050-01-01T00:00:00Z,,
reservation2,aws,us-east-1,c5n.large,,2,2020-01-01T00:00:00Z,2050-01-01T00:00:01Z,,

Azure exported reservations

Reservations exported from Azure in CSV format are also accepted. Example of such CSV file:

Name,Reservation Id,Reservation order Id,Status,Expiration date,Purchase date,Term,Scope,Scope subscription,Scope resource group,Type,Product name,Region,Quantity,Utilization % 1 Day,Utilization % 7 Day,Utilization % 30 Day,Deep link to reservation
VM_RI_01-01-2023_01-01,3b3de39c-bc44-4d69-be2d-69527dfe9958,630226bb-5170-4b95-90b0-f222757130c1,Succeeded,2050-01-01T00:00:00Z,2023-01-11T00:00:00Z,P3Y,Single subscription,8faa0959-093b-4612-8686-a996ac19db00,All resource groups,VirtualMachines,Standard_D32as_v4,eastus,3,100,100,100,https://portal.azure.com#resource/providers/microsoft.capacity/reservationOrders/59791a62-264b-4b9f-aa3a-5eeb761e4583/reservations/883afd52-54c8-4bc6-a0f2-ccbaf7b84bda/overview
VM_RI_01-01-2023_01-02,3b3de39c-bc44-4d69-be2d-69527dfe9958,630226bb-5170-4b95-90b0-f222757130c1,Succeeded,2050-01-01T00:00:00Z,2023-01-11T00:00:01Z,P3Y,Single subscription,8faa0959-093b-4612-8686-a996ac19db00,All resource groups,VirtualMachines,Standard_D32as_v4,eastus,2,100,100,100,https://portal.azure.com#resource/providers/microsoft.capacity/reservationOrders/59791a62-264b-4b9f-aa3a-5eeb761e4583/reservations/25b95bdb-b78b-4973-a60c-71e70f158eca/overview
VM_RI_01-01-2023_01-03,3b3de39c-bc44-4d69-be2d-69527dfe9958,630226bb-5170-4b95-90b0-f222757130c1,Succeeded,2050-01-01T00:00:00Z,2023-01-11T00:00:02Z,P3Y,Single subscription,8faa0959-093b-4612-8686-a996ac19db00,All resource groups,VirtualMachines,Standard_D32as_v4,eastus,1,100,100,100,https://portal.azure.com#resource/providers/microsoft.capacity/reservationOrders/59791a62-264b-4b9f-aa3a-5eeb761e4583/reservations/1745741b-f3c6-46a9-ad16-b93775a1bc38/overview

Create Reservations Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Reservations(name: string, args: ReservationsArgs, opts?: CustomResourceOptions);
@overload
def Reservations(resource_name: str,
                 args: ReservationsArgs,
                 opts: Optional[ResourceOptions] = None)

@overload
def Reservations(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 reservations_csv: Optional[str] = None,
                 organization_id: Optional[str] = None,
                 reservations_id: Optional[str] = None,
                 timeouts: Optional[ReservationsTimeoutsArgs] = None)
func NewReservations(ctx *Context, name string, args ReservationsArgs, opts ...ResourceOption) (*Reservations, error)
public Reservations(string name, ReservationsArgs args, CustomResourceOptions? opts = null)
public Reservations(String name, ReservationsArgs args)
public Reservations(String name, ReservationsArgs args, CustomResourceOptions options)
type: castai:Reservations
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ReservationsArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ReservationsArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ReservationsArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ReservationsArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ReservationsArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var reservationsResource = new Castai.Reservations("reservationsResource", new()
{
    ReservationsCsv = "string",
    OrganizationId = "string",
    ReservationsId = "string",
    Timeouts = new Castai.Inputs.ReservationsTimeoutsArgs
    {
        Create = "string",
        Update = "string",
    },
});
Copy
example, err := castai.NewReservations(ctx, "reservationsResource", &castai.ReservationsArgs{
ReservationsCsv: pulumi.String("string"),
OrganizationId: pulumi.String("string"),
ReservationsId: pulumi.String("string"),
Timeouts: &.ReservationsTimeoutsArgs{
Create: pulumi.String("string"),
Update: pulumi.String("string"),
},
})
Copy
var reservationsResource = new Reservations("reservationsResource", ReservationsArgs.builder()
    .reservationsCsv("string")
    .organizationId("string")
    .reservationsId("string")
    .timeouts(ReservationsTimeoutsArgs.builder()
        .create("string")
        .update("string")
        .build())
    .build());
Copy
reservations_resource = castai.Reservations("reservationsResource",
    reservations_csv="string",
    organization_id="string",
    reservations_id="string",
    timeouts={
        "create": "string",
        "update": "string",
    })
Copy
const reservationsResource = new castai.Reservations("reservationsResource", {
    reservationsCsv: "string",
    organizationId: "string",
    reservationsId: "string",
    timeouts: {
        create: "string",
        update: "string",
    },
});
Copy
type: castai:Reservations
properties:
    organizationId: string
    reservationsCsv: string
    reservationsId: string
    timeouts:
        create: string
        update: string
Copy

Reservations Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Reservations resource accepts the following input properties:

ReservationsCsv This property is required. string
csv file containing reservations
OrganizationId string
organization
ReservationsId string
The ID of this resource.
Timeouts ReservationsTimeouts
ReservationsCsv This property is required. string
csv file containing reservations
OrganizationId string
organization
ReservationsId string
The ID of this resource.
Timeouts ReservationsTimeoutsArgs
reservationsCsv This property is required. String
csv file containing reservations
organizationId String
organization
reservationsId String
The ID of this resource.
timeouts ReservationsTimeouts
reservationsCsv This property is required. string
csv file containing reservations
organizationId string
organization
reservationsId string
The ID of this resource.
timeouts ReservationsTimeouts
reservations_csv This property is required. str
csv file containing reservations
organization_id str
organization
reservations_id str
The ID of this resource.
timeouts ReservationsTimeoutsArgs
reservationsCsv This property is required. String
csv file containing reservations
organizationId String
organization
reservationsId String
The ID of this resource.
timeouts Property Map

Outputs

All input properties are implicitly available as output properties. Additionally, the Reservations resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Reservations List<ReservationsReservation>
Id string
The provider-assigned unique ID for this managed resource.
Reservations []ReservationsReservation
id String
The provider-assigned unique ID for this managed resource.
reservations List<ReservationsReservation>
id string
The provider-assigned unique ID for this managed resource.
reservations ReservationsReservation[]
id str
The provider-assigned unique ID for this managed resource.
reservations Sequence[ReservationsReservation]
id String
The provider-assigned unique ID for this managed resource.
reservations List<Property Map>

Look up Existing Reservations Resource

Get an existing Reservations resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ReservationsState, opts?: CustomResourceOptions): Reservations
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        organization_id: Optional[str] = None,
        reservations: Optional[Sequence[ReservationsReservationArgs]] = None,
        reservations_csv: Optional[str] = None,
        reservations_id: Optional[str] = None,
        timeouts: Optional[ReservationsTimeoutsArgs] = None) -> Reservations
func GetReservations(ctx *Context, name string, id IDInput, state *ReservationsState, opts ...ResourceOption) (*Reservations, error)
public static Reservations Get(string name, Input<string> id, ReservationsState? state, CustomResourceOptions? opts = null)
public static Reservations get(String name, Output<String> id, ReservationsState state, CustomResourceOptions options)
resources:  _:    type: castai:Reservations    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
OrganizationId string
organization
Reservations List<ReservationsReservation>
ReservationsCsv string
csv file containing reservations
ReservationsId string
The ID of this resource.
Timeouts ReservationsTimeouts
OrganizationId string
organization
Reservations []ReservationsReservationArgs
ReservationsCsv string
csv file containing reservations
ReservationsId string
The ID of this resource.
Timeouts ReservationsTimeoutsArgs
organizationId String
organization
reservations List<ReservationsReservation>
reservationsCsv String
csv file containing reservations
reservationsId String
The ID of this resource.
timeouts ReservationsTimeouts
organizationId string
organization
reservations ReservationsReservation[]
reservationsCsv string
csv file containing reservations
reservationsId string
The ID of this resource.
timeouts ReservationsTimeouts
organizationId String
organization
reservations List<Property Map>
reservationsCsv String
csv file containing reservations
reservationsId String
The ID of this resource.
timeouts Property Map

Supporting Types

ReservationsReservation
, ReservationsReservationArgs

Count This property is required. string
EndDate This property is required. string
InstanceType This property is required. string
Name This property is required. string
Price This property is required. string
Provider This property is required. string
Region This property is required. string
StartDate This property is required. string
ZoneId This property is required. string
ZoneName This property is required. string
Count This property is required. string
EndDate This property is required. string
InstanceType This property is required. string
Name This property is required. string
Price This property is required. string
Provider This property is required. string
Region This property is required. string
StartDate This property is required. string
ZoneId This property is required. string
ZoneName This property is required. string
count This property is required. String
endDate This property is required. String
instanceType This property is required. String
name This property is required. String
price This property is required. String
provider This property is required. String
region This property is required. String
startDate This property is required. String
zoneId This property is required. String
zoneName This property is required. String
count This property is required. string
endDate This property is required. string
instanceType This property is required. string
name This property is required. string
price This property is required. string
provider This property is required. string
region This property is required. string
startDate This property is required. string
zoneId This property is required. string
zoneName This property is required. string
count This property is required. str
end_date This property is required. str
instance_type This property is required. str
name This property is required. str
price This property is required. str
provider This property is required. str
region This property is required. str
start_date This property is required. str
zone_id This property is required. str
zone_name This property is required. str
count This property is required. String
endDate This property is required. String
instanceType This property is required. String
name This property is required. String
price This property is required. String
provider This property is required. String
region This property is required. String
startDate This property is required. String
zoneId This property is required. String
zoneName This property is required. String

ReservationsTimeouts
, ReservationsTimeoutsArgs

Create string
Update string
Create string
Update string
create String
update String
create string
update string
create str
update str
create String
update String

Import

Import reservations of an organization.

$ pulumi import castai:index/reservations:Reservations test' 5b046e29-e947-470f-9952-bfdf369ecca6
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
castai castai/terraform-provider-castai
License
Notes
This Pulumi package is based on the castai Terraform Provider.