Run Container image Lamda with runtime args

1

I need to run a container image in a lambda. For each run, I have to supply it a runtime application config file. How can I supply this runtime application config file? I do not want to rebuild the docker image for each run because there are no code changes; I just want to be able to run the same code, same lambda with a different application config-file. Thanks

preguntada hace 2 años460 visualizaciones
2 Respuestas
2
Respuesta aceptada

There might be couple of options -

  1. Use persistent storage, such as EFS, S3 or /tmp directory in certain scenarios;
  2. Refactor and leverage ENV in dockerfile, for exmaple;
  3. (Strongly Recommended) Refactor and use SSM Parameter Store or Secret Manager.
Jason_S
respondido hace 2 años
  • Hi - Just to clarify, your main concern is don't want to rebuild the Lambda custom image that is part of a Cfn custom resource? If so, is it possible to have your Lambda function in a separate CloudFormation template and reference the ARN? Also where is the config file you are referring to stored right now?

  • Thanks for the answers. I have a follow-on question please. I am using a cloudformation custom resource to invoke this lambda whenever there is changes to my config file. In other words it is invoked whenever the custom resource is created, updated, or deleted, AWS Cloud formation calls this lambda. Each invocation of this lambda will use a different config. I have to make this config accessible to this lambda created in the cdk. It is a large config file, I cannot put contents of this config into env variables

    const myHandler = new NodejsFunction(this, "myHandler", {
      runtime: Runtime.NODEJS_14_X,
      entry: "<entry>",
      handler: "handler",
      vpc: <vpc>,
      securityGroup: <sg>,
      functionName: "<funcName>",
      timeout: Duration.minutes(10),
      environment: {
        <env variables>
      },
      role: <role>
    });
    
  • So, my current situation is I have a custom resource defined like this.

    new CustomResource(this, "Resource1", {
      serviceToken: myProvider.serviceToken,
      properties: {
        configsList: <list of config items>
      }
    });
    

    Whenever the properties.configList changes the lambda function is invoked when I run cdk deploy. If there are no changes to the configsList then the lambda is not called. This is working well when my lambda is a nodejs function.

    But now my lambda is a container that I need to run and supply this configsList to it as a file. I am unable to figure out a way to do this.

0

In addition to Jason_S's answer:

  1. Make use of AppConfig - AWS service for managing and deploying configurations
respondido hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas