New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of CloudFormation intrinsic functions in AutoPublishAlias #220
Comments
Hey @dslagle, At the moment, we don't support Sub for AutoPublishAlias. Can you explain your use-case to wanting this a little more? It would good for us to understand why you want to make this AutoPublishAlias 'dynamic' like this. You can do something like this though:
|
My thought was to use aliases for various environments like dev, test, prod, etc. and be able to control them through environment variables for the purposes of CI/CD. This way I can maintain a single template and a single function (instead of naming the function dev-, test-, etc.). To do that I was trying to make use of the --parameter-overrides option on the CLI |
I'm going to work around it by altering the template as part of the CI process before deployment. But on a side note, is it possible to tell where the intrinsic functions in CF are supported and where they are not based on documentation? Both the Function Name and the Alias name are String types, but, as noted, the Alias doesn't support the intrinsic functions. Is there an easy way to know? Thanks. |
@dslagle I am going to answer both your questions here. For your first comment: If that is not what you are attempting to do, can you explain your setup further or what you are trying to achieve? For your second comment: The team knows that documentation and intrinsic support is an area for improvement. We are working towards this improvement but will take some time to get out. Right now, I do not have a good way to surface this information to you or the community. I would like us to do this the right way and get better documentation up. We may do a quick update to surface this information but will depend on how far out the documentation update is. I know this isn't a great answer but hopefully this pain will go away soon enough. |
I see what you are saying. I'm new to CloudFormation and wasn't thinking about it from that perspective, but what you are saying makes sense. I will adjust to take this approach. I really appreciate the answers/feedback. |
@jfuss can you clarify this statement:
Does this mean "3 stacks, 1 template, 1 lambda function" or "3 stacks, 1 template, 3 lambda functions"? |
@gallamine Sure. This would mean "3 stacks, 1 template, 3 lambda". Let me attempt to describe this a little further. My recommendation is to have a CloudFormation stack per environment or stage (depending on your terminology). So taking the example above, lets say we have 3 stages (dev, test, and prod). Each of those stages would have their own CloudFormation stack, lets name them as follows: dev-stack, test-stack, prod-stack. Your CI/CD system will need to deploy to dev-stack, test-stack, and then prod-stack but will be pushing one template through all of these stacks. Let's look go a little deeper into what is going on from a dev flow. Advantages of this kind of structure:
Caveats:
There are probably more caveats to this but can't think of them currently. Would be happy to discuss further. I have become very passionate about these kinds of topics (safe deployments/"Infrastructure as Code"/reduce blast radius/etc). |
I ran into this as well. My use case is similar but I'm basing my deploys off a pipeline. Pseudo:
I have one template, that is run at each stage in my pipeline:
My Pipeline owns naming the lambda alias. Dev will always be dev, prod will always be prod. Different lambda's underneath. In Dev, and in Prod, I could manually downgrade the version number if I need to. (This is really the only reason I'm using the alias). Do you see a risk in doing it this way? FYI: my workaround is to not pass in However, options are nicer. |
Hi, I want to create 3 different environment, DEV, QA and PROD. 1st Tech Stack: Xamarin based mobile APP(.NET) which uses COGNITO, LAMBDA, DYNAMODB, SNS etc. I want to create DEV, QA and PROD stacks and will keep updating that stacks for eventual CI/CD pipeline(which I have no idea where to start from). I am playing with .NET SDK for AWS and created AWS lambda project templates (AWS Lambda Project and AWS Serverless Applicatin with Tests). I am also able to deploy it using Publish to AWS Lambda wizard. Actualy I want to know how I can achieve following: Create CloudFormation stacks for each DEV, QA and PROD environment. I want to create seperate stacks rather than one single stack. This should create all COGNITO pools, roles, DynamoDB tables, Lambda functions in that environment. However I don’t have any need to use API Gateway for these Lambda functions. I am planning to pass environment variables as input parameter like “DEV”, “STAGING” so that related resource names are created using that input. 2nd Tech Stack: I also have a small web application (Node.js) based which uses LAMBDA API Gateway which contains how can I maintain similar DEV, QA and PROD environment for this tech stack? |
@jfuss Thanks a lot for your detailed comment above. It helped me to realize how to build my pipelines better, some concepts finally clicked for me. 🍻 |
Closing this issue as there has been no activity in over year, with the assumption that answers by Jacob answered the overall question. Please re-open if you have more questions. |
I'm relatively new to CloudFormation and AWS SAM, so forgive me for any misunderstandings. I'm attempting to assign an alias to a function version using a CF function such as !Sub or !Join, but this does not seem to be allowed. I've successfully used the functions with the Lambda's FunctionName attribute, but it will not work with AutoPublishAlias. For example the following works:
But when I switch the !Sub function to AutoPublishAlias it fails:
The error message is: 'AutoPublishAlias' must be a string or a Ref to a template parameter. Is this intentional or a bug, and is it something that could be supported in the future?
Thanks in advance for any help/information!
The text was updated successfully, but these errors were encountered: