dry-journalist-60579
10/09/2024, 4:44 PMaws.lambda_.Function(publish=True)
, is that supposed to create an update on every pulumi up
? Or is it supposed to only publish a new version if something has changed?dry-journalist-60579
10/09/2024, 4:45 PMdry-journalist-60579
10/09/2024, 4:46 PMlambda_function.qualified_arn
is changing, causing a downstream ripple effectdry-journalist-60579
10/09/2024, 4:58 PMdry-journalist-60579
10/09/2024, 4:59 PMdry-journalist-60579
10/09/2024, 5:01 PMpulumi 3.120.0=>3.136.0
pulumi-aws 6.40.0=>6.55.0
future-hairdresser-70637
10/09/2024, 7:00 PMfuture-hairdresser-70637
10/09/2024, 7:00 PMdry-journalist-60579
10/09/2024, 7:01 PMfuture-hairdresser-70637
10/09/2024, 7:03 PMdry-journalist-60579
10/09/2024, 7:32 PMname = "foo"
vpc = ...
rds = ...
repo = awsx.ecr.Repository(
f"{name}-ecr-repo",
opts=pulumi.ResourceOptions(parent=self),
)
image = awsx.ecr.Image(
f"{name}-image",
repository_url=repo.url,
context=os.path.join(os.path.dirname(__file__), "src"),
platform="linux/x86_64", # Default lambda architecture is x86_64
opts=pulumi.ResourceOptions(parent=self),
)
lambda_security_group = aws.ec2.SecurityGroup(
f"{name}-lambda-sg",
vpc_id=vpc.vpc_id,
egress=[
aws.ec2.SecurityGroupEgressArgs(
from_port=5432,
to_port=5432,
protocol="tcp",
cidr_blocks=[vpc.vpc.cidr_block],
),
],
)
lambda_function = aws.lambda_.Function(
f"{name}-lambda",
role=lambda_role.arn,
package_type="Image",
image_uri=image.image_uri,
publish=True,
environment={
"variables": {
"DB_HOST_PORT": rds.endpoint,
"DB_USER": db_username,
"DB_NAME": db_name,
"DB_PASSWORD": db_password,
}
},
logging_config=aws.lambda_.FunctionLoggingConfigArgs(
log_format="JSON",
),
vpc_config=aws.lambda_.FunctionVpcConfigArgs(
subnet_ids=vpc.private_subnet_ids,
security_group_ids=[lambda_security_group.id],
),
opts=pulumi.ResourceOptions(
parent=self,
depends_on=[rds],
),
)
dry-journalist-60579
10/09/2024, 7:52 PMdry-journalist-60579
10/09/2024, 7:52 PMmy--project-dev-fivetran-config-lambda
has the plan “update” every rundry-journalist-60579
10/09/2024, 7:54 PMlambda_function.qualified_arn
to be dirty, my Command get’s updated:
invoke_lambda = command.local.Command(
...,
create=lambda_function.qualified_arn.apply(...),
)
dry-journalist-60579
10/09/2024, 7:56 PM[diff: ~code]
on every run is this one:
CODE_PATH = os.path.join(os.path.dirname(__file__), "lambda.py")
lambda_function = aws.lambda_.Function(
"lambda",
role=lambda_role.arn,
runtime=aws.lambda_.Runtime.PYTHON3D12,
handler="datadog_lambda.handler.handler",
code=pulumi.AssetArchive({"lambda.py": pulumi.FileAsset(CODE_PATH)}),
environment={
"variables": {
# ...
}
},
layers=[
f"arn:aws:lambda:{args.aws_region}:{DD_ACT}:layer:Datadog-Python312:98",
f"arn:aws:lambda:{args.aws_region}:{DD_ACT}:layer:Datadog-Extension:65",
],
timeout=15,
opts=pulumi.ResourceOptions(parent=self),
)
dry-journalist-60579
10/10/2024, 1:58 PMfuture-hairdresser-70637
10/10/2024, 4:41 PMdry-journalist-60579
10/10/2024, 7:41 PM~ aws:lambda/function:Function: (update)
[id=...]
[urn=...]
[provider=...]
~ code: archive(assets:fabcfb3) {
}
(There’s nothing in the ~code that has actually changed.)
And the one for the version “update” looks like this (there are no visible changes, yet the Lambda Invocation thinks there’s been an update):
~ aws:lambda/function:Function: (update)
[id=...]
[urn=...]
[provider=...]
environment : {
...
}
imageUri : "..."
loggingConfig : {
applicationLogLevel: ""
logFormat : "JSON"
systemLogLevel : ""
}
memorySize : 128
name : "..."
packageType : "Image"
publish : true
reservedConcurrentExecutions: -1
role : "..."
skipDestroy : false
tags : {
...
}
tagsAll : {
...
}
timeout : 3
vpcConfig : {
...
}
++aws:lambda/invocation:Invocation: (create-replacement)
[id=...]
[urn=...]
[provider=...]
~ qualifier: "4" => output<string>
future-hairdresser-70637
10/10/2024, 10:07 PMpublish=True
. the qualifier will change at that point even if the code/image does not because you're "publishing" a new version. here's a related upstream issue https://github.com/hashicorp/terraform-provider-aws/issues/33383
you could try employing the workaround there; that will suppress the update based on version:
opts=pulumi.ResourceOptions(
ignore_changes=["qualifiedArn", "qualifiedInvokeArn", "version"],
),
I didn't dig deeper into whether the dependency updates should have made a difference - it's possible, but I'm suspecting that upstream issue would explain it overall.dry-journalist-60579
10/11/2024, 3:07 PMignore_changes
will that mean that legitimate updates will be ignored?dry-journalist-60579
10/11/2024, 3:08 PMAssetArchive
?dry-journalist-60579
10/11/2024, 3:24 PMdry-journalist-60579
10/11/2024, 3:24 PMfuture-hairdresser-70637
10/16/2024, 12:46 PMHmm if I useIn general, yes. Specifically in this case I personally don't see this as a show-stopping workaround/hack if documented as the legit updates here are caused by the lambda versioning that isn't getting properly diffed. It's certainly not ideal, though. 🙂will that mean that legitimate updates will be ignored?ignore_changes
any thoughts on what’s causing the infinite updates for theMy first assumption is a file changing thus the archive's hash changing (see here for code) - is something changing the contents of the?AssetArchive
AssetArchive
dir? a build? dependency update? etc.
where/how does the code in https://github.com/hashicorp/terraform-provider-aws/ actually run? Is it in the pulumi sdk? The cli?This gets complicated fast; if you haven't, start here https://www.pulumi.com/docs/iac/concepts/how-pulumi-works/ then progress to here https://github.com/pulumi/pulumi/tree/master/docs/architecture and then https://github.com/pulumi/pulumi/blob/master/docs/architecture/providers.md where you'll end up at https://github.com/pulumi/pulumi-terraform-bridge 😄
dry-journalist-60579
10/16/2024, 2:12 PMCODE_PATH = os.path.join(os.path.dirname(__file__), "twilio_webhook_fallback/lambda.py")
lambda_function = aws.lambda_.Function(
f"{name}-lambda",
role=lambda_role.arn,
runtime=aws.lambda_.Runtime.PYTHON3D12,
handler="datadog_lambda.handler.handler",
code=pulumi.AssetArchive({"lambda.py": pulumi.FileAsset(CODE_PATH)}),
# ...
)
dry-journalist-60579
10/16/2024, 2:12 PMpulumi up
two times in a row and it picks up a difffuture-hairdresser-70637
10/16/2024, 10:37 PMpublish=True
for that aws.lambda_.Function
?dry-journalist-60579
10/17/2024, 2:10 AMfuture-hairdresser-70637
10/17/2024, 3:14 PMFileAsset
and AssetArchive
into their own variables? also, is the hash visibly changing in the diff after an up
? i.e. code: archive(assets:*fabcfb3*)dry-journalist-60579
10/17/2024, 3:40 PM[diff: ~code]
future-hairdresser-70637
10/17/2024, 4:11 PM--diff
to the command you should get more details
~ code: archive(assets:f217920->32c74b9) {
~ "lambda.py": asset(file:1b676be->03d1a6b) { /code/./simple_lambda.py }
dry-journalist-60579
10/17/2024, 5:15 PMfuture-hairdresser-70637
10/17/2024, 5:22 PMpulumi about
dry-journalist-60579
10/17/2024, 6:00 PM