Using DynamoDB from CakePHP 3 installed to Elastic Beanstalk - amazon-web-services

I have installed CakePHP 3 using directions from this tutorial:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/php-cakephp-tutorial.html
It is working perfectly and actually installation was quite easy. There is PHP, CakePHP, MySQL working and also I noticed that the newest AWS SDK as whole is installed in vendor directory. So I am fully set to use also DynamoDB as my data source. You might ask why I should use DynamoDb since I am already using MySQL/MarianDB, this is because we have an application that is already in production and it is using DynamoDB. But we should be able to write admin application using CakePHP in top of DynamoDB. This is not technical decision but coming from business side.
I found good tutorial written by StarTutorial how to use DynamoDB as session handler in CakePHP 3:
https://www.startutorial.com/articles/view/using-amazon-dynamodb-as-session-handler-in-cakephp-3
Well, there is not long way to using DynamoDB for putting data, getting data and doing scans, isn't there? Do you have any simple example how to do it, how to write data to DynamoDB or do scan?
I have also read the article:
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.PHP.html
and this is working fine, no problem. But I would like to all the advantages of the CakePHP 3, templating, security and so on, thousands of hours time saved with well written code and very fast to start coding for example admin console :)
Thank you,

You could create a Lambda function (in case you want to go serverless) or any other microservice to abstract communication with your DynamoDB. This will definitely simplify your PHP code. You may call Lambda functions directly (via API Gateway), or post messages to SQS for better decoupling. I would recommend the use of SQS -- you'll need some kind of microservice anyway to consume messages and deal with your DynamoDB in a CQRS fashion. Hope it helps!

Thank you for your answer, I was looking for a example how to use the AWS SDK for DynamoDB without creating more complexity to this environment as it is. This way I would have to create yet another layer without using the SDK that already exists. Can you please give wokring example how AWS SDK is used from CakePHP 3 so that it can use DynamoDB as a data source for its applications without losing it´s own resources an capabilities (MVC, security etc).
Thank you,

After a hard debug and found bugs I was able to get it working with only using AWS SDK in CakePHP 3.

Related

AWS hosted application need autosuggest & wild card search feature

I 'm not sure if this is the correct platform to ask architecture related question, actually I have a webapplication developed in nodejs & typescript hosted in AWS, and the backend is mongodb and my requirement is to include a search box with wild card & auto suggest search functionality so when I start typing on the text box, it will autosuggest just like we do in google search, so how would I achieve this, querying everytime to mongodb will be kind of slow and if 100's of user start doing that, then my application might start dangling so need your suggestion.
Not tried as this more of architecture help required
Not tried as this more of architecture help required
It's not a very detailed answer but may point you in a direction.
I just built something similar using AWS Lambda, ElasticSearch and API Gateway.
ElasticSearch is great for text searches but needs to be populated with indexed data.
If your dataset is changing, you will have to remember about updating ElasticSearch.
API Gateway routes requests from HTTP to Lambda, of which there are two:
one for analysing data in my data warehouse and producing indices for ElasticSearch, the other for doing the actual search and returning results.

Group Chat Solutions With AWS

EDIT: The original question asked for a real-time solution. I am not sure this is necessary. It should be about as fast as sending a standard SMS text message.
I want to integrate group chat in my android / ios app. There is a similar question found here, but the answers are old and I would like to see if there are any new / better solutions.
I am currently using multiple AWS services in my app, and would like to keep my chat solution in the same ecosystem. However, if there is a solution outside of AWS that is much easier to implement with good results, I am open to the suggestion.
Based on my research I have come across a couple of possibilties:
This AWS blog lightly covers using ElastiCache for this purpose
This LinkedIn slideshow demonstrates the possibility of using AWS IoT
Requirements for my chat:
Would like to be able to support up to 500 people per chat group
Usable from the web via online portal that has the same general functionality as the mobile app
Needs to be scalable to handle thousands of groups
Needs to handle emojies (cross platform)
Needs to allow for file transfers. Images and GIFs at the very least.
Send push notifications to users who have elected to recieve them when they are not currently active in the group
Are either of my possiblities a good fit for my requirements? Which would be the easiest to implement? Are there other, easier solutions inside of AWS? Outside of AWS?
Take a look at https://github.com/tinode/chat
It's not a 100% what you want but close. There is a third-party DynamoDB adapter for it: https://github.com/riandyrn/chat
I am posting this answer to close the question. I ended up switching from AWS to Google Firebase in order to use the Real Time Database.
There is a chat example here that might help anyone that stumbles onto this question.

