Connect to a RDS Database using IAM in a PHP application - php

I have developed an application using the PHP SDK for AWS. It is hosted on AWS also.
I have written a connections file, detailing all the variables and credentials required to connect to the DB, and this works fine.
However, in terms of security I was wondering if it is possible to use an IAM Role, as that is what I am using to connect to the EC2 instance, so that I am not explicitly defining the credentials?

Related

How to upload a PHP file on Azure

Right now I have a localhost database using WAMP server.
I connect and insert data to this DB by making a POST request to the file's PHP link (e.g localhost/sensor_data/connect_To_DB_And_Insert_Data.php).
I want to do the exact same thing with Azure SQL so my database won't be local anymore but on a remote server.
I have already created a database but I don't know how to upload a PHP file that can be accessed online using a link. There are so many documentations that I'm kind of lost and I didn't find an answer to this yet.
So my question is, how do I upload a PHP file on Azure, that it can be accessed by a link, so I can insert data to the database by making a post request to that link ?
Firstly, you just need to change the connection string in your PHP code. Then your PHP application will be able to connect to Azure SQL. In this way, you do not need to create any Azure host server (Web app or VM).
You can get the connection string on Azure portal:
Attention, as Azure SQL has enabled firewall. So, if you want to connect to it from your local server, you need to add your IP to the allowed IP list
However, as #UkraineInTheMembrane suggested in the comment, you can also to use Azure Web App or VM to host your PHP application.
With Azure Web App, here is a get-started tutorial for PHP: Create a PHP web app in Azure , in this tutorial, git is used to manage your code.
There are also many other approaches to upload your code to azure web app: https://learn.microsoft.com/en-us/azure/app-service/deploy-zip

Anyway to connect to external databease from GCP ? (From PHP - Laravel app)

I want to "use Google Cloud SQL Proxy to connect to another vendors database"
(Vendor's database is not stored in GCP, It's simple mysql database hosted in another server)
since I have to update data in vendor's database, my project stored in GCP (hosted separate from vendor's) so:
Is there anyway to connect to external database from GCP app (Laravel 5) Or any other way to solve it except developing web APIs (vendor won't prepare us the APIs since some contract/budged reasons) ?
After I tried to connect to the external DB (set connection in both .env and config/database.php), then the error message alert like:
Access denided #'cloudsqlproxy'
PS. My project can connect to vendor's database as usual from localhost but after deploy to GCP then 'cloudsqlproxy' error's occur.
I'm a newbie one for GCP so
thank you for all community's help,

Deploying application in elastic beanstalk AWS

I created multiple REST api's for my website on a local server(wamp) and now i am trying to move it to a online server(aws elastic beanstalk). My question is where do i build my database with the tables and rows etc just like in phpmyadmin? I figured that "upload and deploy" means upload the php file i made but when i do i get an error saying "health degraded". So what i want to do is basically move my local server to an online one with aws EB. I watched a bunch of videos and did a lot of research but can't seem to find the way to go about this problem.
My question is where do i build my database with the tables and rows
etc just like in phpmyadmin?
You can connect to the RDS instance created by beanstalk using a Database Management Client Tool like MySQL Workbench, Heidi SQL & etc using the DNS name, created for RDS instance. However one challenge you will face is to access the RDS instance from your client machine, since its not a good practice to make the Database publicly accessible. You can create a EC2 instance (Windows or Linux with GUI) inside the same VPC, connect to it (Remote Desktop or SSH) and install the tools so that you can use the tools inside the server, to connect to the RDS instance.
I figured that "upload and deploy" means upload the php file i made
but when i do i get an error saying "health degraded"
To understand the structure in code inside the Zip file, I would recommend to create a Beanstalk environment with a sample project available in Beanstalk and download the sample project artifact (Zip file) from S3 so that you can compare the project structure requirements.
If you prefer to go through the documentation, you can refer this. If nothing goes well, connect to the ElasticBeanstalk provisioned EC2 instance (Either using Remote Desktop for Windows or SSH to linux) and investigate the deployed artifacts.

Cannot connect to Sql Server in Amazon RDS with Codeigniter

I have an application that has been developed with Codeigniter. It uses an SQL Server database, hosted in an Amazon RDS Instance.
The application is using the mssql driver (I can't change it to sqlsrv, unfortunately).
The RDS instance is ok, I tried connecting to the database from an SQL Server client, and everything works perfect, but when I try to connect it in the CI application, I get the classic "Unable to connect to your database server using the provided settings." error.
Is there a way to have a more descriptive error thrown by CI? I have lost a lot of time trying to solve this issue and I really don't know what else I should look.
Notes:
This was working fine some days ago. I had to make a copy of the CI app (which is hosted on an Amazon EC2 instance). I shared the AMI to a different AWS account, and created a new instance with it, but didn't change anything in the volume. Everything has been exactly copied from one place to the other.
Php info tells me that the mssql driver is there and it is correct.
The Security Groups in the RDS instance and the EC2 instance, are open to the world (I deleted all the restrictions in order to see if that was the problem)
I will really appreciate any kind of help.

Best way to access SQLite database on AWS EC2 server from iOS app?

I have a web server set up on an EC2 instance where I have a SQLite database stored. For testing purposes, I currently have a PHP file that I can hit by sending an NSURLRequest to http://<my-instance-ip>/foo.php, where the script will access the SQLite database and return the information in JSON. Would I want to do the same thing in a live application or am I thinking of this completely the wrong way? I'm new to AWS so I'm not too sure about how these services are used.
If the database is for all your app users, you should use mysql or other full functional database, and use php to write web services.
If the database is for a single user, you can just store the sqlite data in the device, and use fmdb to access it

Categories