can I add custom nested CloudFormation stack to AWS Amplify OR can I create a custom Lambda function/SQS with GraphQL/AppSync? - aws-appsync

Spending more than a day I doubt the answer is Yes.
Want to double check though.
Creating Lambda functions is possible with REST APIs. But I need it with GraphQL. As I understand, currently creating Lambda function from CLI for GraphQl is not supported - right ?
In my app one party places an order => mutates DynamoDB table Orders => DynamoDB triggers a Lambda function that in turn mutates DynamoDB table Offers (changes offer's status). This change should notify subscribed parties.
I could do it in a separate Lambda function or in a Lambda function that serves as a Resolver. But either way I do not see a way of doing it using AWS Amplify.
Resolver Lambda function should also be manually added in console (providing Lambda ARN). Is there a way of adding it using CLI or config files or nesting a CloudFormation stack template ?
I know I can do all manually in console. But I need to find a way using AWS Amplify so that I have a parent and nested CloudFormation stack templates.
Possible workaround I see is:
setting up GraphQL API using AWS Amplify;
setting up rest of the serverless environment with AWS SAM or Serverless Framework;
have to manually connect (in console) Lambda and SQS with AppSync's DynamoDB.
Is my understanding correct? Is there a better way than this workaround ?
I am building my front end app in React. This AWS Amplify page shows how resources such as SQS can be created for iOS. Is there anything similar for React ?
Thank you

Related

How to pass values between CDK stacks deployed in different accounts within a CDK app?

Reading from the documentation, the suggestion for passing values between CDK Stacks within an app is to simply pass the value.
If the two stacks are in the same AWS CDK app, just pass a reference between the two stacks. For example, save a reference to the resource's construct as an attribute of the defining stack (this.stack.uploadBucket = myBucket), then pass that attribute to the constructor of the stack that needs the resource.
But it seems this only works if the CDK stacks are within one account.
Upon checking the generated templates, it generates a stack Output and Input and uses that for the passing values. And stack input and outputs does not work beyond the account they are created on.
What's the recommended way to pass values from stacks deployed in different accounts?
I don't think you can think about this as being a single CDK application. Such a single application is intended to be deployed in a single account. What you are trying to do is use this application construct to deploy two different stacks in two different environments and share data between them. However, you are bound to the same restrictions that CloudFormation itself has when it comes to sharing data from services that have been deployed in the stack. So you'll have to work around this issue.
So I don't think there is any recommended way of doing this, but maybe you can create some cross-account roles that allow writing/reading from the SSM parameter store and combine this with custom resource lambdas to read/write the data from/in the SSM store of the other account. Given this, it might be easier to just write some CICD tooling that does this without needing any AWS services and which just passes on the value from the output of one stack to the input of the other stack during deployment.

call AWS POST API with AWS Signature Version 4

did someone already called an AWS Rest API with AWS Signature Version 4 ?
I'm not sure how to generate this using the hierarchical stage Calling the Rest API ?
Thank You -
what do you mean by hierarchical stage, do you want to build the whole signature on your own?
Which language are you trying to call it with? There are different packages depending on that, I highly recommend using one of those instead of rebuilding it on your own.
agnostic-aws-signature This worked for me for example...

Use an existing DynamoDB datasource with Amplify and AppSync

I have a working app I made using Amplify (with AppSync API and Cognito). I'd like to make another app which is different, but shares some data with my first project (same product, but different targets, usages and security rules).
Is there a clean way to use Amplify for that new project, telling the GraphQL API to fetch some data in the DynamoDB from my first Amplify project ?
This data will change often and will be heavy - so I'm not too much into any synchronization solution.
I thought about those solutions, but I'm not experienced enough to tell if one of them is good:
Not using Amplify but SAM for this new project (but I will lose all the build pipeline provided by Amplify)
Using Amplify for the Hosting and the Auth, but configure AppSync with SAM and plug it into my existing DataSource
Maybe CloudFormation can be the answer, but I don't see how to interact directly with it within Amplify
There is an article from Amazon about microservice architectures that might be useful for you
https://aws.amazon.com/blogs/mobile/appsync-microservices/
I'm not sure if Amplify supports adding multiple APIs to it, if so, you could add it and then pull only that api on it.
IMO the easiest approach would be just creating a query endpoint to fetch the data from your other datasource, using lambda.
So, in that case you would edit your schema to something like this
query
{
externalData [ExternalData] #function(name: "getExternalData")
}
Then you need to add the lambda function getExternalData, which will be responsible to query the data as needed.
The article above has more in-depth details about this architecture

Does IBM Compose provide a REST API to trigger a backup?

I want to programmatically trigger a backup in an IBM Compose database.
Is there a REST API available for that?
From within Bluemix, no - there is no API available. Compose is looking to make the traditional Compose UI available from within Bluemix over the course of the next few months, at which time it will be. The documentation for the API can be found here: https://apidocs.compose.com/ (linked from https://help.compose.io)

Amazon API Gateway to lambda to rds?

I am trying to have a mobile app access an amazon rds postgres instance. Referencing https://stackoverflow.com/questions/36103629/is-it-posible-to-query-an-amazon-rds-instance-directly-from-api-gateway#=, Mark said "You should look into pointing API Gateway at a Lambda function that has the ability to connect to your RDS database and run queries." So my question is could I implement this approach using this link: http://docs.aws.amazon.com/lambda/latest/dg/vpc-rds.html and then using api gateway to point at that lambda function? Then any mobile client with credentials from cognito would be able to call that api? Am I correct and is this the best way? My worries is that since a VPC is involved, only a small number of people will be able to use the lambda function.
Yes you could use the technique listed in your link (which is exactly what I was referring to in my other answer that you reference) and then expose that Lambda function via API Gateway. This is (one of ) the correct ways to accompolish this.
My worries is that since a VPC is involved, only a small number of
people will be able to use the lambda function.
I don't understand what you are saying here. Why would use of a VPC restrict the number of people that could use the Lambda function?