nested stacks in AWS CloudFormation are not changing - amazon-web-services

I have more than 20 different services in AWS which are stacks defined in one main file (there are reference to template in .json), so these stacks are nested. Update of this stack is triggered by Codepipeline which is well configured with Github and production site. My problem is with during updating CF script because only main level resources are updated, unfortunately, I cannot see any changes which are linked with nested stacks. Why?

Related

AWS Lambda "Applications" and Deployment Environments

I have an AWS Lambda "Application" which was created from an AWS Lambda app template. This in turn created two stacks. The serverlessrepo-??-toolchain stack and the Lambda Application stack that has the actual application...
I've done the development and added lambdas, permission, and such. Really evolved the template.yml and the buildspec.yml.
It all works and properly rebuilds the stack.
But in an AWS Lambda Application that is using CodeDeploy/CodePipeline, what is the best strategy for deploying additional environments? Let's assume the first one - the one made by the serverlessrepo-??-toolchain stack -- is Dev. How do I create a QA and Prod from my template.yml?
They need to be new stacks, yes? As in each environment is its own stack.
Thank you.

How many times do I need to run cdk bookstrap?

I am trying to understand how cdk bootstrap works. I have read the doc: https://github.com/aws/aws-cdk/blob/master/design/cdk-bootstrap.md and tried to run the command in my AWS account. I can see a new cf stack is created CDKToolkit which includes s3 bucket, iam roles etc.
My question is whether I need to run this command for every cdk project I have? Or is it just one time execution?
If I have projects using different cdk version v1 and v2, do I use the same cf stack? Will it cause version conflicts?
It's typically a one time thing per account per region. The infrastructure in that stack is shared among your CDK apps.
There was a change in format a while ago that required an update of the stack, but since then it has remained largely unchanged.
The docs on bootstrap are probably more helpful than the Github Link: CDK Bootstrapping.
Each CloudFormation stack created by a CDK app only belongs to one CDK app, they shouldn't be shared. The outputs can be referenced from other apps, but each stack should belong to one app.
That's why you can mix and match CDK versions across different stacks. Usually each CDK app maps to one or more CloudFormation stacks.

Maintain order of deployment between multiple cloudformation stacks in Jenkins

I am trying to deploy multiple infra cloud formations through Jenkins and in one of the situations, there are two stacks in which one of the stacks is having a dependency on the other stack. As the deployment script will not be able to maintain the order. So how can I achieve it here in cloud formation
PS: Is there any way that the dependent stack will wait until the other stack got deployed. Here Jenkins can deploy multiple stacks in parallel.
Have you tried using the Stack resource type itself?
The AWS::CloudFormation::Stack type nests a stack as a resource in a
top-level template.
You can use that along with things like a WaitCondition or a DependsOn attribute to ensure that one resource is created before another, so you could have a parent Stack that creates two nested Stacks, where one depends on the other.

Is it possible to deploy same aws lambda jar in multiple regions at once?

I have a deployed a lambda in US EAST region. There is a need to deploy the same lambda in multiple regions. Is there a simple way(in the portal) to do it ? Or do I have to manually create these lambdas in every region ?
Your best bet for this will be to use a stack set in CloudFormation.
AWS CloudFormation StackSets extends the functionality of stacks by
enabling you to create, update, or delete stacks across multiple
accounts and regions with a single operation. Using an administrator
account, you define and manage an AWS CloudFormation template, and use
the template as the basis for provisioning stacks into selected target
accounts across specified regions.
With a stack set, you can specify the accounts and regions to which you want to deploy your lambda. You will likely want to put the lambda code in an S3 bucket that you can then reference from your CloudFormation template.
Then it is easy (and simple) to deploy to a new region--just add that region to the stack set.

How do I run a AWS Lambda function to let me know that CloudFormation has completed the entire stack creation

I would like to make an automated call to a custom program API as soon as CloudFormation has completed the entire stack creation (deployment of instances, setup of VPC, Puppet scripts, etc.).
What is the correct way to go about this?
After some research, it seems a good option would be to launch an AWS Lambda function triggered by the event that stack creation has been completed successfully, but I have no idea how to approach this.
Any ideas or advice would be appreciated.
You can provision and coordinate a lot of what you're talking about (setup of VPC, etc.) with CloudFormation, the DependsOn attribute and nested CloudFormation stacks. This way you can order the execution of the CloudFormation stacks so that, for example, your VPC is created first followed by launching your EC2 instance(s) followed by the deployment of the software on the instance(s).
You can also coordinate the execution of the other behavior you mentioned (deployment [on] instances, [calling] Puppet scripts, etc.) using AWS::CloudFormation::Init. This way, you can call out to your Puppet scripts from your EC2 instance within the CloudFormation template. The actual execution of your Puppet scripts occurs on the EC2 instance(s).
If you want to see an example of calling out to a configuration management tool from CloudFormation (in this case, we're using Chef Solo), see app-instance.json.
If you'd like to see an example of using nested stacks, see dromedary-master.json.
There's also some examples of using Lambda on our blog as well (Stelligent), but it doesn't seem like you need to use Lambda in this case based on the problem you're trying to solve.
P.S. You don't have to use nested stacks either, but it can make things a little cleaner. But, you do want to control the creation order of the resources so the DependsOn attribute will help you in doing so.