Cloud Fortgeschritten
AWS CDK — Cloud Development Kit¶
AWSCDKIaCTypeScript 5 min Lesezeit
CDK Constructs L1/L2/L3, Stacks, Aspects und Testing.
Construct Levels¶
const bucket = new s3.Bucket(this, 'Images', {
versioned: true,
encryption: s3.BucketEncryption.S3_MANAGED,
lifecycleRules: [{
transitions: [{storageClass: s3.StorageClass.GLACIER, transitionAfter: cdk.Duration.days(90)}]
}]
});
const fn = new lambda.Function(this, 'Processor', {
runtime: lambda.Runtime.NODEJS_20_X,
handler: 'index.handler',
code: lambda.Code.fromAsset('lambda'),
});
bucket.grantRead(fn); // L2 magic — auto-generates IAM policy
Aspects¶
class TagChecker implements cdk.IAspect {
visit(node) {
if (cdk.TagManager.isTaggable(node)) {
// enforce required tags
}
}
}
cdk.Aspects.of(app).add(new TagChecker());
Testing¶
const template = Template.fromStack(stack);
template.hasResourceProperties('AWS::S3::Bucket', {
VersioningConfiguration: { Status: 'Enabled' }
});
Zusammenfassung¶
CDK = die beste Wahl für reine AWS-Teams. L2/L3 Constructs reduzieren Boilerplate drastisch.
Brauchen Sie Hilfe bei der Implementierung?¶
Unser Team hat Erfahrung in der Konzeption und Umsetzung moderner Architekturen. Wir helfen Ihnen gerne.