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

Skip handling of container image lambda functions #119

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

duncanpharvey
Copy link
Contributor

@duncanpharvey duncanpharvey commented Jan 26, 2024

What does this PR do?

Skip handling of container image Lambda functions. Lambda functions packaged into container images are instrumented with Datadog differently than Lambda functions packaged into a zip. The CloudFormation Macro should not make any changes to these container image Lambda functions.

Motivation

#108

Testing Guidelines

Created a SAM template with a zip Lambda function and container image Lambda function. Verified that (1) the zip Lambda function is instrumented with the CloudFormation Macro and sends metrics, logs, and traces to Datadog and (2) the container image Lambda function is unaffected by the CloudFormation Macro and sends metrics, logs, and traces to Datadog.

template.yaml

AWSTemplateFormatVersion: "2010-09-09"
Transform:
  - AWS::Serverless-2016-10-31
  - Name: DatadogServerlessTest
    Parameters:
      stackName: !Ref "AWS::StackName"
      apiKey: <redacted>
      pythonLayerVersion: "87"
      extensionLayerVersion: "52"

Globals:
  Function:
    Timeout: 10
    MemorySize: 256
    Architectures:
      - x86_64

Resources:
  HelloWorldFunctionContainer:
    Type: AWS::Serverless::Function
    Properties:
      PackageType: Image
      Environment:
        Variables:
          DD_LAMBDA_HANDLER: app.lambda_handler
          DD_API_KEY: <redacted>
          DD_SITE: datadoghq.com
          DD_TRACE_ENABLED: true
    Metadata:
      Dockerfile: Dockerfile
      DockerContext: ./hello_world
      DockerTag: python3.9-v1
  HelloWorldFunctionZip:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: hello_world/
      Handler: app.lambda_handler
      Runtime: python3.9

Dockerfile

FROM public.ecr.aws/lambda/python:3.9

COPY requirements.txt ./
RUN python3.9 -m pip install -r requirements.txt -t .

COPY app.py ./

COPY --from=public.ecr.aws/datadog/lambda-extension:latest /opt/extensions/ /opt/extensions

CMD ["datadog_lambda.handler.handler"]

Additional Notes

Types of changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog

@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (443c298) 84.62% compared to head (fb7f505) 84.70%.

❗ Current head fb7f505 differs from pull request most recent head cf9e13a. Consider uploading reports for the commit cf9e13a to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #119      +/-   ##
==========================================
+ Coverage   84.62%   84.70%   +0.07%     
==========================================
  Files           8        8              
  Lines         631      634       +3     
  Branches      158      159       +1     
==========================================
+ Hits          534      537       +3     
  Misses         85       85              
  Partials       12       12              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@duncanpharvey duncanpharvey force-pushed the duncan-harvey/handle-container-image-lambdas branch from 76f54ce to cf9e13a Compare January 26, 2024 21:13
@duncanpharvey duncanpharvey marked this pull request as ready for review January 26, 2024 21:20
@duncanpharvey duncanpharvey requested a review from a team as a code owner January 26, 2024 21:20
Copy link
Contributor

@duncanista duncanista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this! LGTM

@duncanpharvey duncanpharvey merged commit e5f4c51 into main Jan 29, 2024
13 checks passed
@duncanpharvey duncanpharvey deleted the duncan-harvey/handle-container-image-lambdas branch January 29, 2024 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Datadog macro removes DD_LAMBDA_HANDLER from container image lambdas
3 participants