-
We are interested in building and deploying a aspnetcore application to Lambda, but ideally building it once, then deploying the same package to dev, stage and prod environments passing in the appropriate template parameters to each. Is there a way to do this? RIght now our command looks something like dotnet lambda deploy-serverless --configuration Release --config-file aws-lambda-tools-dev.json and it takes care of building, packaging, uploading to S3, and deploying. Ideally we would have a separate job (jenkins right now) to build the package, and a different one to selectively promote the same built package to one of the 3 environments. Or perhaps one job to build and deploy to dev, then another to promote the same package from dev to stage or prod. Is anyone doing something like this with this tooling? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Off the top of my head I think what I would do is write the CloudFormation template to have a parameter that controls what stage you want to deploy. You can use the parameter in your template to control what environment variables are set in your function which in your code can control what configurations to load. Then use |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Off the top of my head I think what I would do is write the CloudFormation template to have a parameter that controls what stage you want to deploy. You can use the parameter in your template to control what environment variables are set in your function which in your code can control what configurations to load.
Then use
dotnet lambda package-ci
command to build/package/upload the project and generate a copy of the CloudFormation template with the location of the Lambda function binary updated to the location in S3. Then throughout your pipeline you can use the CLI or whatever tool to deploy/redeploy the CloudFormation template passing in the parameter value for the expected stage.