Skip to content

Several minor discrepancies between "cargo lambda watch" and actually running on aws #863

Description

@Jimmy-Z
  • when there's no query, payload.rawQueryString on watch is Null, on aws it's String("").
  • payload.requestContext.http.protocol on watch is http, on aws it's HTTP/1.1.
  • there's an extra payload.httpMethod member on watch, which is identical to payload.requestContext.http.method, doesn't exist on aws.
  • payload.requestContext.http.userAgent on watch is cargo-lambda, on aws it mirrors payload.headers.user-agent
  • there's an extra payload.headers.lambda-runtime-aws-request-id header on watch, which mirrors payload.requestContext.requestId, doesn't exist on aws.

code is adapted from the streaming example
local testing is cargo lambda watch then curl http://127.0.0.1:9000
aws testing is deploying it as a function url, then curl

use lambda_runtime::{
	Error, LambdaEvent, service_fn,
	streaming::{Body, Response},
	tracing,
};
use serde_json::Value;

async fn func(event: LambdaEvent<Value>) -> Result<Response<Body>, Error> {
	let diag = format!("{:#?}", event.payload);

	let mut resp = Response::from(Body::from(diag));
	resp.metadata_prelude.headers.append("content-type", "text/plain".parse().unwrap());

	Ok(resp)
}

#[tokio::main]
async fn main() -> Result<(), Error> {
	// required to enable CloudWatch error logging by the runtime
	tracing::init_default_subscriber();

	lambda_runtime::run(service_fn(func)).await?;
	Ok(())
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions