aws-cdk-lib.Size

class Size

LanguageType name
.NETAmazon.CDK.Size
Gogithub.com/aws/aws-cdk-go/awscdk/v2#Size
Javasoftware.amazon.awscdk.Size
Pythonaws_cdk.Size
TypeScript (source)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

// Provide a Lambda function that will transform records before delivery, with custom
// buffering and retry configuration
const lambdaFunction = new lambda.Function(this, 'Processor', {
  runtime: lambda.Runtime.NODEJS_14_X,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, 'process-records')),
});
const lambdaProcessor = new firehose.LambdaFunctionProcessor(lambdaFunction, {
  bufferInterval: Duration.minutes(5),
  bufferSize: Size.mebibytes(5),
  retries: 5,
});
declare const bucket: s3.Bucket;
const s3Destination = new destinations.S3Bucket(bucket, {
  processor: lambdaProcessor,
});
new firehose.DeliveryStream(this, 'Delivery Stream', {
  destinations: [s3Destination],
});

Methods

NameDescription
isUnresolved()Checks if size is a token or a resolvable object.
toBytes(opts?)Return this storage as a total number of bytes.
toGibibytes(opts?)Return this storage as a total number of gibibytes.
toKibibytes(opts?)Return this storage as a total number of kibibytes.
toMebibytes(opts?)Return this storage as a total number of mebibytes.
toPebibytes(opts?)Return this storage as a total number of pebibytes.
toTebibytes(opts?)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 SizeConversionOptions — the conversion options.

Returns

  • number

Return this storage as a total number of bytes.


toGibibytes(opts?)

public toGibibytes(opts?: SizeConversionOptions): number

Parameters

  • opts SizeConversionOptions — the conversion options.

Returns

  • number

Return this storage as a total number of gibibytes.


toKibibytes(opts?)

public toKibibytes(opts?: SizeConversionOptions): number

Parameters

  • opts SizeConversionOptions — the conversion options.

Returns

  • number

Return this storage as a total number of kibibytes.


toMebibytes(opts?)

public toMebibytes(opts?: SizeConversionOptions): number

Parameters

  • opts SizeConversionOptions — the conversion options.

Returns

  • number

Return this storage as a total number of mebibytes.


toPebibytes(opts?)

public toPebibytes(opts?: SizeConversionOptions): number

Parameters

  • opts SizeConversionOptions — the conversion options.

Returns

  • number

Return this storage as a total number of pebibytes.


toTebibytes(opts?)

public toTebibytes(opts?: SizeConversionOptions): number

Parameters

  • opts SizeConversionOptions — the 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

  • Size

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

  • Size

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

  • Size

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

  • Size

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

  • Size

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

  • Size

Create a Storage representing an amount tebibytes.

1 TiB = 1024 GiB