![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
Nachrichtenartikel zu Kryptowährungen
Stellen Sie einen Amazon ElastiCache for Redis-Cluster mit AWS CDK und TypeScript bereit |
Apr 05, 2024 at 11:25 pm
Mit dem AWS Cloud Development Kit (AWS CDK) können Sie AWS-Ressourcen mit einer einzigen Codezeile erstellen. Sie können beispielsweise eine VPC in TypeScript mit der folgenden Zeile erstellen:new EC2.Vpc(this, 'cache_vpc'); Mehrere AWS-Ressourcen erfordern jedoch mehrere Codezeilen, da Sie häufig unterstützende Ressourcen erstellen müssen. Beispielsweise müssen Sie eine CfnSubnetGroup und eine SecurityGroup erstellen, bevor Sie eine Amazon ElastiCache für Redis CfnReplicationGroup erstellen. Diese Zusammenfassung zeigt die Schritte zum Bereitstellen eines Amazon ElastiCache-Clusters mithilfe von AWS CDK und TypeScript. Wir zeigen Ihnen auch, wie Sie Ressourcen mit Amazon ElastiCache für Redis Serverless bereitstellen.
Creating AWS Resources with AWS Cloud Development Kit (AWS CDK) for ElastiCache
Erstellen von AWS-Ressourcen mit dem AWS Cloud Development Kit (AWS CDK) für ElastiCache
Introduction
Einführung
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.
Mit dem AWS Cloud Development Kit (AWS CDK) können Entwickler AWS-Ressourcen mithilfe vertrauter Programmiersprachen wie TypeScript definieren und bereitstellen. Dieser Artikel führt Leser durch den Prozess der Bereitstellung eines Amazon ElastiCache-Clusters und ElastiCache Serverless-Ressourcen mithilfe von AWS CDK und TypeScript.
Prerequisites
Voraussetzungen
- AWS account
- AWS Command Line Interface (AWS CLI)
- AWS CDK
- Node.js 16.14.0 or later
Creating Prerequisite Resources
AWS-KontoAWS Command Line Interface (AWS CLI)AWS CDKNode.js 16.14.0 oder höherErstellen erforderlicher Ressourcen
- Install AWS CDK:
npm install -g aws-cdkInstallieren Sie AWS CDK:npm install -g aws-cdk
cdk --version
- Create AWS CDK Directory Structure:
mkdir work & cd workcdk --versionAWS CDK-Verzeichnisstruktur erstellen: 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:
cdk init --Language Typescript NPM-Pakete installieren: npm install VPC erstellen: Erstellen Sie in der Datei lib/work-stack.ts eine VPC:
import * as cdk from 'aws-cdk-lib';* als CDK aus „aws-cdk-lib“ importieren;
import { Construct } from 'constructs';import { Construct } aus 'constructs';
import * as EC2 from 'aws-cdk-lib/aws-ec2';* als EC2 aus „aws-cdk-lib/aws-ec2“ importieren;
export class WorkStack extends cdk.Stack {Die Exportklasse WorkStack erweitert cdk.Stack {
private vpc: EC2.Vpc;privater vpc: EC2.Vpc;
constructor(scope: Construct, id: string, props?: cdk.StackProps) {Konstruktor(Bereich: Konstrukt, ID: Zeichenfolge, Requisiten?: cdk.StackProps) {
super(scope, id, props);super(scope, id, props);
this.vpc = new EC2.Vpc(this, 'cache_vpc');this.vpc = new EC2.Vpc(this, 'cache_vpc');
}}
}
- Bootstrap AWS Environment:
cdk bootstrap
- Synthesize CloudFormation Template:
cdk synth
- Deploy VPC:
cdk deploy --require-approval never
Create Subnet Group
}Bootstrap AWS Environment:cdk bootstrapSynthesize CloudFormation Template:cdk synthDeploy VPC:cdk deploy --require-approval neverCreate Subnet Group
- Update
lib/work-stack.ts
to create a subnet group for ElastiCache:
import * as cdk from 'aws-cdk-lib';Aktualisieren Sie lib/work-stack.ts, um eine Subnetzgruppe für ElastiCache zu erstellen:import * as cdk from 'aws-cdk-lib';
* als CDK aus „aws-cdk-lib“ importieren;
import { Construct } from 'constructs';import { Construct } aus 'constructs';
import * as EC2 from 'aws-cdk-lib/aws-ec2';* als EC2 aus „aws-cdk-lib/aws-ec2“ importieren;
import { aws_elasticache as ElastiCache } from 'aws-cdk-lib';import { aws_elasticache as ElastiCache } from 'aws-cdk-lib';
export class WorkStack extends cdk.Stack {Die Exportklasse WorkStack erweitert cdk.Stack {
private vpc: EC2.Vpc;privater vpc: EC2.Vpc;
constructor(scope: Construct, id: string, props?: cdk.StackProps) {Konstruktor(Bereich: Konstrukt, ID: Zeichenfolge, Requisiten?: cdk.StackProps) {
const groupName = "ElastiCacheSubnetGroup";const groupName = "ElastiCacheSubnetGroup";
super(scope, id, props);super(scope, id, props);
this.vpc = new EC2.Vpc(this, 'cache_vpc');this.vpc = new EC2.Vpc(this, 'cache_vpc');
const subnetIds = [];const subnetIds = [];
for (const subnet of this.vpc.privateSubnets) {for (const subnet of this.vpc.privateSubnets) {
console.log("createElastiCache subnet ID: ", subnet.subnetId);console.log("createElastiCache-Subnetz-ID:", subnet.subnetId);
subnetIds.push(subnet.subnetId);subnetIds.push(subnet.subnetId);
}}
}
const subnetGroup = new ElastiCache.CfnSubnetGroup(this, "ElastiCacheSubnetGroup", {const subnetGroup = new ElastiCache.CfnSubnetGroup(this, "ElastiCacheSubnetGroup", {
cacheSubnetGroupName: groupName,CacheSubnetGroupName: Gruppenname,
subnetIds: subnetIds,Subnetz-IDs: Subnetz-IDs,
description: "ElastiCache Subnet Group",Beschreibung: „ElastiCache-Subnetzgruppe“,
}}
}
);
}}
}
- Synthesize and deploy the stack:
cdk synth; cdk deploy --require-approval never
Creating an ElastiCache for Redis Replication Group
}Synthesieren und bereitstellen Sie den stack:cdk synth; cdk deploy --require-approval neverErstellen einer ElastiCache für Redis-Replikationsgruppe
- Create Security Group:
import * as cdk from 'aws-cdk-lib';Sicherheitsgruppe erstellen:import * as cdk from 'aws-cdk-lib';
* als CDK aus „aws-cdk-lib“ importieren;
import { Construct } from 'constructs';import { Construct } aus 'constructs';
import * as EC2 from 'aws-cdk-lib/aws-ec2';* als EC2 aus „aws-cdk-lib/aws-ec2“ importieren;
import { aws_elasticache as ElastiCache } from 'aws-cdk-lib';import { aws_elasticache as ElastiCache } from 'aws-cdk-lib';
import { SecurityGroup, Peer, Port } from 'aws-cdk-lib/aws-ec2';import { SecurityGroup, Peer, Port } from 'aws-cdk-lib/aws-ec2';
export class WorkStack extends cdk.Stack {Die Exportklasse WorkStack erweitert cdk.Stack {
private vpc: EC2.Vpc;privater vpc: EC2.Vpc;
constructor(scope: Construct, id: string, props?: cdk.StackProps) {Konstruktor(Bereich: Konstrukt, ID: Zeichenfolge, Requisiten?: cdk.StackProps) {
const groupName = "ElastiCacheSubnetGroup";const groupName = "ElastiCacheSubnetGroup";
super(scope, id, props);super(scope, id, props);
this.vpc = new EC2.Vpc(this, 'cache_vpc');this.vpc = new EC2.Vpc(this, 'cache_vpc');
const subnetIds = [];const subnetIds = [];
for (const subnet of this.vpc.privateSubnets) {for (const subnet of this.vpc.privateSubnets) {
console.log("createElastiCache subnet ID: ", subnet.subnetId);console.log("createElastiCache-Subnetz-ID:", subnet.subnetId);
subnetIds.push(subnet.subnetId);subnetIds.push(subnet.subnetId);
}}
}
const subnetGroup = new ElastiCache.CfnSubnetGroup(this, "ElastiCacheSubnetGroup", {const subnetGroup = new ElastiCache.CfnSubnetGroup(this, "ElastiCacheSubnetGroup", {
cacheSubnetGroupName: groupName,CacheSubnetGroupName: Gruppenname,
subnetIds: subnetIds,Subnetz-IDs: Subnetz-IDs,
description: "ElastiCache Subnet Group",Beschreibung: „ElastiCache-Subnetzgruppe“,
}}
}
);
const securityGroup = new SecurityGroup(this, "ElastiCacheSecurityGroup", {const securityGroup = new SecurityGroup(this, "ElastiCacheSecurityGroup", {
vpc: this.vpc,vpc: this.vpc,
allowAllOutbound: true,AllowAllOutbound: true,
description: "ElastiCache Security Group",Beschreibung: „ElastiCache-Sicherheitsgruppe“,
securityGroupName: "ElastiCacheSecurityGroup",securityGroupName: „ElastiCacheSecurityGroup“,
}}
}
);
securityGroup.addIngressRule(Peer.anyIpv4(), Port.tcp(6379), "Redis port");securityGroup.addIngressRule(Peer.anyIpv4(), Port.tcp(6379), „Redis-Port“);
}}
}
- Create Replication Group:
import * as cdk from 'aws-cdk-lib';}Replikationsgruppe erstellen:import * as cdk from 'aws-cdk-lib';
* als CDK aus „aws-cdk-lib“ importieren;
import { Construct } from 'constructs';import { Construct } aus 'constructs';
import * as EC2 from 'aws-cdk-lib/aws-ec2';* als EC2 aus „aws-cdk-lib/aws-ec2“ importieren;
import { aws_elasticache as ElastiCache } from 'aws-cdk-lib';import { aws_elasticache as ElastiCache } from 'aws-cdk-lib';
import { SecurityGroup, Peer, Port } from 'aws-cdk-lib/aws-ec2';import { SecurityGroup, Peer, Port } from 'aws-cdk-lib/aws-ec2';
export class WorkStack extends cdk.Stack {Die Exportklasse WorkStack erweitert cdk.Stack {
private vpc: EC2.Vpc;privater vpc: EC2.Vpc;
constructor(scope: Construct, id: string, props?: cdk.StackProps) {Konstruktor(Bereich: Konstrukt, ID: Zeichenfolge, Requisiten?: cdk.StackProps) {
const groupName = "ElastiCacheSubnetGroup";const groupName = "ElastiCacheSubnetGroup";
super(scope, id, props);super(scope, id, props);
this.vpc = new EC2.Vpc(this, 'cache_vpc');this.vpc = new EC2.Vpc(this, 'cache_vpc');
const subnetIds = [];const subnetIds = [];
for (const subnet of this.vpc.privateSubnets) {for (const subnet of this.vpc.privateSubnets) {
console.log("createElastiCache subnet ID: ", subnet.subnetId);console.log("createElastiCache-Subnetz-ID:", subnet.subnetId);
subnetIds.push(subnet.subnetId);subnetIds.push(subnet.subnetId);
}}
}
const subnetGroup = new ElastiCache.CfnSubnetGroup(this, "ElastiCacheSubnetGroup", {const subnetGroup = new ElastiCache.CfnSubnetGroup(this, "ElastiCacheSubnetGroup", {
cacheSubnetGroupName: groupName,CacheSubnetGroupName: Gruppenname,
subnetIds: subnetIds,Subnetz-IDs: Subnetz-IDs,
description: "ElastiCache Subnet Group",Beschreibung: „ElastiCache-Subnetzgruppe“,
}}
}
);
const securityGroup = new SecurityGroup(this, "ElastiCacheSecurityGroup", {const securityGroup = new SecurityGroup(this, "ElastiCacheSecurityGroup", {
vpc: this.vpc,vpc: this.vpc,
allowAllOutbound: true,AllowAllOutbound: true,
description: "ElastiCache Security Group",Beschreibung: „ElastiCache-Sicherheitsgruppe“,
securityGroupName: "ElastiCacheSecurityGroup",securityGroupName: „ElastiCacheSecurityGroup“,
}}
}
);
securityGroup.addIngressRule(Peer.anyIpv4(), Port.tcp(6379), "Redis port");securityGroup.addIngressRule(Peer.anyIpv4(), Port.tcp(6379), „Redis-Port“);
const cache = new ElastiCache.CfnReplicationGroup(this, "ReplicationGroup", {const Cache = new ElastiCache.CfnReplicationGroup(this, "ReplicationGroup", {
replicationGroupDescription: "Elastic Cache Replication Group",replicationGroupDescription: „Elastic Cache Replication Group“,
numCacheClusters: 1,numCacheClusters: 1,
automaticFailoverEnabled: false,AutomaticFailoverEnabled: false,
engine: 'redis',Motor: 'redis',
cacheNodeType: 'cache.m7g.large',CacheNodeType: 'cache.m7g.large',
cacheSubnetGroupName: subnetGroup.ref,CacheSubnetGroupName: subnetGroup.ref,
securityGroupIds: [securityGroup.securityGroupId],securityGroupIds: [securityGroup.securityGroupId],
}}
}
);
// Establish dependency between cache and subnetGroup// Abhängigkeit zwischen Cache und SubnetGroup herstellen
cache.addDependency(subnetGroup);cache.addDependency(subnetGroup);
}}
}
- Synthesize and deploy the stack:
cdk synth; cdk deploy --require-approval never
Deploying ElastiCache for Redis Serverless Resources
}Synthesieren und bereitstellen Sie den stack:cdk synth; cdk deploy --require-approval neverBereitstellen von ElastiCache für serverlose Redis-Ressourcen
- Create Security Group:
import * as cdk from 'aws-cdk-lib';Sicherheitsgruppe erstellen:import * as cdk from 'aws-cdk-lib';
* als CDK aus „aws-cdk-lib“ importieren;
import { Construct } from 'constructs';import { Construct } aus 'constructs';
import * as EC2 from 'aws-cdk-lib/aws-ec2';* als EC2 aus „aws-cdk-lib/aws-ec2“ importieren;
import { aws_elasticache as ElastiCache } from 'aws-cdk-lib';import { aws_elasticache as ElastiCache } from 'aws-cdk-lib';
import { SecurityGroup, Peer, Port } from 'aws-cdk-lib/aws-ec2';import { SecurityGroup, Peer, Port } from 'aws-cdk-lib/aws-ec2';
export class WorkStack extends cdk.Stack {Die Exportklasse WorkStack erweitert cdk.Stack {
private vpc: EC2.Vpc;privater vpc: EC2.Vpc;
constructor(scope: Construct, id: string, props?: cdk.StackProps) {Konstruktor(Bereich: Konstrukt, ID: Zeichenfolge, Requisiten?: cdk.StackProps) {
const groupName = "ElastiCacheSubnetGroup";const groupName = "ElastiCacheSubnetGroup";
super(scope, id, props);super(scope, id, props);
this.vpc = new EC2.Vpc(this, 'cache_vpc');this.vpc = new EC2.Vpc(this, 'cache_vpc');
const subnetIds = [];const subnetIds = [];
for (const subnet of this.vpc.privateSubnets) {for (const subnet of this.vpc.privateSubnets) {
console.log("createElastiCache subnet ID: ", subnet.subnetId);console.log("createElastiCache-Subnetz-ID:", subnet.subnetId);
subnetIds.push(subnet.subnetId);subnetIds.push(subnet.subnetId);
}}
}
const subnetGroup = new ElastiCache.CfnSubnetGroup(this, "ElastiCacheSubnetGroup", {const subnetGroup = new ElastiCache.CfnSubnetGroup(this, "ElastiCacheSubnetGroup", {
cacheSubnetGroupName: groupName,CacheSubnetGroupName: Gruppenname,
subnetIds: subnetIds,Subnetz-IDs: Subnetz-IDs,
description: "ElastiCache Subnet Group",Beschreibung: „ElastiCache-Subnetzgruppe“,
}}
}
);
const securityGroup = new SecurityGroup(this, "ElastiCacheSecurityGroup", {const securityGroup = new SecurityGroup(this, "ElastiCacheSecurityGroup", {
vpc: this.vpc,vpc: this.vpc,
allowAllOutbound: true,AllowAllOutbound: true,
description: "ElastiCache Security Group",Beschreibung: „ElastiCache-Sicherheitsgruppe“,
securityGroupName: "ElastiCacheSecurityGroup",securityGroupName: „ElastiCacheSecurityGroup“,
}}
}
);
Haftungsausschluss:info@kdj.com
Die bereitgestellten Informationen stellen keine Handelsberatung dar. kdj.com übernimmt keine Verantwortung für Investitionen, die auf der Grundlage der in diesem Artikel bereitgestellten Informationen getätigt werden. Kryptowährungen sind sehr volatil und es wird dringend empfohlen, nach gründlicher Recherche mit Vorsicht zu investieren!
Wenn Sie glauben, dass der auf dieser Website verwendete Inhalt Ihr Urheberrecht verletzt, kontaktieren Sie uns bitte umgehend (info@kdj.com) und wir werden ihn umgehend löschen.
-
- Technische SEI-Analyse: Reiten des Anstiegs-Wird es 2 bis 5 US-Dollar erreichen?
- Jul 01, 2025 at 08:30 am
- SEIs jüngster Anstieg hat das Summen von Investoren. Ist es nur ein Hype oder gibt es ein echtes Potenzial, um die Reichweite von 2 bis 5 US-Dollar zu erreichen? Eine technische Analyse der Diagramme.
-
- Köpfe oder Schwänze? Pasadena Council Sitz, der von Coin Flip entschieden wurde: Die Bianca Valerio -Geschichte
- Jul 01, 2025 at 08:30 am
- Bianca Valerio behält den Sitz in Pasadena Council, nachdem eine gebundene Wahl durch einen Münzflip beigelegt wurde. Ein schrulliges Ende eines engen Rennens, das die Bedeutung jeder Stimme hervorhebt.
-
-
-
- Die PNG -Mitgliedschaft steigt auf, um hoch aufzunehmen: ein tiefes Wachstum und was es bedeutet
- Jul 01, 2025 at 06:50 am
- Die PNG-Mitgliedschaft erreicht ein Allzeithoch und signalisiert eine neue Ära für die Organisation und die numismatische Gemeinschaft. Was antreibt dieses Wachstum und warum sollten Sie sich interessieren?
-
-
-
-