Google Authentication with Dynamodb instead of mongoose

I have been following this tutorial and it has given me great insight into linking up a mongodb and getting back google authentication. However, I want to use dynamodb, and I found this to hook up a localhost dynamodb to test out my theories, but I am not sure how to swap out mongoose - because I don't want it linking to a mongodb, or can I use mongoose for the schema and tell it to write to a dynamodb? Not sure. Thanks for any guidance in advance. I'm new to aws if you can't tell.
Mongoose is a library for connecting to MongoDB. I believe your question title should be "DynamoDB instead of MongoDB".
You can't use Mongoose to connect to DynamoDB. There are many differences between MongoDB and DynamoDB. If you want to use DynamoDB with your NodeJS application you should look into using the AWS SDK for NodeJS.
Please be aware that there are major differences between MongoDB and DynamoDB. It's not going to be trivial to take a MongoDB tutorial and modify that to work with DynamoDB. I highly recommend you read up on DynamoDB and understand its restrictions and limitations before committing to using it.

What is the "proper" way to use DynamoDB for an iOS app?

I've just started messing around with AWS DynamoDB in my iOS app and I have a few questions.
Currently, I have my app communicating directly to my DynamoDB database. I've been reading around lately and people are saying this isn't the proper way to go about getting data from my database.
By this I mean is I just have a function in my code querying my Dynamo database and returning the result.
How I do it works but is there a better way I should be going about this?
Amazon DynamoDB itself is a highly-scalable service and standing up another server in front of it requires scaling the service also in line with the RCU/WCU configured for your tables, which we can and should avoid.
If your mobile application doesn't need a backend server and you can perform all the business functions from the mobile device, then you should probably think about
Using the AWS DynamoDB SDK for iOS devices to write your client application that runs on the mobile device
Use AWS Token Vending Machine to authenticate your mobile users to grant them credentials to be used to run operations on DynamoDB tables.
Control access (i.e what operations should be allowed on tables etc.,) using IAM policies.
HTH.
From what you say, I can guess that you are talking about a way you can distribute data to many clients (ios apps).
There are few integration patterns (a very good book on this: Enterprise Integration Patterns), one of which is called shared database. It is essentially about using a common database for multiple clients to share the data. Main drawback for that pattern (in your case) is that you are doing assumption about how the database schema looks like. It can potentially bring you some headache supporting the schema in the future, if your business logic changes.
The more advanced approach would be sending events on every change in your data instead of directly writing changes to the database from client apps. This way you can add additional processing to the events before the data they carry is written to the database. For example, you may want to change the event format in the new version of your app, but still want to support legacy users, so you add translation procedure which transforms both types of events to the format which fits the database schema. It's basically a question of whether to work with diffs vs snapshots.
You should be aware of added complexity of working with events, and it can be an overkill if your app is simple and changes in schema are unlikely.
Also consider that you can do data preprocessing using DynamoDB Streams, which gives you some advantages of using events still keeping it simple to implement.

building an amazon store with drupal 7

I've been playing around with an idea for an amazon store with Drupal 7. I do a lot of product reviews, and I typically link to amazon pages already (without referrer IDs, since I wanted toa void any questions of integrity all together), but having a seperate storefront link, well I'm playing with the idea.
I'm using Drupal 7, and I installed the Amazon API and Amazon Store module. It uses an Amazon AWS account and amazon associates ID. Basically creates a light storefront that does all the lifting through amazon itself. It only even uses Amazon items, which is fine since what isn't on Amazon, and only gives you a referral payout.
Well, what I'd love to do is have a stronger control over the items in the store. The Amazon Store module just gives you the option to control the basic items that are visible upon loading.
What I'd like to do: Create a store where categories match the contents of my site, and disable the search options. Is this possible with these modules? Does anyone have advice on creating something like this?
please see the below module and I hope it will be handy
https://drupal.org/project/amazon_store