Skip to content

Maintenance: Add E2E tests for Lambda Managed Instances #5092

@svozza

Description

@svozza

Summary

Now that CloudFormation supports provisioning Lambda Managed Instances, we should add e2e tests fot his configuration. Specifically, the logger, metrics, and batch utilities have specific code paths that are only invoked in LMI environments and we should test these.

Why is this needed?

We support this platform but we have no automated e2e tests to confirm it works.

Which area does this relate to?

No response

Solution

Update our CDK test to create LMI environments:

import * as ec2 from 'aws-cdk-lib/aws-ec2';

const vpc = new ec2.Vpc(this, 'MyVpc');
const securityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', { vpc });

const capacityProvider = new lambda.CapacityProvider(this, 'MyCapacityProvider', {
  subnets: vpc.privateSubnets,
  securityGroups: [securityGroup],
  scalingOptions: lambda.ScalingOptions.manual([
    lambda.TargetTrackingScalingPolicy.cpuUtilization(70),
  ]),
});

const fn = new lambda.Function(this, 'MyFunction', {
  // Runtime must be equal to or newer than NODEJS_LATEST
  runtime: lambda.Runtime.NODEJS_LATEST,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});

// Associate the function with the capacity provider
capacityProvider.addFunction(fn, {
  perExecutionEnvironmentMaxConcurrency: 10,
  executionEnvironmentMemoryGiBPerVCpu: 4,
});

If possible we should try to run some of the concurrency tests in this particular:

https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/logger/tests/unit/concurrency
https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/metrics/tests/unit/concurrency
https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/batch/tests/unit/concurrency

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    batchThis item relates to the Batch Processing UtilityinternalPRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.)loggerThis item relates to the Logger UtilitymetricsThis item relates to the Metrics UtilitytriageThis item has not been triaged by a maintainer, please wait

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions