Appsync operations Lambda Layer tutorial issue - amazon-web-services

I am following the tutorial from AWS here: Functions - Exporting AppSync operations to a Lambda layer for easy reuse - JavaScript - AWS Amplify Docs to create a Lambda Layer for my AppSync graphql operations to use in other Lambda functions.
In following the tutorial, when I get to the part of running the codegen from the script in packages.json, it runs through but finishes with the message:
Successfully compiled 0 files with Babel (9ms)
It looks like everything is pointing to the correct locations. I have also tried specifying extensions in my the script command for babel. Here is my script added to packages:
"updateAppsyncOperations": "amplify api gql-compile && amplify codegen && babel src/graphql --config-file ./babel.config.json -d ./amplify/backend/function/my_function_name/opt/graphql/"
where my_function_name is the name of the Lambda Layer function.
Has anyone run though this tutorial and got this to work successfully? I cannot figure out why it is not adding my mutations.js, queries.js and subscriptions.js to the Lambda Layer graphql folder.

Related

Can a Amazon States Language json file be generated from CDK step functions TS file

If I have a CDK *.ts file that defines my AWS Step Functions, is it possible to generate an Amazon States Language asl.json file that I can use it to visualize that step function process (using the AWS Toolkit for VS)?
I took a look at: Is there a way of running AWS Step Functions locally when defined by CDK?, Is there a way to create step functions graph using CDK?, and the AWS CDK for Step Functions: https://docs.aws.amazon.com/cdk/api/latest/docs/aws-stepfunctions-readme.html but none of those resources indicated a process to generate that asl.json file. The AWS Step Function module has an Import, what I am looking for is essentially, the reverse or an Export.
AWS Toolkit for Visual Studio Code supports visualization of CDK state machines. Run cdk synth then the state machine resource will appear in the CDK explorer. Right click on it to display the graph.
This may not be exactly what your looking for, but check out this Question and Answer.
From this you would be able to get the Amazon State Language JSON of your state machine that is defined in your CDK *.ts file and do whatever you want with it upon deployment.
If you wanted to see the JSON that is created just to visualize it though, you can always go to the AWS Console > Step Functions > [Your State Machine] > Definition tab, to see the asl.json

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.

Dynamically append function to AppSync Pipeline Resolver via CloudFormation

I am currently developing an AppSync based API in a domain driven manner, so we need to put a function to an already created Pipeline Resolver. Does anybody know if there is there any chance doing this via CloudFormation without using a custom resource?
Thanks in advance, Sven
Terraform can do this neatly if you can build this pull request yourself or vote in this issue to get it merged into a public release.
The new syntax is described here.
The build process is actually quite simple. It took me about 30 min end-to-end.
Install GoLang.
Clone the repo with the changes and sync it with the main (upstream) repo.
Make sure you cloned it into go\src\github.com\terraform-providers\terraform-provider-aws folder.
Run go build from go\src\github.com\terraform-providers\terraform-provider-aws
Replace .terraform\plugins\...\terraform-provider-aws-* executable with the one you compiled.
Run terraform init
Test by trying to import a function terraform import aws_appsync_function.example xxxxx-yyyyy
I hope the pull request gets merged by the time you read this.

Deploy Lambda Functions in or via Bamboo

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.