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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