|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cryptocurrency News Articles
Deploy Amazon ElastiCache for Redis clusters using AWS CDK and TypeScript | AWS Database Blog
Apr 05, 2024 at 11:25 pm
The AWS Cloud Development Kit (AWS CDK) allows you to create AWS resources with a single line of code. For example, you can create a VPC in TypeScript with the following line:new EC2.Vpc(this, 'cache_vpc');However, several AWS resources require several lines of code because you often need to create supporting resources. For example, you need to create a CfnSubnetGroup and a SecurityGroup before creating an Amazon ElastiCache for Redis CfnReplicationGroup. This abstract demonstrates the steps to deploy an Amazon ElastiCache cluster using AWS CDK and TypeScript. We also show you how to deploy resources using Amazon ElastiCache for Redis Serverless.

Creating AWS Resources with AWS Cloud Development Kit (AWS CDK) for ElastiCache
Introduction
AWS Cloud Development Kit (AWS CDK) enables developers to define and provision AWS resources using familiar programming languages such as TypeScript. This article guides readers through the process of deploying an Amazon ElastiCache cluster and ElastiCache Serverless resources using AWS CDK and TypeScript.
Prerequisites
- AWS account
- AWS Command Line Interface (AWS CLI)
- AWS CDK
- Node.js 16.14.0 or later
Creating Prerequisite Resources
- Install AWS CDK:
npm install -g aws-cdk
cdk --version- Create AWS CDK Directory Structure:
mkdir work & cd work
cdk init --language typescript- Install NPM Packages:
npm install- Create VPC:
In the lib/work-stack.ts file, create a VPC:
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as EC2 from 'aws-cdk-lib/aws-ec2';
export class WorkStack extends cdk.Stack {
private vpc: EC2.Vpc;
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
this.vpc = new EC2.Vpc(this, 'cache_vpc');
}
}- Bootstrap AWS Environment:
cdk bootstrap- Synthesize CloudFormation Template:
cdk synth- Deploy VPC:
cdk deploy --require-approval neverCreate Subnet Group
- Update
lib/work-stack.tsto create a subnet group for ElastiCache:
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as EC2 from 'aws-cdk-lib/aws-ec2';
import { aws_elasticache as ElastiCache } from 'aws-cdk-lib';
export class WorkStack extends cdk.Stack {
private vpc: EC2.Vpc;
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
const groupName = "ElastiCacheSubnetGroup";
super(scope, id, props);
this.vpc = new EC2.Vpc(this, 'cache_vpc');
const subnetIds = [];
for (const subnet of this.vpc.privateSubnets) {
console.log("createElastiCache subnet ID: ", subnet.subnetId);
subnetIds.push(subnet.subnetId);
}
const subnetGroup = new ElastiCache.CfnSubnetGroup(this, "ElastiCacheSubnetGroup", {
cacheSubnetGroupName: groupName,
subnetIds: subnetIds,
description: "ElastiCache Subnet Group",
});
}
}- Synthesize and deploy the stack:
cdk synth; cdk deploy --require-approval neverCreating an ElastiCache for Redis Replication Group
- Create Security Group:
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as EC2 from 'aws-cdk-lib/aws-ec2';
import { aws_elasticache as ElastiCache } from 'aws-cdk-lib';
import { SecurityGroup, Peer, Port } from 'aws-cdk-lib/aws-ec2';
export class WorkStack extends cdk.Stack {
private vpc: EC2.Vpc;
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
const groupName = "ElastiCacheSubnetGroup";
super(scope, id, props);
this.vpc = new EC2.Vpc(this, 'cache_vpc');
const subnetIds = [];
for (const subnet of this.vpc.privateSubnets) {
console.log("createElastiCache subnet ID: ", subnet.subnetId);
subnetIds.push(subnet.subnetId);
}
const subnetGroup = new ElastiCache.CfnSubnetGroup(this, "ElastiCacheSubnetGroup", {
cacheSubnetGroupName: groupName,
subnetIds: subnetIds,
description: "ElastiCache Subnet Group",
});
const securityGroup = new SecurityGroup(this, "ElastiCacheSecurityGroup", {
vpc: this.vpc,
allowAllOutbound: true,
description: "ElastiCache Security Group",
securityGroupName: "ElastiCacheSecurityGroup",
});
securityGroup.addIngressRule(Peer.anyIpv4(), Port.tcp(6379), "Redis port");
}
}- Create Replication Group:
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as EC2 from 'aws-cdk-lib/aws-ec2';
import { aws_elasticache as ElastiCache } from 'aws-cdk-lib';
import { SecurityGroup, Peer, Port } from 'aws-cdk-lib/aws-ec2';
export class WorkStack extends cdk.Stack {
private vpc: EC2.Vpc;
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
const groupName = "ElastiCacheSubnetGroup";
super(scope, id, props);
this.vpc = new EC2.Vpc(this, 'cache_vpc');
const subnetIds = [];
for (const subnet of this.vpc.privateSubnets) {
console.log("createElastiCache subnet ID: ", subnet.subnetId);
subnetIds.push(subnet.subnetId);
}
const subnetGroup = new ElastiCache.CfnSubnetGroup(this, "ElastiCacheSubnetGroup", {
cacheSubnetGroupName: groupName,
subnetIds: subnetIds,
description: "ElastiCache Subnet Group",
});
const securityGroup = new SecurityGroup(this, "ElastiCacheSecurityGroup", {
vpc: this.vpc,
allowAllOutbound: true,
description: "ElastiCache Security Group",
securityGroupName: "ElastiCacheSecurityGroup",
});
securityGroup.addIngressRule(Peer.anyIpv4(), Port.tcp(6379), "Redis port");
const cache = new ElastiCache.CfnReplicationGroup(this, "ReplicationGroup", {
replicationGroupDescription: "Elastic Cache Replication Group",
numCacheClusters: 1,
automaticFailoverEnabled: false,
engine: 'redis',
cacheNodeType: 'cache.m7g.large',
cacheSubnetGroupName: subnetGroup.ref,
securityGroupIds: [securityGroup.securityGroupId],
});
// Establish dependency between cache and subnetGroup
cache.addDependency(subnetGroup);
}
}- Synthesize and deploy the stack:
cdk synth; cdk deploy --require-approval neverDeploying ElastiCache for Redis Serverless Resources
- Create Security Group:
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as EC2 from 'aws-cdk-lib/aws-ec2';
import { aws_elasticache as ElastiCache } from 'aws-cdk-lib';
import { SecurityGroup, Peer, Port } from 'aws-cdk-lib/aws-ec2';
export class WorkStack extends cdk.Stack {
private vpc: EC2.Vpc;
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
const groupName = "ElastiCacheSubnetGroup";
super(scope, id, props);
this.vpc = new EC2.Vpc(this, 'cache_vpc');
const subnetIds = [];
for (const subnet of this.vpc.privateSubnets) {
console.log("createElastiCache subnet ID: ", subnet.subnetId);
subnetIds.push(subnet.subnetId);
}
const subnetGroup = new ElastiCache.CfnSubnetGroup(this, "ElastiCacheSubnetGroup", {
cacheSubnetGroupName: groupName,
subnetIds: subnetIds,
description: "ElastiCache Subnet Group",
});
const securityGroup = new SecurityGroup(this, "ElastiCacheSecurityGroup", {
vpc: this.vpc,
allowAllOutbound: true,
description: "ElastiCache Security Group",
securityGroupName: "ElastiCacheSecurityGroup",
});
Disclaimer:info@kdj.com
The information provided is not trading advice. kdj.com does not assume any responsibility for any investments made based on the information provided in this article. Cryptocurrencies are highly volatile and it is highly recommended that you invest with caution after thorough research!
If you believe that the content used on this website infringes your copyright, please contact us immediately (info@kdj.com) and we will delete it promptly.
-
- North Korea Malware & Asia Express: CoinEx's Exit Amidst a Shifting Digital Landscape
- Sep 18, 2026 at 08:05 am
- Amidst rising North Korean cyber threats and a dynamic Asian crypto scene, CoinEx, a Hong Kong-founded exchange, shutters after nine years, signaling a pivotal moment for regional digital asset markets and regulatory landscapes.
-
- Vitalik Buterin Challenges AI Cybersecurity Doom Narrative, Advocates for Formal Verification
- Sep 18, 2026 at 12:05 am
- Vitalik Buterin, Ethereum co-founder, refutes the 'AI doom narrative' in cybersecurity, asserting AI's potential to bolster defenses through formal verification, a stance underpinned by Ethereum's ongoing security research.
-
-
- Solana and XRP Navigate Shifting Tides in Crypto Market, With a Nod to Broader Tokenization Trends
- Sep 17, 2026 at 08:05 pm
- Solana and XRP face key support levels amid market downturns. Meanwhile, Solana gears up for its London conference, highlighting tokenization, while XRP finds new utility via Flare's FAssets. A look at the evolving crypto landscape.
-
- HBO Max Reddit Account Hijacked for Crypto-Stealing Malware Attack: A New Wave of Sophisticated Scams
- Sep 17, 2026 at 12:05 pm
- A sophisticated malware campaign, dubbed PasteSwitch, leveraged the verified HBO Max Reddit account to distribute crypto-stealing malware, highlighting evolving threats to user accounts and digital assets.
-
- House Committee Advances Strategic Bitcoin Reserve Bill, Shaping Future of Federal Crypto Holdings
- Sep 17, 2026 at 12:05 pm
- The House Financial Services Committee approved the American Reserve Modernization Act, moving the Strategic Bitcoin Reserve bill forward to establish federal Bitcoin and digital asset stockpiles.
-
- Crypto Tax Bill: Digital Assets Face New Tax Rules, But Clarity Remains Elusive
- Sep 17, 2026 at 08:05 am
- The House advanced a crypto tax bill aiming to align digital asset tax rules with traditional finance, offering some relief but leaving key questions, especially for mining and staking, unresolved.
-
-
- Bitcoin, Ether Brace for Continued Volatility as Fed's Unanimous Rate Hike Signals Hawkish Resolve
- Sep 17, 2026 at 07:55 am
- The Federal Reserve's unanimous quarter-point rate hike on September 16, 2026, sent Bitcoin and Ether swinging, as Chair Kevin Warsh doubled down on an inflation-first approach, setting the stage for ongoing crypto market recalibration.

































