sam deploy does not work correctly on .NET 7 AOT functions

0

I have a lambda with a triger that is an EventBridge (CloudWatch) rule as schedule. It was created in .NET Core 3.1 and it works as expected. But lately I had updated this function, and at the same time was decided to update to .NET 7 native AOT. I successfully updated this lambda to .NET 7 and I am able to use "sam build" to create a bootstrap file (the AOT). Now I would like to replace my existing .NET Core 3.1 in AWS with this .NET 7 AOT. But I am having issues with "sam deploy".

  1. Option --s3-bucket does not seem to work at all, even when resolve_s3 = false in samconfig.toml . Running with the option --guide still assumes resolve_s3 is false and creates a new s3 bucket (or better adds my function to an existing previously created with resolve_s3 = true).

  2. Is there a way to publish the updated lambda to AWS and replace the old one? All I can do at the moment is publish the updated lambda, setup its triger (same triger as old lambda), then disable the old lambda.

  3. Why "sam deploy" of a .NET 7 AOT function publishes with weird characters in the name of the function? i.e. my original function name (.NET Core 3.1) in AWS was LambdFunction. The updated function is uploaded with the name format: <stack_name>-<resource name in template.yml>-<weird code>. I could get around by setting <stack_name> as an empty string, but I have no control over <weird code>

Any comment about this would be very appreciated.

chio
asked 6 months ago178 views
1 Answer
0

#1 -- Do not use --guide option if you want to use your own s3 bucket. Use --debug option to see what happens during deployment. But make sure the default "samconfig.toml" file has resolve_s3 set to false.

First I let "sam deploy" create the s3 bucket; then I created my own bucket as a copy of this bucket with a nice name like "dotnet7-apps". Then tried again "sam deploy" using "dotnet7-apps" -- it worked nicely! Trying the other options of "sam deploy" one can configure the bucket like creating folders to save this 1 function, then another folder for another function, and so on.

#2 -- Unfortunately "sam deploy" uploads and publishes the lambda with a slightly different name than my original one, so at the end I would have to just publish the .NET 7 function, put the same trigger as the .NET 6 one and delete the .NET 6 (or better just remove its trigger until I verify the updated one is working as intended)

#3 -- At the moment I cannot do anything about this, looks that is the way "sam deploy" works for naming conventions. At least after the first deployment, subsequent deployments of the updated function go to the same services. "stack_name" can not be empty; that is the name of the stack in CloudFormation that corresponds to this lambda....no wonder it is prefixed to the lambda function name to identify it.

Right now I am trying to see if I can edit template.yaml to include in the "Outputs" section a link or whatever is called to my current EventBridge rule, that way the deployment is done in 1 shot and I don't have to go to AWS and manually do the link everytime.

chio
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions