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")});
import pulumi
import pulumi_castai as castai
test = castai.Reservations("test", reservations_csv=(lambda path: open(path).read())("./reservations.csv"))
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
})
}
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"),
});
});
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());
}
}
resources:
test:
type: castai:Reservations
properties:
reservationsCsv:
fn::readFile: ./reservations.csv
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 instancesend_date
(String) - end date of reservationinstance_type
(String) - reserved instance typename
(String) - unique reservation name in region for specific instance typeprice
(String) - reservation priceprovider
(String) - reservation cloud provider (gcp, aws, azure)region
(String) - reservation regionstart_date
(String) - start date of reservationzone_id
(String) - reservation zone idzone_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 string
- The unique name of the resource.
- args ReservationsArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args 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 string
- The unique name of the resource.
- args ReservationsArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ReservationsArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args 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",
},
});
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"),
},
})
var reservationsResource = new Reservations("reservationsResource", ReservationsArgs.builder()
.reservationsCsv("string")
.organizationId("string")
.reservationsId("string")
.timeouts(ReservationsTimeoutsArgs.builder()
.create("string")
.update("string")
.build())
.build());
reservations_resource = castai.Reservations("reservationsResource",
reservations_csv="string",
organization_id="string",
reservations_id="string",
timeouts={
"create": "string",
"update": "string",
})
const reservationsResource = new castai.Reservations("reservationsResource", {
reservationsCsv: "string",
organizationId: "string",
reservationsId: "string",
timeouts: {
create: "string",
update: "string",
},
});
type: castai:Reservations
properties:
organizationId: string
reservationsCsv: string
reservationsId: string
timeouts:
create: string
update: string
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:
- Reservations
Csv string - csv file containing reservations
- Organization
Id string - organization
- Reservations
Id string - The ID of this resource.
- Timeouts
Reservations
Timeouts
- Reservations
Csv string - csv file containing reservations
- Organization
Id string - organization
- Reservations
Id string - The ID of this resource.
- Timeouts
Reservations
Timeouts Args
- reservations
Csv String - csv file containing reservations
- organization
Id String - organization
- reservations
Id String - The ID of this resource.
- timeouts
Reservations
Timeouts
- reservations
Csv string - csv file containing reservations
- organization
Id string - organization
- reservations
Id string - The ID of this resource.
- timeouts
Reservations
Timeouts
- reservations_
csv str - csv file containing reservations
- organization_
id str - organization
- reservations_
id str - The ID of this resource.
- timeouts
Reservations
Timeouts Args
- reservations
Csv String - csv file containing reservations
- organization
Id String - organization
- reservations
Id 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<Reservations
Reservation>
- Id string
- The provider-assigned unique ID for this managed resource.
- Reservations
[]Reservations
Reservation
- id String
- The provider-assigned unique ID for this managed resource.
- reservations
List<Reservations
Reservation>
- id string
- The provider-assigned unique ID for this managed resource.
- reservations
Reservations
Reservation[]
- id str
- The provider-assigned unique ID for this managed resource.
- reservations
Sequence[Reservations
Reservation]
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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.
- Organization
Id string - organization
- Reservations
List<Reservations
Reservation> - Reservations
Csv string - csv file containing reservations
- Reservations
Id string - The ID of this resource.
- Timeouts
Reservations
Timeouts
- Organization
Id string - organization
- Reservations
[]Reservations
Reservation Args - Reservations
Csv string - csv file containing reservations
- Reservations
Id string - The ID of this resource.
- Timeouts
Reservations
Timeouts Args
- organization
Id String - organization
- reservations
List<Reservations
Reservation> - reservations
Csv String - csv file containing reservations
- reservations
Id String - The ID of this resource.
- timeouts
Reservations
Timeouts
- organization
Id string - organization
- reservations
Reservations
Reservation[] - reservations
Csv string - csv file containing reservations
- reservations
Id string - The ID of this resource.
- timeouts
Reservations
Timeouts
- organization_
id str - organization
- reservations
Sequence[Reservations
Reservation Args] - reservations_
csv str - csv file containing reservations
- reservations_
id str - The ID of this resource.
- timeouts
Reservations
Timeouts Args
- organization
Id String - organization
- reservations List<Property Map>
- reservations
Csv String - csv file containing reservations
- reservations
Id String - The ID of this resource.
- timeouts Property Map
Supporting Types
ReservationsReservation, ReservationsReservationArgs
- count str
- end_
date str - instance_
type str - name str
- price str
- provider str
- region str
- start_
date str - zone_
id str - zone_
name str
ReservationsTimeouts, ReservationsTimeoutsArgs
Import
Import reservations of an organization.
$ pulumi import castai:index/reservations:Reservations test' 5b046e29-e947-470f-9952-bfdf369ecca6
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.