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,
}),
});
# my_file_system: efs.IFileSystem
# my_job_role: iam.Role
my_file_system.grant_read(my_job_role)
job_defn = batch.EcsJobDefinition(self, "JobDefn",
container=batch.EcsEc2ContainerDefinition(self, "containerDefn",
image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
memory=cdk.Size.mebibytes(2048),
cpu=256,
volumes=[batch.EcsVolume.efs(
name="myVolume",
file_system=my_file_system,
container_path="/Volumes/myVolume",
use_job_role=True
)],
job_role=my_job_role
)
)
IFileSystem myFileSystem;
Role myJobRole;
myFileSystem.grantRead(myJobRole);
EcsJobDefinition jobDefn = EcsJobDefinition.Builder.create(this, "JobDefn")
.container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
.image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
.memory(Size.mebibytes(2048))
.cpu(256)
.volumes(List.of(EcsVolume.efs(EfsVolumeOptions.builder()
.name("myVolume")
.fileSystem(myFileSystem)
.containerPath("/Volumes/myVolume")
.useJobRole(true)
.build())))
.jobRole(myJobRole)
.build())
.build();
// Install: dotnet add package Amazon.CDK.Lib
IFileSystem myFileSystem;
Role myJobRole;
myFileSystem.GrantRead(myJobRole);
var jobDefn = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
Container = new EcsEc2ContainerDefinition(this, "containerDefn", new EcsEc2ContainerDefinitionProps {
Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
Memory = Size.Mebibytes(2048),
Cpu = 256,
Volumes = new [] { EcsVolume.Efs(new EfsVolumeOptions {
Name = "myVolume",
FileSystem = myFileSystem,
ContainerPath = "/Volumes/myVolume",
UseJobRole = true
}) },
JobRole = myJobRole
})
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var myFileSystem IFileSystem
var myJobRole Role
myFileSystem.GrantRead(myJobRole)
jobDefn := batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
Container: batch.NewEcsEc2ContainerDefinition(this, jsii.String("containerDefn"), &EcsEc2ContainerDefinitionProps{
Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
Cpu: jsii.Number(256),
Volumes: []EcsVolume{
batch.EcsVolume_Efs(&EfsVolumeOptions{
Name: jsii.String("myVolume"),
FileSystem: myFileSystem,
ContainerPath: jsii.String("/Volumes/myVolume"),
UseJobRole: jsii.Boolean(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