Size Class
Represents the amount of digital storage.
The amount can be specified either as a literal value (e.g: 10) which cannot be negative, or as an unresolved number token.
When the amount is passed as a token, unit conversion is not possible.
Example
declare const myFileSystem: efs.IFileSystem;
declare const myJobRole: iam.Role;
myFileSystem.grantRead(myJobRole);
const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
container: new batch.EcsEc2ContainerDefinition(this, 'containerDefn', {
image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
memory: cdk.Size.mebibytes(2048),
cpu: 256,
volumes: [batch.EcsVolume.efs({
name: 'myVolume',
fileSystem: myFileSystem,
containerPath: '/Volumes/myVolume',
useJobRole: true,
})],
jobRole: myJobRole,
}),
});
Methods
bytes(amount: number): Size // chainable@staticmethod def bytes(amount: int | float) -> Sizepublic static Size bytes(Number amount)public static Size Bytes(double amount)func Bytes(Amount *float64) Sizestatic#1 parameter · returns
Parameters
amountamountamountamountAmount— the amount of bytes to be represented.
Returns: a new Size instance
gibibytes(amount: number): Size // chainable@staticmethod def gibibytes(amount: int | float) -> Sizepublic static Size gibibytes(Number amount)public static Size Gibibytes(double amount)func Gibibytes(Amount *float64) Sizestatic#1 GiB = 1024 MiB
1 parameter · returns
Parameters
amountamountamountamountAmount— the amount of gibibytes to be represented.
Returns: a new Size instance
isUnresolved(): booleandef is_unresolved(self, ) -> boolpublic Boolean isUnresolved()public bool IsUnresolved()func IsUnresolved() *bool#kibibytes(amount: number): Size // chainable@staticmethod def kibibytes(amount: int | float) -> Sizepublic static Size kibibytes(Number amount)public static Size Kibibytes(double amount)func Kibibytes(Amount *float64) Sizestatic#1 KiB = 1024 bytes
1 parameter · returns
Parameters
amountamountamountamountAmount— the amount of kibibytes to be represented.
Returns: a new Size instance
mebibytes(amount: number): Size // chainable@staticmethod def mebibytes(amount: int | float) -> Sizepublic static Size mebibytes(Number amount)public static Size Mebibytes(double amount)func Mebibytes(Amount *float64) Sizestatic#1 MiB = 1024 KiB
1 parameter · returns
Parameters
amountamountamountamountAmount— the amount of mebibytes to be represented.
Returns: a new Size instance
pebibytes(amount: number): Size // chainable@staticmethod def pebibytes(amount: int | float) -> Sizepublic static Size pebibytes(Number amount)public static Size Pebibytes(double amount)func Pebibytes(Amount *float64) Sizestatic#1 PiB = 1024 TiB
1 parameter · returns
Parameters
amountamountamountamountAmount— the amount of pebibytes to be represented.
Returns: a new Size instance
tebibytes(amount: number): Size // chainable@staticmethod def tebibytes(amount: int | float) -> Sizepublic static Size tebibytes(Number amount)public static Size Tebibytes(double amount)func Tebibytes(Amount *float64) Sizestatic#1 TiB = 1024 GiB
1 parameter · returns
Parameters
amountamountamountamountAmount— the amount of tebibytes to be represented.
Returns: a new Size instance
toBytes(opts?: SizeConversionOptions): numberdef to_bytes(self, opts: typing.Optional[SizeConversionOptions] = None) -> int | floatpublic Number toBytes(SizeConversionOptions opts)public double ToBytes(SizeConversionOptions? opts = null)func ToBytes(Opts SizeConversionOptions) *float64#1 parameter · returns
Parameters
optsoptsoptsoptsOpts— the conversion options.
Returns: the quantity expressed in bytes
toGibibytes(opts?: SizeConversionOptions): numberdef to_gibibytes(self, opts: typing.Optional[SizeConversionOptions] = None) -> int | floatpublic Number toGibibytes(SizeConversionOptions opts)public double ToGibibytes(SizeConversionOptions? opts = null)func ToGibibytes(Opts SizeConversionOptions) *float64#1 parameter · returns
Parameters
optsoptsoptsoptsOpts— the conversion options.
Returns: the quantity of bytes expressed in gibibytes
toHumanString(): stringdef to_human_string(self, ) -> strpublic String toHumanString()public string ToHumanString()func ToHumanString() *string#toKibibytes(opts?: SizeConversionOptions): numberdef to_kibibytes(self, opts: typing.Optional[SizeConversionOptions] = None) -> int | floatpublic Number toKibibytes(SizeConversionOptions opts)public double ToKibibytes(SizeConversionOptions? opts = null)func ToKibibytes(Opts SizeConversionOptions) *float64#1 parameter · returns
Parameters
optsoptsoptsoptsOpts— the conversion options.
Returns: the quantity of bytes expressed in kibibytes
toMebibytes(opts?: SizeConversionOptions): numberdef to_mebibytes(self, opts: typing.Optional[SizeConversionOptions] = None) -> int | floatpublic Number toMebibytes(SizeConversionOptions opts)public double ToMebibytes(SizeConversionOptions? opts = null)func ToMebibytes(Opts SizeConversionOptions) *float64#1 parameter · returns
Parameters
optsoptsoptsoptsOpts— the conversion options.
Returns: the quantity of bytes expressed in mebibytes
toPebibytes(opts?: SizeConversionOptions): numberdef to_pebibytes(self, opts: typing.Optional[SizeConversionOptions] = None) -> int | floatpublic Number toPebibytes(SizeConversionOptions opts)public double ToPebibytes(SizeConversionOptions? opts = null)func ToPebibytes(Opts SizeConversionOptions) *float64#1 parameter · returns
Parameters
optsoptsoptsoptsOpts— the conversion options.
Returns: the quantity of bytes expressed in pebibytes
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#toTebibytes(opts?: SizeConversionOptions): numberdef to_tebibytes(self, opts: typing.Optional[SizeConversionOptions] = None) -> int | floatpublic Number toTebibytes(SizeConversionOptions opts)public double ToTebibytes(SizeConversionOptions? opts = null)func ToTebibytes(Opts SizeConversionOptions) *float64#1 parameter · returns
Parameters
optsoptsoptsoptsOpts— the conversion options.
Returns: the quantity of bytes expressed in tebibytes