class Size
Language | Type name |
---|---|
![]() | Amazon.CDK.Size |
![]() | github.com/aws/aws-cdk-go/awscdk/v2#Size |
![]() | software.amazon.awscdk.Size |
![]() | aws_cdk.Size |
![]() | aws-cdk-lib » Size |
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
Name | Description |
---|---|
is | Checks if size is a token or a resolvable object. |
to | Return this storage as a total number of bytes. |
to | Return this storage as a total number of gibibytes. |
to | Return this storage as a total number of kibibytes. |
to | Return this storage as a total number of mebibytes. |
to | Return this storage as a total number of pebibytes. |
to | Return this storage as a total number of tebibytes. |
static bytes(amount) | Create a Storage representing an amount bytes. |
static gibibytes(amount) | Create a Storage representing an amount gibibytes. |
static kibibytes(amount) | Create a Storage representing an amount kibibytes. |
static mebibytes(amount) | Create a Storage representing an amount mebibytes. |
static pebibytes(amount) | Create a Storage representing an amount pebibytes. |
static tebibytes(amount) | Create a Storage representing an amount tebibytes. |
isUnresolved()
public isUnresolved(): boolean
Returns
boolean
Checks if size is a token or a resolvable object.
toBytes(opts?)
public toBytes(opts?: SizeConversionOptions): number
Parameters
- opts
Size
— the conversion options.Conversion Options
Returns
number
Return this storage as a total number of bytes.
toGibibytes(opts?)
public toGibibytes(opts?: SizeConversionOptions): number
Parameters
- opts
Size
— the conversion options.Conversion Options
Returns
number
Return this storage as a total number of gibibytes.
toKibibytes(opts?)
public toKibibytes(opts?: SizeConversionOptions): number
Parameters
- opts
Size
— the conversion options.Conversion Options
Returns
number
Return this storage as a total number of kibibytes.
toMebibytes(opts?)
public toMebibytes(opts?: SizeConversionOptions): number
Parameters
- opts
Size
— the conversion options.Conversion Options
Returns
number
Return this storage as a total number of mebibytes.
toPebibytes(opts?)
public toPebibytes(opts?: SizeConversionOptions): number
Parameters
- opts
Size
— the conversion options.Conversion Options
Returns
number
Return this storage as a total number of pebibytes.
toTebibytes(opts?)
public toTebibytes(opts?: SizeConversionOptions): number
Parameters
- opts
Size
— the conversion options.Conversion Options
Returns
number
Return this storage as a total number of tebibytes.
static bytes(amount)
public static bytes(amount: number): Size
Parameters
- amount
number
— the amount of bytes to be represented.
Returns
Create a Storage representing an amount bytes.
static gibibytes(amount)
public static gibibytes(amount: number): Size
Parameters
- amount
number
— the amount of gibibytes to be represented.
Returns
Create a Storage representing an amount gibibytes.
1 GiB = 1024 MiB
static kibibytes(amount)
public static kibibytes(amount: number): Size
Parameters
- amount
number
— the amount of kibibytes to be represented.
Returns
Create a Storage representing an amount kibibytes.
1 KiB = 1024 bytes
static mebibytes(amount)
public static mebibytes(amount: number): Size
Parameters
- amount
number
— the amount of mebibytes to be represented.
Returns
Create a Storage representing an amount mebibytes.
1 MiB = 1024 KiB
static pebibytes(amount)
public static pebibytes(amount: number): Size
Parameters
- amount
number
— the amount of pebibytes to be represented.
Returns
Create a Storage representing an amount pebibytes.
1 PiB = 1024 TiB
static tebibytes(amount)
public static tebibytes(amount: number): Size
Parameters
- amount
number
— the amount of tebibytes to be represented.
Returns
Create a Storage representing an amount tebibytes.
1 TiB = 1024 GiB