I'm referencing this aws tutorial to deploy our lambdas cross-account wise.
I'm able to get the lambdas to deploy over successfully but I notice that if I go deploy another lambda (lambda_b), RE-USING the SAME pipeline but for a different lambda, this different lambda (lambda_b) will replace the other lambda (say lambda_a) that was deployed earlier so that at any time, I only have a single lambda within the aws console.
Could this replacement be happening because of how i'm creating the changeset?
I just don't know how to proceed or where to look to get an idea of why it doesn't deploy lambda_b without replacing lambda_a even though we're re-using the same pipeline for all lambdas.
To deploy lambda_a I had to go through all steps, 1-6 of the tutorial linked above
However, to deploy lambda_b, I only rerun step 4 and 5 of the above, is that maybe why? When I try rerunning from the beginning again, it doesn't see the changeset for step 1
In the codepipiline, cloudformation yaml file, is there a way to set a retain:true attribute or some kind of way so that I can show all the lambdas that we've deployed so far; right now, i'm only able to show the lambda that was lastly deployed since a new lambda deployment (lambda_b) always replaces the old lambda deployment (lambda_a)
I want the console to show both lambda_a, and lambda_b
Seeing as you're using CloudFormation to deploy the lambda function, when a resource (lambda_a) is removed from the template it will be deleted as part of the CloudFormation clean up step.
You need to retain both functions in the template you're deploying to have both lambda_a and lambda_b deployed at the same time.
Related
when I change something in my lambda repo and redeploy the lambda with serverless framework it make changes. I want to know the changes that going to happen prior to deploying the lambda.
I tried serverless changeset plugin, but it doesn't show a comparison between my current lambda configuration and the changes going to happen by deploying the lambda after making some changes in my lambda repo [e.g. the lambda name, tags etc.]
You can enable changesets with deploymentMethod: changesets so that serverless deploy doesn't actually execute the changes, but instead creates a changeset inside CloudFormation which you can inspect inside the console and then initiate from there.
I have AWS Glue jobs setup to upload test data to our database. Uploading takes place only 1 time and no additional runs are required unless additions or changes are required on the test data. However, we have multiple environments where the upload needs to happen. One way is to deploy the jobs using CDK and manually run the jobs in each environment. Looking for pointers to automatically trigger a run when the jobs is either updated or created.
Use a CustomResource to invoke it via command line or the Glue SDK.
It is important to remember that CDK is not a deployment solution - it is an infrastructure as code solution. CDK does not actually do any deployment - the cdk deploy command is just a shortcut for sending the template to CloudFormation.
CDK is just a way to lay code over top the creation of the CloudFormation templates and give developers far more options. All it really does is generate a CloudFormation Template - everything else is window dressing.
As such, anything that has to happen after the CloudFormation template is synthed and deployed is not possible for CDK to interact with. You need to make a custom resource that can watch for Stack Updates and when the stack is done deploying, trigger whatever else you want.
Alternatively, this is a perfect use of CodePipeline - run your cdk in the the pipeline (either with a Synth and CodeDeploy stages or a single codeBuild that just runs cdk deploy) and then in a stage after it have a lambda that triggers your jobs.
So, first go at AWS LAmbda Containers (need to deploy a "big-ish" Lambda) and we use Serverless framework for all other Lambdas and I tried it for the container as well.
It all went fine and the Lambda was created with all the expected parameters following this blog/guide: https://www.serverless.com/blog/container-support-for-lambda
Of course I had messed up the code and forgotten a module so teh Lambda didn't run in AWS.
I added the module and did a re-deploy (sls deploy) from my laptop and it writes out everything as "success" like in half a second so it is clear it is not deploying anything (I am using the --force flag as well but no difference.
The only way to get it updated seems to be to alter some code and save it and Serverless will "detect" a change and redeploy (for real).
This will cause a problem in our DevOps deploy pipeline so any way of getting it redeploying through a parameter/command?
When set up AWS code deploy to deploy an AWS service we have to provide 2 target groups lets say
TargetGroupBlue and TargetGroupGreen.
In the cloudformation template we use the TargetGroupBlue when linking the Service to Loadbalancer.
TargetGroupGreen is created only to be used by AWS during code deploy.
Step 1 : We executed create stack command in order to create the service and loadbalancer. We have a workable service now. Traffic is routed via TargetGroupBlue.
Step 2 : Then use code deploy to do another deploy which will the swap the target group to TargetGroupGreen once done.
Step 3 : Now we need to update the desired task count in service so use cloudformation update stack command. This fails because the targetgroup is TargetGroupGreen (as Code deploy changed it in step 2) and out cloud formation templates has used TargetGroupBlue for linking the service to Loadbalancer.
The workaround could be do all service related updates outside code deploy in a even numbered release (so always have to do code deploy twice so that we know traffic is always routed TargetGroupBlue)
Is this the way we should work with service updates via cloudformation and Code Deploy?
Please help to get this figured out.
Even though AWS provides many cool ways to work with when it comes to BlueGreen deploys with CodeDeploy or CloudFormation it really sucks.
The work around they suggested was to use Custom Resources in cloudformation which will actually trigger a lambda function to get the services updated cheating the cloudformation stack updates. Sample.
But there are no proper samples to do that so it would take lot of time to get it to work the way you need.
Furthermore, the cloudforamtion with hooks does not really work for bigger projects as the LBs cannot be shared.
So here is the open ticket, please help to put a thumbs up so the AWS will prioritize this in their roadmap.
https://github.com/aws-cloudformation/aws-cloudformation-coverage-roadmap/issues/483
I follow the tutorial on http://docs.aws.amazon.com/lambda/latest/dg/automating-deployment.html
The tutorial demonstrate how to automatically deploy a lambda and an API gateway using AWS cloudformation.
After some time I was able to complete the tutorial with success. This means that when I push a commit to the github repository linked to the AWS CodePipeline the changed code is uploaded/packaged to AWS -> build -> and deployed (i.e. i can see the code change)
My problem is that I tried to delete the lambda function and then invoke the Codepipeline by pushing a git commit. This trickered the codepipeline and I could watch source, build and staging steps complete successfully. However, I cannot find the lambda? I thought that cloudformation would recreate the application ? Can you help?
If you deleted the function manually then you're most likely running into this issue:
Resources that are created as part of an AWS CloudFormation stack must be managed from the same stack. Modifications to a resource must be done by a stack update. If a resource is deleted, a stack update is also necessary to remove the resource from the template. If a resource has been accidentally or purposely manually deleted, you can encounter errors when attempting to perform a stack update.
https://aws.amazon.com/premiumsupport/knowledge-center/failing-stack-updates-deleted/
You can resolve this by manually recreating the resource with the same name, then allowing CloudFormation to manage the resource in future.
The reason why I did not see any lambda function was because I only created the change set ("create or update change set") and missed to add the actual deploy stage "execute change set".