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

已提問 2 年前檢視次數 460 次
2 個答案
2
已接受的答案

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
已回答 2 年前
  • 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
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南