crooked-ram-3551
10/01/2025, 8:13 PMpulumi preview etc. show that there are no changes, but when I look in the AWS dashboard I can see that one region still has the old code. This is an app with one stack that deploys to 2 region.
I think the culprit is somehow this:
code=pulumi.FileArchive("path/to/lambda.zip"),
I even tried making 2 copies of the file (one for each region), but pulumi still isn’t seeing that one of the lambdas needs to be updated. 🤔
Any ideas?little-cartoon-10569
10/01/2025, 8:28 PMlittle-cartoon-10569
10/01/2025, 8:33 PMcrooked-ram-3551
10/01/2025, 8:36 PMimport pulumi
import pulumi_aws as aws
import shutil
from providers import providers
from regional.iam_role_lambda import iam_roles
from regional.s3_artifacts import s3_artifacts
cfg = pulumi.Config()
prefix = cfg.require("resourcePrefix")
regions = cfg.require_object("regions") # e.g. us-east-1, us-west-2
tags = cfg.get_object("tags") or {}
my_lambda = {}
for r in regions:
provider = providers[r]
# Region-specific copy of the zip;
regional_zip_path = f"path/to/lambda_src-{r}.zip"
shutil.copy2("path/to/lambda_src.zip", regional_zip_path)
# The role this Lambda assumes
role = iam_roles[r]
# Build the Lambda function
fn = aws.lambda_.Function(
f"{prefix}source-builder-{r}",
name=f"{prefix}source-builder-{r}",
role=role.arn,
runtime="python3.12",
handler="index.lambda_handler",
timeout=300,
memory_size=256,
code=pulumi.FileArchive(regional_zip_path),
environment=aws.lambda_.FunctionEnvironmentArgs(
variables={
# ...
}
),
tags=tags,
opts=pulumi.ResourceOptions(
provider=provider,
depends_on=[
# ...
],
),
)
my_lambda[r] = fn
pulumi.export(
"my_lambda",
{
r: {
"name": my_lambda[r].name,
"arn": my_lambda[r].arn,
}
for r in regions
},
)little-cartoon-10569
10/01/2025, 8:38 PMlittle-cartoon-10569
10/01/2025, 8:39 PMcrooked-ram-3551
10/01/2025, 8:40 PMlittle-cartoon-10569
10/01/2025, 8:40 PMlittle-cartoon-10569
10/01/2025, 8:42 PMlittle-cartoon-10569
10/01/2025, 8:43 PMlittle-cartoon-10569
10/01/2025, 8:43 PMcrooked-ram-3551
10/01/2025, 8:45 PM<http://pulumi.log.info|pulumi.log.info>(f"[DEBUG] regions = {regions}")
I see what I expect, e.g.
[DEBUG] regions = ['us-east-2', 'us-west-2']
so that appears to be working fine.little-cartoon-10569
10/01/2025, 8:46 PMcrooked-ram-3551
10/01/2025, 8:48 PMcrooked-ram-3551
10/01/2025, 8:49 PMcrooked-ram-3551
10/01/2025, 8:58 PM# Pulumi requires unique provider refs across the entire stack, so
# we create them once here per region.
import pulumi_aws as aws
import pulumi
cfg = pulumi.Config()
regions = cfg.require_object("regions")
providers = {r: aws.Provider(f"aws-{r}-provider", region=r) for r in regions}little-cartoon-10569
10/01/2025, 9:02 PMlittle-cartoon-10569
10/01/2025, 9:31 PMlittle-cartoon-10569
10/01/2025, 9:31 PMlittle-cartoon-10569
10/01/2025, 9:33 PMcode: new pulumi.asset.AssetArchive({
".": new pulumi.asset.FileArchive(resolve(dirname(fileURLToPath(import.meta.url)), "lambda", codePath))
});
Where codePath is a directory, for us. I presume you would use a .zip directly, not a directory.modern-spring-15520
10/01/2025, 9:35 PMcrooked-ram-3551
10/02/2025, 1:15 PMwhite-vase-18996
10/02/2025, 1:18 PMcrooked-ram-3551
10/02/2025, 1:21 PMmodern-spring-15520
10/02/2025, 1:22 PMI’m gonna pour coffee on my headI think you might be using the coffee wrong 🙂
crooked-ram-3551
10/02/2025, 1:24 PMmodern-spring-15520
10/02/2025, 1:35 PMcrooked-ram-3551
10/02/2025, 1:47 PM