Get all field names(attributes) from DynamoDB using amazion java SDK - amazon-web-services

I am new to Amazon SDK.
My requirement is to fetch all the field names(attributes) from DynamoDB cloud and print it on the console.
Can anybody help me out?
Thanks in advance.

You can also use a mapper (similar to Hibernate in relational databases) which is a layer over the client.
This is the official page: http://aws.amazon.com/articles/3756417425850538
Besides, when you create the tables in the console, you must define the indexes (hash, range, local, global or range index) and whether to project all attributes or only some.

Related

Restoring a DynamoDB table using PITR and updating Cloudformation/CDK/other services references

I have an environment where my DynamoDB table is central to a few services (a couple of lambdas, kinesis and firehoses). All of that is managed by AWS's CloudFormation/Typescript CDK.
This table has PITR enabled and, as far as I know, it's only possible to do a PITR by dumping the recovered data into a new table. Here is where the pain begins:
AWS's documentation after the creation of the new table is INEXISTENT!
How can I update the references for the new table on all other services?
Should I just 'erase' my old table and import the recovered ones?
Wouldn't this means that I would need to take my service down to recover it?
What is the "standard" or "best practice" here?
Thanks a lot community! :D
You must restore to a new table yes. There are some ways to overcome the issues you describe. Firstly, when you restore to a new table you will need to import that resource to your CDK stack.
Parameter Store
Use the parameter Store to hold the latest name of your table, all of your down stream applications will resolve the table name by querying the param store.
Lambda Env Variable
Set your table name dynamically as environment variables for your lambda, this will reduce latency as opposed to the other approach, but it's only applicable to Lambda or services which allow you to set env variables.
Inline Anwers for Completeness
AWS's documentation after the creation of the new table is INEXISTENT!
Please share feedback directly on the docs page if you believe relevant information is missing.
How can I update the references for the new table on all other services?
2 options mentioned above is the most common approach.
Should I just 'erase' my old table and import the recovered ones?
This would cause application downtime, if you can afford that then it would be an easy approach. If not, follow the above suggestions.
Wouldn't this means that I would need to take my service down to recover it? What is the "standard" or "best practice" here?
Yes, as mentioned above.

Is it possible to retrieve the Timestream schema via the API?

The AWS console for Timestream can show you the schema for tables, but I cannot find any way to retrieve this information programatically. While the schema is dynamically created from the write requests, it would be useful to check the schema to validate that writes are going to generate the same measure types.
As shown in this document, you can run the command beneath, it'll return the table's schema.
DESCRIBE "database"."tablename"
Having the right profile setup at your environment, to run this query from the CLI, you can run the command:
aws timestream-query query --query-string 'DESCRIBE "db-name"."tb-name"' --no-paginate
This should return the table schema.
You can also retrieve the same data running this query from source codes in Typescript/Javascript, Python, Java or C# just by using the Timestream-Query library from AWS's SDK.
NOTE:
If the table is empty, this query will return empty so, make sure you have data in your db/table before querying for it's schema, ok? Good luck!

Issues while working with Amazon Aurora Database

My Requirments:
I want to store real-time events data coming from e-commerce websites into a database
In parallel to storing the data, i want to access the events data from a database
I want to perform some sort of ad-hoc analysis(SQL)
Using some sort of built-in methods(either from Boto3 or JAVA SDK), I want to access the events data
I want to create some sort of Custom-API's to access events data stored in database
I recently came across with Amazon Aurora(mysql) database.
I thought Aurora is one of the good example for my requirements. But when I dig into this Amazon Aurora(mysql), I noticed that we can create a database using AWS-CDK
BUT
1. No equivalent methods to create tables using AWS-CDK/BOTO3
2. No equivalent methods in BOTO3 or JAVA SDK to store/access the database data
Can anyone tell me how i can create a table using(IAC) in AURORA db?
Can anyone tell me how i can store realtime data into AURORA?
Can anyone tell me how i can access realtime data stored in AURORA?
No equivalent methods to create tables using AWS-CDK/BOTO3
This is because only Aurora Serveless can be accessed using Data API, not regular database.
You have to use regular mysql tools (e.g., mysql cli, phpmyadmin, mysql workbench etc) to create tables and populate them.
No equivalent methods in BOTO3 or JAVA SDK to store/access the database data
Same reason and solution as for point 1.
Can anyone tell me how i can create a table using(IAC) in AURORA db?
Terraform has mysql, but its not for tables, but users and databases.
Can anyone tell me how i can store realtime data into AURORA?
There is no out-of-the box solution for that, so you need custom solution for that. Maybe stream data to Kinesis Streams or Firehose, then to lambda and lambda will populate your DB? Seems easiest to implement.
Can anyone tell me how i can access realtime data stored in AURORA?
If you stream data to Kinesis Stream first, you can use Kinesis Analytics to analyze it in real time.
Since many of the above requires custom solutions, other architectures are possible.
Create connectoin manager as
DriverManager.getConnection(
"jdbc:mysql://localhost:3306/$dbName", //replace here with you endpoints & database name
"root",
"admin123"
) then
val stmt: Statement = con.createStatement()
stmt.executeQuery("use productcatalogueinfo;")
Whenever your lambda is triggering then it performs this connection and DDL operations too.

Access Creation date for Dynamo DB table using golang SDK

I need to access the creation date field for the dynamo db table as part of the golang SDK. Does anyone have any idea how to do this?
It is possible to get the Table creation date using DescribeTable API. Please refer AWS Doc for more information.
Go SDK has API to DescribeTable.
Use the "CreationDateTime" property in the output.

How to describe domains in AWS SimpleDB?

Is it possible to do an SQL-like describe tables statement with AWS SimpleDB and if so, what's the syntax. The same for show tables or whatever the equivalent of that might be.
If you know of a resource that explains all of this, please tell me where it is, because I can't find the information I'm looking for.
Edit
I came across a SimpleDB query that someone else wrote in something that I'm working on. It looks something like select A, B, C from MyDomain where D = 'SomeVal'.
I didn't create the database so I don't know if this SimpleDB has the data that I need. I'd like to find out just the column names that MyDomain contains/accepts. Is that even possible?
Solution
Oh, I suppose I could just select * from MyDomain limit 1 and then print out then print out each from getName() in the attribute list.
There is noting similar to describe tables in Amazon SimpleDB. Amazon SimpleDB concept is different from traditional database. Amazon SimpleDB is non structure database service. Amazon SimpleDB requires no schema, automatically indexes your data and provides a simple API for storage and access. Amazon SimpleDB provides flexibility to add new attributes that only applies to certain rows. Therefore, each row may have different-different attributes. To learn more about service - doc & related links