class ServerlessCache (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.ElastiCache.Alpha.ServerlessCache |
Go | github.com/aws/aws-cdk-go/awscdkelasticachealpha/v2#ServerlessCache |
Java | software.amazon.awscdk.services.elasticache.alpha.ServerlessCache |
Python | aws_cdk.aws_elasticache_alpha.ServerlessCache |
TypeScript (source) | @aws-cdk/aws-elasticache-alpha ยป ServerlessCache |
Implements
IConstruct, IDependable, IResource, IEnvironment, IServerless, IConnectable
A serverless ElastiCache cache.
Example
declare const vpc: ec2.Vpc;
const serverlessCache = new elasticache.ServerlessCache(this, 'ServerlessCache', {
engine: elasticache.CacheEngine.VALKEY_LATEST,
backup: {
// set a backup name before deleting a cache
backupNameBeforeDeletion: "my-final-backup-name",
},
vpc,
});
Initializer
new ServerlessCache(scope: Construct, id: string, props: ServerlessCacheProps)
Parameters
- scope
Construct - id
string - props
ServerlessCache Props
Construct Props
| Name | Type | Description |
|---|---|---|
| vpc | IVpc | The VPC to place the cache in. |
| backup? | Backup | Backup configuration. |
| cache | Cache | Usage limits for the cache. |
| description? | string | A description for the cache. |
| engine? | Cache | The cache engine combined with the version Enum options: VALKEY_DEFAULT, VALKEY_7, VALKEY_8, REDIS_DEFAULT, MEMCACHED_DEFAULT The default options bring the latest versions available. |
| kms | IKey | KMS key for encryption. |
| security | ISecurity[] | Security groups for the cache. |
| serverless | string | Name for the serverless cache. |
| user | IUser | User group for access control. |
| vpc | Subnet | Which subnets to place the cache in. |
vpc
Type:
IVpc
The VPC to place the cache in.
backup?
Type:
Backup
(optional, default: No backups configured)
Backup configuration.
cacheUsageLimits?
Type:
Cache
(optional, default: No usage limits)
Usage limits for the cache.
description?
Type:
string
(optional, default: No description)
A description for the cache.
engine?
Type:
Cache
(optional, default: when not provided, the default engine would be Valkey, latest version available (VALKEY_DEFAULT))
The cache engine combined with the version Enum options: VALKEY_DEFAULT, VALKEY_7, VALKEY_8, REDIS_DEFAULT, MEMCACHED_DEFAULT The default options bring the latest versions available.
kmsKey?
Type:
IKey
(optional, default: Service managed encryption (AWS owned KMS key))
KMS key for encryption.
securityGroups?
Type:
ISecurity[]
(optional, default: A new security group is created)
Security groups for the cache.
serverlessCacheName?
Type:
string
(optional, default: automatically generated name by Resource)
Name for the serverless cache.
userGroup?
Type:
IUser
(optional, default: No user group)
User group for access control.
vpcSubnets?
Type:
Subnet
(optional, default: Private subnets with egress)
Which subnets to place the cache in.
Properties
| Name | Type | Description |
|---|---|---|
| connections | Connections | Access to network connections. |
| env | Resource | The environment this resource belongs to. |
| node | Node | The tree node. |
| serverless | string | The ARN of the serverless cache. |
| serverless | string | The endpoint address of the serverless cache. |
| serverless | string | The endpoint port of the serverless cache. |
| serverless | string | The name of the serverless cache. |
| serverless | string | The reader endpoint address of the serverless cache. |
| serverless | string | The reader endpoint port of the serverless cache. |
| serverless | string | The current status of the serverless cache Can be 'CREATING', 'AVAILABLE', 'DELETING', 'CREATE-FAILED', 'MODIFYING'. |
| stack | Stack | The stack in which this resource is defined. |
| backup | string[] | The ARNs of backups restored in the cache. |
| engine? | Cache | The cache engine used by this cache. |
| kms | IKey | The KMS key used for encryption. |
| security | ISecurity[] | The security groups associated with this cache. |
| subnets? | ISubnet[] | The subnets this cache is deployed in. |
| user | IUser | The user group associated with this cache. |
| vpc? | IVpc | The VPC this cache is deployed in. |
| static PROPERTY_INJECTION_ID | string | Uniquely identifies this class. |
connections
Type:
Connections
Access to network connections.
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
node
Type:
Node
The tree node.
serverlessCacheArn
Type:
string
The ARN of the serverless cache.
serverlessCacheEndpointAddress
Type:
string
The endpoint address of the serverless cache.
serverlessCacheEndpointPort
Type:
string
The endpoint port of the serverless cache.
serverlessCacheName
Type:
string
The name of the serverless cache.
serverlessCacheReaderEndpointAddress
Type:
string
The reader endpoint address of the serverless cache.
serverlessCacheReaderEndpointPort
Type:
string
The reader endpoint port of the serverless cache.
serverlessCacheStatus
Type:
string
The current status of the serverless cache Can be 'CREATING', 'AVAILABLE', 'DELETING', 'CREATE-FAILED', 'MODIFYING'.
stack
Type:
Stack
The stack in which this resource is defined.
backupArnsToRestore?
Type:
string[]
(optional)
The ARNs of backups restored in the cache.
engine?
Type:
Cache
(optional)
The cache engine used by this cache.
kmsKey?
Type:
IKey
(optional)
The KMS key used for encryption.
securityGroups?
Type:
ISecurity[]
(optional)
The security groups associated with this cache.
subnets?
Type:
ISubnet[]
(optional)
The subnets this cache is deployed in.
userGroup?
Type:
IUser
(optional)
The user group associated with this cache.
vpc?
Type:
IVpc
(optional)
The VPC this cache is deployed in.
static PROPERTY_INJECTION_ID
Type:
string
Uniquely identifies this class.
Methods
| Name | Description |
|---|---|
| apply | Apply the given removal policy to this resource. |
| grant(grantee, ...actions) | Grant the given identity custom permissions. |
| grant | Grant connect permissions to the cache. |
| metric(metricName, props?) | Return the given named metric for this cache. |
| metric | Metric for active connections. |
| metric | Metric for cache hit count. |
| metric | Metric for cache hit rate. |
| metric | Metric for cache miss count. |
| metric | Metric for data stored in the cache. |
| metric | Metric for network bytes in. |
| metric | Metric for network bytes out. |
| metric | Metric for ECPUs consumed. |
| metric | Metric for read request latency. |
| metric | Metric for write request latency. |
| to | Returns a string representation of this construct. |
| static from | Import an existing serverless cache by ARN. |
| static from | Import an existing serverless cache using attributes. |
| static from | Import an existing serverless cache by name. |
| static is | Return whether the given object is a ServerlessCache. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
RemovalPolicy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN).
grant(grantee, ...actions)
public grant(grantee: IGrantable, ...actions: string[]): Grant
Parameters
- grantee
IGrantableโ The principal to grant permissions to. - actions
stringโ The actions to grant.
Returns
Grant the given identity custom permissions.
grantConnect(grantee)
public grantConnect(grantee: IGrantable): Grant
Parameters
- grantee
IGrantableโ The principal to grant permissions to.
Returns
Grant connect permissions to the cache.
metric(metricName, props?)
public metric(metricName: string, props?: MetricOptions): Metric
Parameters
- metricName
stringโ The name of the metric. - props
Metricโ Additional properties which will be merged with the default metric.Options
Returns
Return the given named metric for this cache.
metricActiveConnections(props?)
public metricActiveConnections(props?: MetricOptions): Metric
Parameters
- props
Metricโ Additional properties which will be merged with the default metric.Options
Returns
Metric for active connections.
metricCacheHitCount(props?)
public metricCacheHitCount(props?: MetricOptions): Metric
Parameters
- props
Metricโ Additional properties which will be merged with the default metric.Options
Returns
Metric for cache hit count.
metricCacheHitRate(props?)
public metricCacheHitRate(props?: MetricOptions): Metric
Parameters
- props
Metricโ Additional properties which will be merged with the default metric.Options
Returns
Metric for cache hit rate.
metricCacheMissCount(props?)
public metricCacheMissCount(props?: MetricOptions): Metric
Parameters
- props
Metricโ Additional properties which will be merged with the default metric.Options
Returns
Metric for cache miss count.
metricDataStored(props?)
public metricDataStored(props?: MetricOptions): Metric
Parameters
- props
Metricโ Additional properties which will be merged with the default metric.Options
Returns
Metric for data stored in the cache.
metricNetworkBytesIn(props?)
public metricNetworkBytesIn(props?: MetricOptions): Metric
Parameters
- props
Metricโ Additional properties which will be merged with the default metric.Options
Returns
Metric for network bytes in.
metricNetworkBytesOut(props?)
public metricNetworkBytesOut(props?: MetricOptions): Metric
Parameters
- props
Metricโ Additional properties which will be merged with the default metric.Options
Returns
Metric for network bytes out.
metricProcessingUnitsConsumed(props?)
public metricProcessingUnitsConsumed(props?: MetricOptions): Metric
Parameters
- props
Metricโ Additional properties which will be merged with the default metric.Options
Returns
Metric for ECPUs consumed.
metricReadRequestLatency(props?)
public metricReadRequestLatency(props?: MetricOptions): Metric
Parameters
- props
Metricโ Additional properties which will be merged with the default metric.Options
Returns
Metric for read request latency.
metricWriteRequestLatency(props?)
public metricWriteRequestLatency(props?: MetricOptions): Metric
Parameters
- props
Metricโ Additional properties which will be merged with the default metric.Options
Returns
Metric for write request latency.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromServerlessCacheArn(scope, id, serverlessCacheArn)
public static fromServerlessCacheArn(scope: Construct, id: string, serverlessCacheArn: string): IServerlessCache
Parameters
- scope
Constructโ The parent creating construct (usuallythis). - id
stringโ The construct's name. - serverlessCacheArn
stringโ The ARN of the existing serverless cache.
Returns
Import an existing serverless cache by ARN.
static fromServerlessCacheAttributes(scope, id, attrs)
public static fromServerlessCacheAttributes(scope: Construct, id: string, attrs: ServerlessCacheAttributes): IServerlessCache
Parameters
- scope
Constructโ The parent creating construct (usuallythis). - id
stringโ The construct's name. - attrs
Serverlessโ ACache Attributes ServerlessCacheAttributesobject.
Returns
Import an existing serverless cache using attributes.
static fromServerlessCacheName(scope, id, serverlessCacheName)
public static fromServerlessCacheName(scope: Construct, id: string, serverlessCacheName: string): IServerlessCache
Parameters
- scope
Constructโ The parent creating construct (usuallythis). - id
stringโ The construct's name. - serverlessCacheName
stringโ The name of the existing serverless cache.
Returns
Import an existing serverless cache by name.
static isServerlessCache(x)
public static isServerlessCache(x: any): boolean
Parameters
- x
any
Returns
boolean
Return whether the given object is a ServerlessCache.

.NET
Go
Java
Python
TypeScript (