How to look up AWS Document DB using Terraform AWS Provider? - terraform

With an RDS instance, metadata regarding the instance can be obtained via terraform scripts using aws_db_instance data source. However, this doesn't exist for document db. My goal is to look up the endpoint of a document DB by its name. Does anyone know how this can be done?

Related

Database migration from AWS Aurora Serverless v1

We have a plan to create a new application, which won't have the same architecture of the current one, and will definitely have some differences in the tables' schemas. Our current application's database is running on a AWS Aurora Serverless v1 cluster, with MySQL 5.7. We need to migrate data from the old application to the new one, making some schema changes in some places.
One solution is to create dumps of the old tables, in an easily readable format like csv, then import the data in the new application, picking the data as needed. This will require writing bespoke code on both applications to export data from one and import it into the other.
Considering that we are in AWS, and we intend to keep using it, choosing Aurora as a database (we'll have to decide whether use a provided solution or go with Serverless v2), is there any service to export data from one Aurora Serverless v1 cluster to another Aurora cluster, making changes along the way?
I know that database snapshots exist, but that's not exacly our goal. We need to migrate data from one database to another, not creating another copy of the first one. I've seen that there is a service, called "AWS Database Migration Service", that's used to migrate data into RDS, but does this service suit our needs, to get data from one Aurora Serverless database, do some changes, and then put it into another RDS database of our choice?
You could use following options to accomplish your goal.
1.- AWS Database Migration Service, this service provide you capabilities to replicate your data and also perform some schema transformation during replication process. You can create selection and transformation rules, the service will execute those rules and apply changes to the target schemas. You could review more details on this link.
https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.CustomizingTasks.TableMapping.SelectionTransformation.Transformations.html
2.- AWS Glue Studio, it is ETL service that allows you extract, convert and transfer data between source and target databases.
What is AWS Glue Studio?
Automate ETL jobs between Amazon RDS for SQL Server and Azure Managed SQL using AWS Glue Studio

Move a schema from one AWS RDS to another

I need to move schema and its objects from one AWS RDS to another AWS RDS db.
I have used AWS schema conversion tool (SCT) in the past.
Is there any other better way or what I am doing is the best.
Thank you,
AWS Database Migration Service (AWS DMS) will help you to migrate databases to AWS quickly and securely. The source database remains fully operational during the migration, minimizing downtime to applications that rely on the database. The AWS Database Migration Service can migrate your data to and from the most widely used commercial and open-source databases.
Here is the reference link which will help you to guide further for AWS DMS

Fetching keys from AWS Secret Manager

I am trying to fetch my Secret keys and Id( to access aws dynamo db ) from AWS Sceret Manager.
What I am able to do:
access the dynamo db table with python script locally.
access the dynamo db table with python flask local server.
(This case it can do because .. i think .. it is able to fetch my details from the aws/credentials )
What I am not able to do:
access the dynamodb table with chalice (an aws flask like microservice)
access the dynamo db table from my Nodejs project locally.
What I want to do:
I have a website code written(in nodejs) and deployed(with aws). now I want to access the aws dynamo db from my nodejs code (which I was not able to do) even locally.
So I thought of making a python Api and deploy in AWS and then access the api end point from node. BUt I couldn't access the dynamo db from the chalice api Chalice.
If there is way to access the credentials from nodejs and if it even works when deployed. It would be amazing.
If you find this question not appropriate please correct me. I am noob in this.
Thank you in advance.
Where is your code actually running? EC2? Why not create a role for your EC2 instance and grant it the appropriate DynamoDB permissions through the role?
It's not good practice to store AWS IAM credentials in Secrets Manager when you can just grant permissions through roles.

terraform script to create mysql schema and load data

I created the RDS Aurora database in AWS management console. I have the sql script on mysql schema and insert statement.
I created the terraform script on the database creation, and next is to use terraform to create mysql schema and load data. My question is do I use terraform script to create mysql schema and load data? I am not clear on that.
You can try to use terraform to create your mysql schema, and load data, by leveraging terraform provisioniner: https://www.terraform.io/docs/provisioners/index.html
For example, you can execute remote scripts with remote-exec. This
You should be aware that terraform core capabilities is to provision infrastructure. Configuring and managing services is better achieved with specialized tools.

Amazon RDS - How to Create new DB using PHP API?

In a SAAS app, written in PHP, how to create a new mysql database in an existing RDS instance?
The documentation for php api here:
http://docs.aws.amazon.com/aws-sdk-php/guide/latest/service-rds.html
doesn't show any such function available under available operations section at the bottom.
How do we do that??
There is no such option provided in RDS API. When you call CreateDBInstance API, you can specify the DBName but that is at the time of creating a new RDS instance. Once you have created the instance, then there is no provision to create a new DB on it.
I would imagine you need to connect via PHP using ODBC (or whatever that PHP supports) to the RDS endpoint and then create a new DB just like you are connecting to a non-RDS remote DB.

Resources