Size

class aws_cdk.Size(*args: Any, **kwargs)

Bases: object

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.

ExampleMetadata:

infused

Example:

# bucket: s3.Bucket
# Provide a Lambda function that will transform records before delivery, with custom
# buffering and retry configuration
lambda_function = lambda_.Function(self, "Processor",
    runtime=lambda_.Runtime.NODEJS_LATEST,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "process-records"))
)
lambda_processor = firehose.LambdaFunctionProcessor(lambda_function,
    buffer_interval=Duration.minutes(5),
    buffer_size=Size.mebibytes(5),
    retries=5
)
s3_destination = destinations.S3Bucket(bucket,
    processor=lambda_processor
)
firehose.DeliveryStream(self, "Delivery Stream",
    destinations=[s3_destination]
)

Methods

is_unresolved()

Checks if size is a token or a resolvable object.

Return type:

bool

to_bytes(*, rounding=None)

Return this storage as a total number of bytes.

Parameters:

rounding (Optional[SizeRoundingBehavior]) – How conversions should behave when it encounters a non-integer result. Default: SizeRoundingBehavior.FAIL

Return type:

Union[int, float]

Returns:

the quantity expressed in bytes

to_gibibytes(*, rounding=None)

Return this storage as a total number of gibibytes.

Parameters:

rounding (Optional[SizeRoundingBehavior]) – How conversions should behave when it encounters a non-integer result. Default: SizeRoundingBehavior.FAIL

Return type:

Union[int, float]

Returns:

the quantity of bytes expressed in gibibytes

to_kibibytes(*, rounding=None)

Return this storage as a total number of kibibytes.

Parameters:

rounding (Optional[SizeRoundingBehavior]) – How conversions should behave when it encounters a non-integer result. Default: SizeRoundingBehavior.FAIL

Return type:

Union[int, float]

Returns:

the quantity of bytes expressed in kibibytes

to_mebibytes(*, rounding=None)

Return this storage as a total number of mebibytes.

Parameters:

rounding (Optional[SizeRoundingBehavior]) – How conversions should behave when it encounters a non-integer result. Default: SizeRoundingBehavior.FAIL

Return type:

Union[int, float]

Returns:

the quantity of bytes expressed in mebibytes

to_pebibytes(*, rounding=None)

Return this storage as a total number of pebibytes.

Parameters:

rounding (Optional[SizeRoundingBehavior]) – How conversions should behave when it encounters a non-integer result. Default: SizeRoundingBehavior.FAIL

Return type:

Union[int, float]

Returns:

the quantity of bytes expressed in pebibytes

to_tebibytes(*, rounding=None)

Return this storage as a total number of tebibytes.

Parameters:

rounding (Optional[SizeRoundingBehavior]) – How conversions should behave when it encounters a non-integer result. Default: SizeRoundingBehavior.FAIL

Return type:

Union[int, float]

Returns:

the quantity of bytes expressed in tebibytes

Static Methods

classmethod bytes(amount)

Create a Storage representing an amount bytes.

Parameters:

amount (Union[int, float]) – the amount of bytes to be represented.

Return type:

Size

Returns:

a new Size instance

classmethod gibibytes(amount)

Create a Storage representing an amount gibibytes.

1 GiB = 1024 MiB

Parameters:

amount (Union[int, float]) – the amount of gibibytes to be represented.

Return type:

Size

Returns:

a new Size instance

classmethod kibibytes(amount)

Create a Storage representing an amount kibibytes.

1 KiB = 1024 bytes

Parameters:

amount (Union[int, float]) – the amount of kibibytes to be represented.

Return type:

Size

Returns:

a new Size instance

classmethod mebibytes(amount)

Create a Storage representing an amount mebibytes.

1 MiB = 1024 KiB

Parameters:

amount (Union[int, float]) – the amount of mebibytes to be represented.

Return type:

Size

Returns:

a new Size instance

classmethod pebibytes(amount)

Create a Storage representing an amount pebibytes.

1 PiB = 1024 TiB

Parameters:

amount (Union[int, float]) – the amount of pebibytes to be represented.

Return type:

Size

Returns:

a new Size instance

classmethod tebibytes(amount)

Create a Storage representing an amount tebibytes.

1 TiB = 1024 GiB

Parameters:

amount (Union[int, float]) – the amount of tebibytes to be represented.

Return type:

Size

Returns:

a new Size instance