https://pulumi.com logo
#general
Title
# general
h

happy-advantage-79856

01/04/2024, 5:08 AM
Getting a weird issue trying to incorporate a python lambda in our nodejs project in AWS, does anyone have any idea what I can do to fix this besides just manually setting all of the runtimes and removing the runtime from the Pulumi.yaml file? It seems weird the yaml for the whole project overrides the actual setting for the lambda. When I create the Python lambdas the runtime I pick is over-ridden by the runtime in the Pulumi.yaml, so instead of running in Python 3.8, it runs in NodeJS 14.x which breaks the lambda unless I manually change it in AWS Management Console. This is the Pulumi Code:
Copy code
export const onDocumentsIndexingEvent = new lambda.Function(`onDocumentsIndexingEvent-${stack}-${project}`, {
    code: new pulumi.asset.AssetArchive({ '.': new pulumi.asset.FileArchive('./jobs/python/mb_indexer_gpt/') }),
    runtime: lambda.Runtime.Python3d8,
    timeout: 200,
    layers: [pythonLayer.arn],
    handler: 'mb_indexer.lambda_handler',
    role: pythonLambdaRole.arn,
    environment: {
        variables: {
            OPENAI_API_KEY: ''
        }
    }
})
i

icy-controller-6092

01/04/2024, 5:14 AM
do you have a typo there for
runtime
?
i had a quick look at the sdk source code, I think you need to write:
runtime: lambda.enums.Runtime.Python3d8
are you using typescript in your pulumi program? this would have picked up such an error before deploying
no scratch that, I think the way you have it is right. next time you run
pulumi up
try adding the
--refresh
flag
fyi, runtime in Pulumi.yaml is not used for deploying resources - it's only used for running your deploy program locally -- so it should not be affecting this
h

happy-advantage-79856

01/04/2024, 5:38 AM
I can try the enum, I also did ‘python3.8’ as a string. Yes, I am using Typescript in the project, and it seems correct to me. I will try with --refresh
I had set it to the correct python3.8 runtime manually. After trying pulumi up with --refresh, it incorrectly set it back to node 14 again, despite the runtime in the lambda being python3.8
i

icy-controller-6092

01/04/2024, 6:24 AM
It will keep doing that every time it detects the runtime has been changed from what it wants to set
can you do
pulumi stack export > state.json
then look through that file to find the
onDocumentsIndexingEvent...
resource then have a look at the inputs there, what is it saying?
h

happy-advantage-79856

01/04/2024, 7:49 AM
“runtime”: “nodejs14.x”,
Copy code
"inputs": {
                    "__defaults": [
                        "memorySize",
                        "name",
                        "packageType",
                        "publish",
                        "reservedConcurrentExecutions",
                        "skipDestroy"
                    ],
                    "code": {
                        "4dabf18193072939515e22adb298388d": "0def7320c3a5731c473e5ecbe6d01bc7",
                        "assets": {
                            ".": {
                                "4dabf18193072939515e22adb298388d": "0def7320c3a5731c473e5ecbe6d01bc7",
                                "hash": "76557255a1b978ea5f4df5c201cb6a1bd1aa6b7b2f218bb232debd1b137425b7",
                                "path": "./jobs/python/mb_indexer_gpt/"
                            }
                        },
                        "hash": "76557255a1b978ea5f4df5c201cb6a1bd1aa6b7b2f218bb232debd1b137425b7"
                    },
                    "environment": {
                        "__defaults": [],
                        "variables": {
                            "OPENAI_API_KEY": "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",
                            "__defaults": []
                        }
                    },
                    "handler": "mb_indexer.lambda_handler",
                    "layers": [
                        "arn:aws:lambda:us-west-2:617706700270:layer:python_layer:7"
                    ],
                    "memorySize": 128,
                    "name": "onDocumentsIndexingEvent-ai-smart_onboarding-3075219",
                    "packageType": "Zip",
                    "publish": false,
                    "reservedConcurrentExecutions": -1,
                    "role": "arn:aws:iam::617706700270:role/pythonLambdaRole-ai-smart_onboarding-4552f77",
                    "runtime": "nodejs14.x",
                    "skipDestroy": false,
                    "timeout": 200
                }
i

icy-controller-6092

01/04/2024, 8:48 AM
That’s no good, what if you try changing the runtime to some static string that makes no sense - just to ensure that an error occurs
h

happy-advantage-79856

01/04/2024, 4:17 PM
I tried it with a random static string and the pulumi up --refresh command. It resulted in the exact same thing as when I did the string
'python3.8'
or
lambda.Runtime.Python3d8