Skip to content

Commit 6980ab8

Browse files
trivikrkaiz-ioMichael Kaiser
authored
chore(csharp): update nodejs version to 20.x (#1039)
* chore(csharp): update nodejs version to 20.x * Fix: Output the cdk version * Fix: Updated csharp libraries * Fix: Updated csharp libraries * Fix: Updated csharp libraries * Fix: Updated csharp libraries --------- Co-authored-by: Michael Kaiser <[email protected]> Co-authored-by: Michael Kaiser <[email protected]>
1 parent f1f697e commit 6980ab8

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

.github/workflows/build-pull-request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ jobs:
105105
# ts will use the one from the particular cdk app
106106
if [[ ${{ matrix.language }} != 'typescript' ]]; then
107107
npm install -g aws-cdk
108+
npx cdk --version
108109
fi
109110
110111
# Run the build_file function in parallel for each project to be built

csharp/my-widget-service/src/MyWidgetService/MyWidgetService.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Amazon.CDK.Lib" Version="2.0.0" />
12-
<PackageReference Include="Constructs" Version="10.0.0" />
11+
<PackageReference Include="Amazon.CDK.Lib" Version="2.143.0" />
12+
<PackageReference Include="Constructs" Version="10.0" />
1313
</ItemGroup>
1414

1515
</Project>

csharp/my-widget-service/src/MyWidgetService/MyWidgetServiceStack.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public MyWidgetServiceStack(Construct parent, string id, IStackProps props) : ba
1414
var bucket = new Bucket(this, "WidgetStore");
1515

1616
var handler = new Function(this, "WidgetHandler", new FunctionProps {
17-
Runtime = Runtime.NODEJS_10_X,
17+
Runtime = Runtime.NODEJS_20_X,
1818
Code = Code.FromAsset("src/MyWidgetService/resources"),
1919
Handler = "widgets.main",
2020
Environment = new Dictionary<string, string>{

csharp/my-widget-service/src/MyWidgetService/resources/widgets.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const AWS = require('aws-sdk');
2-
const S3 = new AWS.S3();
1+
const { S3 } = require("@aws-sdk/client-s3");
2+
const s3 = new S3();
33

44
const bucketName = process.env.BUCKET;
55

@@ -12,7 +12,7 @@ exports.main = async function(event, context) {
1212
if (method === "GET") {
1313
// GET / to get the names of all widgets
1414
if (event.path === "/") {
15-
const data = await S3.listObjectsV2({ Bucket: bucketName }).promise();
15+
const data = await s3.listObjectsV2({ Bucket: bucketName });
1616
var body = {
1717
widgets: data.Contents.map(function(e) { return e.Key })
1818
};
@@ -25,8 +25,8 @@ exports.main = async function(event, context) {
2525

2626
if (widgetName) {
2727
// GET /name to get info on widget name
28-
const data = await S3.getObject({ Bucket: bucketName, Key: widgetName}).promise();
29-
var body = data.Body.toString('utf-8');
28+
const data = await s3.getObject({ Bucket: bucketName, Key: widgetName});
29+
var body = await data.Body.transformToString();
3030

3131
return {
3232
statusCode: 200,
@@ -53,12 +53,12 @@ exports.main = async function(event, context) {
5353

5454
var base64data = new Buffer(data, 'binary');
5555

56-
await S3.putObject({
56+
await s3.putObject({
5757
Bucket: bucketName,
5858
Key: widgetName,
5959
Body: base64data,
6060
ContentType: 'application/json'
61-
}).promise();
61+
});
6262

6363
return {
6464
statusCode: 200,
@@ -78,9 +78,9 @@ exports.main = async function(event, context) {
7878
};
7979
}
8080

81-
await S3.deleteObject({
81+
await s3.deleteObject({
8282
Bucket: bucketName, Key: widgetName
83-
}).promise();
83+
});
8484

8585
return {
8686
statusCode: 200,

csharp/random-writer/src/RandomWriter/RandomWriter.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Amazon.CDK.Lib" Version="2.0.0" />
11+
<PackageReference Include="Amazon.CDK.Lib" Version="2.143.0" />
1212
<PackageReference Include="Constructs" Version="10.0.0" />
1313
</ItemGroup>
1414

csharp/random-writer/src/RandomWriter/RandomWriterStack.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public RandomWriter(Construct scope, string id): base(scope, id)
4040

4141
Function = new Function(this, "Lambda", new FunctionProps
4242
{
43-
Runtime = Runtime.NODEJS_10_X,
43+
Runtime = Runtime.NODEJS_20_X,
4444
Handler = "index.handler",
4545
Code = Code.FromAsset("src/RandomWriter/resources"),
4646
Environment = new Dictionary<string, string>

csharp/random-writer/src/RandomWriter/resources/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { DynamoDB } = require('aws-sdk');
1+
const { DynamoDB } = require('@aws-sdk/client-dynamodb');
22
const crypto = require('crypto');
33

44
/**
@@ -22,5 +22,5 @@ exports.handler = async function handler(event, context) {
2222
Item: {
2323
ID: { S: id }
2424
}
25-
}).promise();
25+
});
2626
};

0 commit comments

Comments
 (0)