From 8c310ede17daaef908de5d15f1cdfaaed89c802a Mon Sep 17 00:00:00 2001 From: Sammie downing Date: Tue, 26 Mar 2024 16:55:34 -0700 Subject: [PATCH] fix(serverless): deleting lambda containerized images docs --- .../enable-containerized-function.mdx | 176 ------------------ .../get-started.mdx | 50 ----- src/nav/serverless-function-monitoring.yml | 6 - 3 files changed, 232 deletions(-) delete mode 100644 src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-containerized-function-monitoring/enable-containerized-function.mdx delete mode 100644 src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-containerized-function-monitoring/get-started.mdx diff --git a/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-containerized-function-monitoring/enable-containerized-function.mdx b/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-containerized-function-monitoring/enable-containerized-function.mdx deleted file mode 100644 index f976e2f8edb..00000000000 --- a/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-containerized-function-monitoring/enable-containerized-function.mdx +++ /dev/null @@ -1,176 +0,0 @@ ---- -title: Create and deploy New Relic Lambda image layers -metaDescription: After enabling New Relic's containerized Lambda function, you can create a layer as an image. -redirects: -freshnessValidatedDate: never ---- - -With containerized Lambda functions, you can create Lambda layers using container images. As an alternative to deploying layers as .zip archives, container images allow for increased flexibility and improved security. - -## Prerequisites [#prereqs] - -Before you get started, make sure you've built a Dockerfile that includes your chosen runtime environment, installed your dependencies, and copied them into the correct directory structure. - -## Use a prebuilt New Relic Lambda layer [#prebuilt] - -First, you need to create your image layers. Once that's done, you can either create a regular or a public ECR function. To help you with this, we've created a [gallery of New Relic Lambda layers for Docker hosted on Amazon ECR](https://gallery.ecr.aws/x6n7b2o2?page=1). - -## Create your own New Relic layer from scratch [#create-lambda-layer] - -Follow these steps to create your own New Relic Lambda layer. - - - -### Create a New Relic Lambda layer - -Before you can deploy your image, you first need to create a New Relic Lambda layer. To do this, complete the following steps: - -1. Choose from the different [Amazon Resource Name (ARN) layers available to you](https://layers.newrelic-external.com/#/get-layers/get) to find the one that matches your system. -2. Create a new docker image using the following code: -``` -FROM alpine:latest as layer-copy -# Create a build stage to copy the files from S3 using credentials ARG AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-"region"} -ARG AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-"accessKey"} -ARG AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-"secretkey"} ENV AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} -ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} -ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} -RUN apk add aws-cli curl unzip -RUN mkdir -p /opt -RUN curl $(aws lambda get-layer-version-by-arn --arn --query 'Content.Location' --output text) --output layer.zip -RUN unzip layer.zip -d /opt -RUN rm layer.zip -FROM scratch -# Start second stage from blank image to squash all previous history, including credentials. -WORKDIR /opt -COPY --from=layer-copy /opt . -``` -3. Push that image to Amazon ECR. - -``` -docker build -t layer-image1:latest . -``` - - - -### Deploy the image in AWS ECR [#deploy-image-ECR] - -Now that you've created the image, you can deploy it using the following steps: - -1. Make sure you've installed the [AWS CLI](https://docs.aws.amazon.com/AmazonECR/latest/userguide/getting-started-cli.html) on your system. -2. Authenticate your AWS account using the following command: - -``` -aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 111122223333.dkr.ecr.us-east-1.amazonaws.com -``` -3. Create a repository in Amazon ECR using the `create-repository` command: - -``` -aws ecr create-repository --repository-name hello-world --image-scanning-configuration scanOnPush=true --image-tag-mutability MUTABLE -``` -4. Copy the `repositoryUri` from the output in the previous step. -5. To tag your local image into your Amazon ECR repository as the latest version, run the docker tag command: -``` -Replace docker-image:test with the name and tag of your Docker image. -``` -6. Replace < ECRrepositoryUri > with the `repositoryUri` that you copied. Make sure to include `:latest` at the end of the URI. Here is an example: - -``` -docker tag docker-image:test :latest -``` -7. Run the docker push command to deploy your local image to the Amazon ECR repository. Make sure to include `:latest` at the end of the repository URI. -``` -docker push 111122223333.dkr.ecr.us-east-1.amazonaws.com/hello-world:latest -``` - - - -## Create a Containerized Lambda function with New Relic layer image ECR [#lambda-function-image-layer] - -Now that you've created the image layer, you can need to create a Lambda function. You can create either a public or regular ECR layer. - - - -### Create a Lambda function with a New Relic image layer - -Now that you've created the image and deployed it to AWS ECR, now you need to create a Lambda function. To do this, complete the following steps: - -1. Use the image URI from either the New Relic layer you chose or your own image layer and add the image URI to your Dockerfile. Here's an example: -``` -FROM AS layer -``` -2. Add the directory for the layer. Here is an example: - -``` -# Layer code -WORKDIR /opt -COPY --from=layer /opt/ . -``` -3. Here is a complete example: - -``` -FROM AS layer -FROM public.ecr.aws/lambda/python:3.9 -# Layer code -WORKDIR /opt -COPY --from=layer /opt/ . -WORKDIR ${LAMBDA_TASK_ROOT} -# Copy requirements.txt -COPY requirements.txt ${LAMBDA_TASK_ROOT} -# Copy function code -COPY lambda_function.py ${LAMBDA_TASK_ROOT} -# Install the specified packages -RUN pip freeze > requirements.txt -# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) -CMD [ "lambda_function.handler" ] -``` -4. Push the image to Amazon ECR. -``` -docker build -t docker-image-sample:latest -``` - - -### Test the image locally (optional) [#test-image] - -While this step is optional, we recommend testing the image locally to ensure everything works correctly. - -1. Start the Docker image with the docker run command: -``` -docker run -p 9000:8080 docker-image-sample:latest -``` -2. From a new terminal window, post an event to the following endpoint using a curl command: - -``` -curl "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}' -``` - - -### Create a container image Lambda function [#create-container-image] - -1. Choose the container image option. -2. Name your function. -3. Browse your ECR and select. -4. Choose your architecture and create. -5. Once you create the function, add the environment variable. Below are the environment variables that you can add: - -``` -NEW_RELIC_ACCOUNT_ID : -NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS : boolean value -NEW_RELIC_LAMBDA_EXTENSION_ENABLED : boolean value -NEW_RELIC_LAMBDA_HANDLER : index.handler -NEW_RELIC_LICENSE_KEY : -NEW_RELIC_LOG_ENDPOINT : -NEW_RELIC_TELEMETRY_ENDPOINT : -``` -6. The environment endpoints are: - * NEW_RELIC_TELEMETRY_ENDPOINT - * Production : https://cloud-collector.newrelic.com/aws/lambda/v1 - * Eu-production : https://cloud-collector.eu01.nr-data.net/aws/lambda/v1 - * NEW_RELIC_LOG_ENDPOINT - *Production : https://log-api.newrelic.com/log/v1 - * Eu-production : https://log-api.eu.newrelic.com/log/v1 -7. Now, add a CMD handler that based on your language. To learn more, see our [Lambda instrumentation documentation](/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/instrument-your-own/) - - - - - diff --git a/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-containerized-function-monitoring/get-started.mdx b/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-containerized-function-monitoring/get-started.mdx deleted file mode 100644 index 4224b36e507..00000000000 --- a/src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-containerized-function-monitoring/get-started.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: "Get started with containerized Lambda functions" -metaDescription: Create containerized Lambda functions with New Relic. -redirects: -freshnessValidatedDate: never ---- - -import serverlessLambdaContainerizedFunctions from 'images/serverless_screenshot-full_lambda-containerized-functions.webp' - -Containerized Lambda functions offer an alternative way to deploy code within AWS Lambda while still enjoying the benefits of serverless computing. - -With New Relic, you can monitor AWS Lambda functions deployed using containerized images, so that you can: - -* **Increase flexibility**: Use familiar container tooling and leverage pre-built images for your code and dependencies. -* **Improve security**: Benefit from container isolation and potential security advantages associated with containerized environments. -* **Ensure consistent runtime**: Ensure a consistent development, testing, and deployment environment. - -A screenshot for containerized Lambda functions - -
- To view your containerized Lambda functions in the UI, Go to [**one.newrelic.com > All capabilities**](https://one.newrelic.com/all-capabilities) > Serverless functions. -
- -## Requirements [#Requirements] - -To create a containerized Lambda function using Node.js, you need the following: - -* [AWS Command Line Interface (AWS CLI) version 2] (https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) -* [Docker ](https://docs.docker.com/get-docker/) -* Node.js versions 16 or 18 -* Python version 3.9+ - - - After you've completed this setup, you can create a New Relic Lambda layer as an image - Review our Lambda monitoring capabilities. - - - - - - - - - - - diff --git a/src/nav/serverless-function-monitoring.yml b/src/nav/serverless-function-monitoring.yml index 1143475c10a..bb7901c3328 100644 --- a/src/nav/serverless-function-monitoring.yml +++ b/src/nav/serverless-function-monitoring.yml @@ -29,12 +29,6 @@ pages: path: /docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/enable-serverless-monitoring-aws-lambda-layerless - title: Update serverless monitoring path: /docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/update-serverless-monitoring-aws-lambda - - title: Enable Lambda containerized functions - pages: - - title: Get started - path: /docs/serverless-function-monitoring/aws-lambda-monitoring/enable-containerized-function-monitoring/get-started - - title: Create and deploy - path: /docs/serverless-function-monitoring/aws-lambda-monitoring/enable-containerized-function-monitoring/enable-containerized-function - title: OpenTelemetry pages: - title: Trace your Java Lambda functions with New Relic and OpenTelemetry