This message was deleted.
# aws
s
This message was deleted.
e
Or, maybe there’s a better way to work with Lambda qualifiers for CI and have Aliases for feature branches. Any advise is more than welcome!
l
Are you changing the Pulumi name of the Alias at the same time? If you change the name (that is, if stageSanitized changes, or if you add the -new suffix), then it is an entirely different resource as far as Pulumi is concerned, and it will delete the old one.
e
@little-cartoon-10569 thanks for the reply! I’m trying to set up (understand at this point) the way to use Alias on a Lambda function to CI or feature branching (to use the same lambda but with the alias pointing to a specific version of the Lambda, maybe it’s not the best way). So for context I have the lambdas deployment like this:
Copy code
const myLayer = new aws.lambda.LayerVersion("layer-dev", args);

const myFunction = new aws.lambda.Function("lambda-function1", {
  ...args,
  name: 'my-function-dev',
  layers: [myLayer.arn],
  publish: true
});

new aws.lambda.Alias("alias-dev", {
  name: 'dev',
  functionVersion: myFunction.version,
  functionName: myFunction.arn,
})
[stageSanitized = “dev”] So with that scenario, I tried two options: • Same Pulumi stack, changed the stageSanitized from
dev
(code above) to
SER001
(feature branch). And Pulumi deletes the dev Alias. Makes sense, as it’s not in the new Pulumi desired final state. Is there a way NOT to be deleted, and leave it as is? Because I need it to stay there, pointing to the Lambda published version as it was. So, basically could point me to a direction to understand if there’s a way to work with Lambda’s aliases with Pulumi? • Different Pulumi stack, or maybe this is the way to go. Instead of using the Alias on a Lambda, it’s needed to make a complete deployment with another stack name, with the stack reference in the resources naming (so there’s no collision, as I’m forcing the AWS resources names, for references purposes). Thanks!
l
So long as you don't change the Pulumi name, it won't delete the Alias, just update it.
You can change the resource name all you like.
However, from what you've described, I would guess that you do want a stack per branch. Or at least, per branch that you intend to deploy. You want two Aliases (dev and ser001) pointing to different versions of the same lambda, but managed by the same bit of Pulumi code. Therefore, you need two stacks.
e
@little-cartoon-10569 Thanks! I was thinking on it, and on how Pulumi works I understand now that there’s only the new stack way. One more question on it, if I do create a new stack and make the deployment of the same Pulumi bit of code: • Lambda code references are only with the environment =
dev
(no reference to the actual stack name), so Pulumi name and AWS resource name for Layer and Lambda are the same between stacks. • But, the Alias is related to the Stack:
dev
||
ser001
. Pointing to the same Lambda. On the Lambda code for the new deployment (
ser001
Stack), wouldn’t I get an error because the naming is the same (Pulumi and AWS resource)? Or how can I make this new deployment for another stack be just a new version on the same Lambda?
l
I'm afraid I don't understand the question. Are you asking how to avoid creating two lambdas? Only create the lambda in one stack (
if ("dev" == Pulumi.getStack()
), and export the stack reference. In the other stack, use the stack reference when creating the alias.
Another, arguably better, option, is to have a separate project for shared resources, and not create the lambda in either the dev or ser001 stacks. Both stack would use a stack reference to get the alias.