Skip to content

Commit e1fd233

Browse files
chore: add test for BucketDeployment
1 parent 8803647 commit e1fd233

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/cdk-basic/lib/cdk-basic-stack.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Construct } from 'constructs';
33
import * as lambda_nodejs from 'aws-cdk-lib/aws-lambda-nodejs';
44
import * as lambda from 'aws-cdk-lib/aws-lambda';
55
import * 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';
68
import * as path from 'path';
79

810
export 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

Comments
 (0)