The role defined for the function cannot be assumed by Lambda

后端 未结 11 1244
野性不改
野性不改 2021-02-04 23:29

I\'m getting the error \"The role defined for the function cannot be assumed by Lambda\" when I\'m trying to create a lambda function with create-function command.

11条回答
  •  北海茫月
    2021-02-05 00:11

    Had the same issue although my IAM role did have the right policy and trust relationship. Lambda creation worked fine when done through CLI the problem was when using lambda module after just creating the IAM role.

    I also tried to "pause" for few seconds but it didn't help.

    Ended up adding retry and delay until registerdLambda.code was defined. Usually it works after 1-2 tries.

    example:

     - name: creating lambda function
       lambda:
         state: present
         name: "{{ lambdaName }}"
         zip_file: "{{ lambdaZipFile }}"
         runtime: "{{ lambdaRuntime }}"
         role: "{{ lambdaRole }}"
         description: "{{ lambdaDescription }}"
         handler: "{{ lambdaHandler }}"
       register: lambdaFunc
       retries: 3
       delay: 10
       until: "{{ lambdaFunc.code is defined }}"
    

提交回复
热议问题