Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade sdk js to V3 and lambda to runtime 20.x #5583

Merged
merged 22 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
phases:
install:
runtime-versions:
nodejs: 16
nodejs: 20
commands:
- "cd $HOME/.goenv && git pull --ff-only && cd -"
- "goenv install 1.21.1" # Check if a version is available: https://github.com/syndbg/goenv/tree/master/plugins/go-build/share/go-build
Expand Down
38 changes: 19 additions & 19 deletions .release/buildspec_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: addons
APP_REGION: us-west-2
Expand All @@ -28,7 +28,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: customized-env
APP_REGION: us-west-1
Expand All @@ -44,7 +44,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: init
APP_REGION: us-east-1
Expand All @@ -54,7 +54,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: multi-env-app
APP_REGION: us-east-2
Expand All @@ -68,7 +68,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: multi-svc-app
APP_REGION: us-west-2
Expand All @@ -80,7 +80,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: root
APP_REGION: us-west-1
Expand All @@ -89,7 +89,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: sidecars
APP_REGION: us-east-1
Expand All @@ -101,7 +101,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: task
APP_REGION: us-east-2
Expand All @@ -113,7 +113,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: app-with-domain
APP_REGION: us-west-2
Expand All @@ -127,7 +127,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: import-certs
APP_REGION: us-west-2
Expand All @@ -139,7 +139,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: isolated
APP_REGION: us-west-2
Expand All @@ -151,7 +151,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: exec
APP_REGION: ap-northeast-1
Expand All @@ -163,7 +163,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: apprunner
APP_REGION: ap-northeast-1
Expand All @@ -173,7 +173,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: pipeline
APP_REGION: eu-west-1
Expand All @@ -187,7 +187,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: multi-pipeline
APP_REGION: ap-northeast-1
Expand All @@ -201,7 +201,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: worker
APP_REGION: eu-central-1
Expand All @@ -213,7 +213,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: cloudfront
APP_REGION: eu-central-1
Expand All @@ -225,7 +225,7 @@ batch:
privileged-mode: true
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:6.0
image: aws/codebuild/standard:7.0
variables:
TEST_SUITE: static-site
APP_REGION: eu-central-1
Expand All @@ -236,7 +236,7 @@ batch:
phases:
install:
runtime-versions:
nodejs: 16
nodejs: 20
commands:
- "cd $HOME/.goenv && git pull --ff-only && cd -"
- "goenv install 1.21.1"
Expand Down
2 changes: 1 addition & 1 deletion .release/buildspec_integ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
phases:
install:
runtime-versions:
nodejs: 16
nodejs: 20
commands:
- "cd $HOME/.goenv && git pull --ff-only && cd -"
- "goenv install 1.21.1"
Expand Down
2 changes: 1 addition & 1 deletion .release/buildspec_regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ batch:
phases:
install:
runtime-versions:
nodejs: 16
nodejs: 20
commands:
- "cd $HOME/.goenv && git pull --ff-only && cd -"
- "goenv install 1.21.1"
Expand Down
9 changes: 4 additions & 5 deletions cf-custom-resources/lib/alb-rule-priority-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
"use strict";

const aws = require("aws-sdk");
const { ElasticLoadBalancingV2, DescribeRulesCommand} = require("@aws-sdk/client-elastic-load-balancing-v2");

// minPriorityForRootRule is the min priority number for the root path "/".
const minPriorityForRootRule = 48000;
Expand Down Expand Up @@ -135,17 +135,16 @@ const calculateNextRootRulePriority = async function (listenerArn) {
};

