@@ -3,6 +3,8 @@ import { Construct } from 'constructs';
33import * as lambda_nodejs from 'aws-cdk-lib/aws-lambda-nodejs' ;
44import * as lambda from 'aws-cdk-lib/aws-lambda' ;
55import * as log from 'aws-cdk-lib/aws-logs' ;
6+ import * as s3 from 'aws-cdk-lib/aws-s3' ;
7+ import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment' ;
68import * as path from 'path' ;
79
810export class CdkbasicStack extends cdk . Stack {
@@ -64,6 +66,32 @@ export class CdkbasicStack extends cdk.Stack {
6466 logRetention : log . RetentionDays . ONE_DAY ,
6567 } ) ;
6668
69+ // S3 Bucket for deployment example
70+ const websiteBucket = new s3 . Bucket ( this , 'WebsiteBucket' , {
71+ removalPolicy : cdk . RemovalPolicy . DESTROY ,
72+ autoDeleteObjects : true ,
73+ } ) ;
74+
75+ new s3deploy . BucketDeployment ( this , 'DeployWebsite' , {
76+ sources : [
77+ s3deploy . Source . data (
78+ 'index.html' ,
79+ `<!DOCTYPE html>
80+ <html>
81+ <head>
82+ <title>CDK Bucket Deployment Test</title>
83+ </head>
84+ <body>
85+ <h1>Hello from S3 Bucket Deployment!</h1>
86+ <p>This file was deployed using CDK BucketDeployment construct.</p>
87+ <p>Deployed at: ${ new Date ( ) . toISOString ( ) } </p>
88+ </body>
89+ </html>` ,
90+ ) ,
91+ ] ,
92+ destinationBucket : websiteBucket ,
93+ } ) ;
94+
6795 new cdk . CfnOutput ( this , 'FunctionNameTestTsCommonJs' , {
6896 value : functionTestTsCommonJs . functionName ,
6997 } ) ;
0 commit comments