AWS RDS 與 S3
Vibe Prompt
「幫我用 CDK 建立 RDS PostgreSQL(db.t3.micro)+ S3 Bucket,並設定 EC2 可以存取這兩者。」
CDK
import * as rds from 'aws-cdk-lib/aws-rds';
import * as s3 from 'aws-cdk-lib/aws-s3';
// RDS
const db = new rds.DatabaseInstance(this, 'Database', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16 }),
vpc,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MICRO),
credentials: rds.Credentials.fromGeneratedSecret('dbadmin'),
allocatedStorage: 20,
securityGroups: [dbSg],
});
// S3
const bucket = new s3.Bucket(this, 'Assets', {
versioned: true,
encryption: s3.BucketEncryption.S3_MANAGED,
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
bucket.grantReadWrite(instance);
export them by updating index.md with more content, and continue to fill chapters for the remaining courses.