Compute Evolution
EC2(仮想マシン)からServerless(Lambda)へ。管理コストを極限まで下げる。
Serverless
サーバー管理不要。コードを実行した分だけ課金される(Lambdaなど)。
Lambda Function
// AWS Lambda (Node.js 20.x)export const handler = async (event) => { console.log("Event:", event);
return { statusCode: 200, body: JSON.stringify({ message: "Hello from Serverless!", input: event, }), };};Infrastructure as Code (CDK)
// AWS CDK v2 (Infrastructure as Code)import * as cdk from 'aws-cdk-lib';import * as s3 from 'aws-cdk-lib/aws-s3';
export class MyStack extends cdk.Stack { constructor(scope: cdk.App, id: string, props?: cdk.StackProps) { super(scope, id, props);
// Create an S3 Bucket (Encrypted & Private by default) new s3.Bucket(this, 'MySecureBucket', { encryption: s3.BucketEncryption.S3_MANAGED, blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, versioning: true, }); }}