Deploy Lambda Functions in or via Bamboo - amazon-web-services

How can we deploy a set of Lambda functions using the Serverless stack via Bamboo? Is there any way to write scripts/tasks to deploy lambda functions or applications in Bamboo?

You can use the AWS Lambda Function task in Bamboo as shown here:
The link to the description how to use the task is here:
https://utoolity.atlassian.net/wiki/spaces/TAWS/pages/50004002/Using+the+AWS+Lambda+Function+task+in+Bamboo
A description of deploying the lambda function is here:
https://utoolity.atlassian.net/wiki/spaces/TAWS/pages/50003999/Deploying+to+AWS+Lambda

If the aws lambda is written in node.js, you can directly add a node js task and include your script files or even write script inline in tasks. If written using C#, you can use MS build tasks to deploy the same. I have used both of them. You can find the Node js or MS build in Atlassian marketplace. If its not suitable, you can write your own using java and deploy.

Related

How to edit lambda using the vscode aws extension (go)

I created a lambda using the web gui, using Go 1.x. Now I want to edit the code but I don't know how. I downloaded the vscode extension but it only displays the lambda, doesn't give me any options for editing.
What am I doing wrong? How can I edit the code, and ideally run it locally and debug it?
All the tutorials cover how to create a function locally and then deploy it, but for another use case, I need to do it the other way around - there's already a deployed lambda and I need to edit it and write tests for it.
I have aws-cli, sam and docker functional.
From Working with AWS Lambda Functions - AWS Toolkit for VS Code:
The AWS Toolkit for Visual Studio Code provides support for AWS Lambda functions. Using the Toolkit for VS Code, you can author code for Lambda functions that are part of serverless applications. In addition, you can invoke Lambda functions either locally or on AWS.
So, looks like you can only edit Lambda components that are part of a SAM app.

Is there a way of running AWS Step Functions locally when defined by CDK?

AWS Step Functions may be run in a local Docker environment using Step Functions Local Docker. However, the step functions need to be defined using the JSON-based Amazon States Language. This is not at all convenient if your AWS infrastructure (Step Functions plus lambdas) is defined using AWS CDK/CloudFormation.
Is there a way to create the Amazon States Language definition of a state machine from the CDK or CloudFormation output, such that it’s possible to run the step functions locally?
My development cycle is currently taking me 30 minutes to build/deploy/run my Lambda-based step functions in AWS in order to test them and there must surely be a better/faster way of testing them than this.
We have been able to achieve this by the following:
Download:
https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local.html
To run step functions local, in the directory where you extracted the local Step Function files run:
java -jar StepFunctionsLocal.jar --lambda-endpoint http://localhost:3003
To create a state machine, you need a json definition (It can be pulled from the generated template or can get the toolkit plug in for Vs code, type step functions, select from a template and that can be your starter. Can also get it from the AWS console in the definition tab on the step function.
Run this command in the same directory as the definition json:
aws stepfunctions --endpoint http://localhost:8083 create-state-machine --definition "cat step-function.json" --name "local-state-machine" --role-arn "arn:aws:iam::012345678901:role/DummyRole"
You should be able to hit the SF now (hopefully) :)
You can use cdk watch or the --hotswap option to deploy your updated state machine or Lambda functions without a CloudFormation deployment.
https://aws.amazon.com/blogs/developer/increasing-development-speed-with-cdk-watch/
If you want to test with Step Functions local, cdk synth generates the CloudFormation code containing the state machine's ASL JSON definition. If you get that and replace the CloudFormation references and intrinsic functions, you can use it to create and execute the state machine in Step Functions Local.
How some people have automated this:
https://nathanagez.com/blog/mocking-service-integration-step-functions-local-cdk/
https://github.com/kenfdev/step-functions-testing
Another solution that might help is to use localstack what is supports many tools such CDK or CloudFormation and let developers to run stack locally.
There are a variety ways to run it, one of them is to run it manually in docker container, according to the instruction get started.
Next following the instruction what's next configure aws-cli or use awslocal.
All next steps and templates should be the same as for AWS API in the cloud.

Is a single serverless yml enough for all lambda functions?

I am new to serverless framework, I used to create and write lambda codes through aws console. But I am little bit confused about the serverless framework structure. Should I need to create a serverless yml for each lambda function, Or I can use a single yml file for my whole aws lambda functions? I don't know which is the best way to start, because each api gateway end point will point to different lambda functions. Please suggest the best way to start.
My few cents here, based on some experience in the last 6 months. I started using a single Git repo with all lambda functions each in a folder. During the first 2 months, I had a single YML file to define all functions.
Then after some issues, I moved to separate YML files inside each folder for lambda function.
You can use plugins specific to each functions. In my use case, I had a NodeJS and GraphQL function for which I use Webpack for compressing the packages.
The Webpack didn't work for my other function which uses some pre-built binary for running specifically in AWS.
Not all functions need to be deployed every time. So managing in separate folders gave lot of flexibility in CI/CD and deployment version management. Otherwise, you will have releases for all functions.

Where is the visual config view in AWS Lambda?

I have been trying to look at the code that is deployed in an aws lambda.
There is an existing go function that is running in the go lambda.
However, I am not able to. AWS docs says we can look at the code through the visual config view, where is this view? This is the screen that I see, where is the view to see the code?
Please help.
Or is it because we are using a go server, only the executable which is a binary is running in the lambda and hence we are not able to see the code?
Code inline is supported only for interpreted languages (js for example) and not compiled languages.
Beside below lamda limitation, It seems console lamda editor does not support go.
However the documentation suggest to use code star.
You can also get started with AWS Lambda Go support through AWS
CodeStar. AWS CodeStar lets you quickly launch development projects
that include a sample application, source control and release
automation. With this announcement, AWS CodeStar introduced new
project templates for Go running on AWS Lambda. Select one of the
CodeStar Go project templates to get started. CodeStar makes it easy
to begin editing your Go project code in AWS Cloud9, an online IDE,
with just a few clicks.
announcing-go-support-for-aws-lambda
Q: How do I create an AWS Lambda function using the Lambda console?
If you are using Node.js or Python, you can author the code for your
function using code editor in the AWS Lambda console which lets you
author and test your functions, and view the results of function
executions in a robust, IDE-like environment
lambda-faqs
Deployment package size
50 MB (zipped, for direct upload)
250 MB (unzipped, including layers)
3 MB (console editor)
lambda limits
lambda-go-how-to-create-deployment-package
Based on the code size the AWS code editor will display the code. Since the size of the code/package is large AWS Code editor can't display the same.
But you can download the package from AWS Lambda function using export.
Kindly follow the below steps:
Go to the lambda
Select the lambda
Click on Actions
Select Export function
You will get few options. Select Download deployment package.

Deploy multiple functions using serverless creating each function with all files in it

I am working on serverless. I have created a project using serverless create. Then I have added multiple lambda functions to it. Whenever I deploy, every function is having the entire tree structure as
which is not my requirement. I used indivudually: true under package. Still no use. Please help me solve this.
Thank you...
We have accomplished similar need as follows:
"AWS Lambda Functions Code in Java 8 with Maven as dependency and build tool"
All the functions are defined in single deployment package and at project level all dependencies are controlled through single Maven.
This way, build generates one deployment bundle and same bundle can be used for all Lambda functions for confirmation, with lambda handler set differently for each function.
This has greatly reduced the deployment process.