const getListenerRules = async function (listenerArn) {
let elb = new aws.ELBv2();
let elb = new ElasticLoadBalancingV2();
// Grab all the rules for this listener
let marker;
let rules = [];
do {
const rulesResponse = await elb
.describeRules({
.send(new DescribeRulesCommand({
ListenerArn: listenerArn,
Marker: marker,
})
.promise();
}));

rules = rules.concat(rulesResponse.Rules);
marker = rulesResponse.NextMarker;
Expand Down
20 changes: 10 additions & 10 deletions cf-custom-resources/lib/backlog-per-task-calculator.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
"use strict";

const aws = require("aws-sdk");
const { ECS,DescribeServicesCommand } = require("@aws-sdk/client-ecs");
const { SQS,GetQueueUrlCommand, GetQueueAttributesCommand} = require("@aws-sdk/client-sqs");

// AWS Clients that are overriden in tests.
let ecs, sqs;
Expand Down Expand Up @@ -79,9 +79,9 @@ const emitBacklogPerTaskMetric = (namespace, timestamp, queueName, backlogPerTas
* @returns string The URL of the queue.
*/
const getQueueURL = async (queueName) => {
const out = await sqs.getQueueUrl({
const out = await sqs.send(new GetQueueUrlCommand({
QueueName: queueName,
}).promise();
}));
return out.QueueUrl;
}

Expand All @@ -91,10 +91,10 @@ const getQueueURL = async (queueName) => {
* @return int The ApproximateNumberOfMessages in the queue.
*/
const getQueueDepth = async (queueUrl) => {
const out = await sqs.getQueueAttributes({
const out = await sqs.send(new GetQueueAttributesCommand({
QueueUrl: queueUrl,
AttributeNames: ['ApproximateNumberOfMessages'],
}).promise();
}));
return out.Attributes.ApproximateNumberOfMessages;
}

Expand All @@ -105,10 +105,10 @@ const getQueueDepth = async (queueUrl) => {
* @returns int The number of tasks running part of the service.
*/
const getRunningTaskCount = async (clusterId, serviceName) => {
const out = await ecs.describeServices({
const out = await ecs.send(new DescribeServicesCommand({
cluster: clusterId,
services: [serviceName],
}).promise();
}));
if (out.services.length === 0) {
throw new Error(`service ${serviceName} of cluster ${clusterId} does not exist`);
}
Expand All @@ -119,8 +119,8 @@ const getRunningTaskCount = async (clusterId, serviceName) => {
* Create new clients.
*/
const setupClients = () => {
ecs = new aws.ECS();
sqs = new aws.SQS();
ecs = new ECS();
sqs = new SQS();
}

// convertQueueNames takes a comma separated string of SQS queue names and returns it as an array of strings.
Expand Down
12 changes: 6 additions & 6 deletions cf-custom-resources/lib/bucket-cleaner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
"use strict";

const aws = require("aws-sdk");
const { S3,HeadBucketCommand, ListObjectVersionsCommand, DeleteObjectsCommand } = require("@aws-sdk/client-s3");

// These are used for test purposes only
let defaultResponseURL;
Expand Down Expand Up @@ -75,10 +75,10 @@ let report = function (
* @param {string} bucketName Name of the bucket to be cleaned.
*/
const cleanBucket = async function (bucketName) {
const s3 = new aws.S3();
const s3 = new S3();
// Make sure the bucket exists.
try {
await s3.headBucket({ Bucket: bucketName }).promise();
await s3.send(new HeadBucketCommand({ Bucket: bucketName }));
} catch (err) {
if (err.name === "ResourceNotFoundException") {
return;
Expand All @@ -89,7 +89,7 @@ const cleanBucket = async function (bucketName) {
Bucket: bucketName
}
while (true) {
const listResp = await s3.listObjectVersions(listObjectVersionsParam).promise();
const listResp = await s3.send(new ListObjectVersionsCommand(listObjectVersionsParam));
// After deleting other versions, remove delete markers version.
// For info on "delete marker": https://docs.aws.amazon.com/AmazonS3/latest/dev/DeleteMarker.html
let objectsToDelete = [
Expand All @@ -99,13 +99,13 @@ const cleanBucket = async function (bucketName) {
if (objectsToDelete.length === 0) {
return
}
const delResp = await s3.deleteObjects({
const delResp = await s3.send(new DeleteObjectsCommand({
Bucket: bucketName,
Delete: {
Objects: objectsToDelete,
Quiet: true
}
}).promise()
}));
if (delResp.Errors.length > 0) {
throw new AggregateError([new Error(`${delResp.Errors.length}/${objectsToDelete.length} objects failed to delete`),
new Error(`first failed on key "${delResp.Errors[0].Key}": ${delResp.Errors[0].Message}`)]);
Expand Down