Enabling bulk admin privilege in amazon rds? - amazon-web-services

I wanted to setup an RDS instance store data for reporting. I have scrips that run different rest calls against certain sites that require bulk admin privilege on the back end because they dump their rest call data into a csv and then do a bulk csv insert into Sql Server SE. In my local environment setting up a user for my scripts to use with bulk admin privileges was easy. However, I couldn't seem to figure out how to do it in RDS. I opened a ticket with Amazon and they suggested writing a policy for it. So I figured I would ask here if this is possible and possible alternatives? If bulk/system admin privileges are out of the question in RDS I guess I will just have to use an AWS EC2 instance with Sql Server set up on it.

Bulk insert is not possible with RDS. The data_file parameter of the BULK INSERT command must refer to a file accessible by the machine running SQL Server.
Also, RDS does not support the bulkadmin server role.
Supported SQL Server Roles and Permissions
Importing and Exporting SQL Server Data

Related

Superset with Athena: set workgroup based on user role

I'm working at a company that used to use AWS Athena and Quicksight to run sql queries and create dashboards, but now we have to use Apache Superset to do this.
While all users was using aws console, I could get Cloud Trail logs to send to the managers some reports of data consumption based on Athena workgroups or even idetify users that ran heavy queries, but since we migrate to Superset I lost the trace of user and workgroup because all queries are run using the same Athena connection...
Is this possible to pass the Athena workgroup based on user role (and maybe the username too) throught the conector?
I tried to find something on superset docs, but didn't find anything :(

Google Cloud SQL shared or individual database user accounts when using cloud-sql-proxy

Since the cloud-sql-proxy already forces individual user authentication with the database through a users iam account, and allows specifying read / write permissions, it seems potentially pointless to also have an individual database accounts for each user as well.
For security, is it necessary to have a database user per dev when using cloud-sql-proxy, or is it fine to just have one database user, since they are already authenticated by the time they can enter a database user / password anyways. I'm not a server dev or a DBA, so I thought it best to ask.
In fact, you have 2 levels of permissions
Cloud IAM allows you to access to Cloud SQL product or not
Database user management allows to log into the db engine and to get the db engine permission (access to a specific schema, one schema per developer, on the same SQL instance for instance).
The hosted database engine are based on MySQL, PostgreSQL or SQL Server. All those databases have their legacy user authentication in place. You have to deal with.

Using EC2 instance profile with IAM authentication in RDS

I set up IAM authentication on an RDS instance, and I'm able to use IAM to get database passwords that work for 15-minutes. This is fine to access the database for backups, but this database backs an web application so currently after 15 minutes the password used by the app to connect to the DB becomes invalid and the app crashes as it can no longer access the DB.
However, in the RDS IAM docs there's this line:
For applications running on Amazon EC2, you can use EC2 instance profile credentials to access the database, so you don't need to use database passwords on your EC2 instance.
This implies that on EC2 there's no need to use the IAM temporary DB password, which would mean that my app should be able to connect to the DB as long as it's running on EC2 and I set up the role permissions (which I think I did correctly). However, I can't get my app running on EC2 to be able to connect to the RDS DB except by using the 15-minute temporary password. If I try connecting with a normal MySQL connection with no password I get permission denied. Is there something special that needs to be done to connect to RDS using the EC2 instance profile, or is it not possible without using 15-minute temporary passwords?
According to the documentation you linked (http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html), you need to perform the following steps (See under "Authenticating to a DB Instance or DB Cluster Using IAM Database Authentication"):
Use the AWS SDK for Java or AWS CLI to get an authentication token you can use to identify the IAM user or role. To learn how to get an authentication token, see Getting an Authentication Token.
Connect to the database using an SSL connection, specifying the IAM user or role as the database user account and the authentication token as the password. For more information, see Connecting to a DB Instance or DB Cluster Using IAM Database Authentication.
That means for every connection you intend to open, you need to get a valid Token using the AWS SDK. This is where using the correct instance profile with the RDS permission is needed. See also the code examples further down the AWS documentation page.
I think however this requires quite a bit of effort on your side, to always get a valid token before opening a connection. It makes using an off-the-shelf connection pool difficult. Probably once open, the connection will remain open even after the token expires, but you still need to handle the case where more connections need to be opened at a later time.
I would stick with a normal user/password access for the application, using IAM for this case seems to be too much effort.
For applications running on Amazon EC2, you can use EC2 instance profile credentials to access the database, so you don't need to use database passwords on your EC2 instance.
You're misinterpreting what this means. It means you don't have to use static passwords or store them on the instance.
The idea is that you generate a new authentication token each time you establish a connection to the database. The token is generated on your instance, using the instance role credentials. It can only be used to authenticate for 15 minutes, but once connected, you don't lose your database connection after 15 minutes. You remain connected.
If your application doesn't reuse database connections, then you likely have a design flaw there.

Is it possible to have php hosted local connects to Amazon dynamoDb?

I was working on a Arduino project that provides data to outside public but I want to keep only for family members or some guests. So I wanted to set up login authentication page where user can login and see data over a php website hosted locally (available over internet via port forwarding) . But since login would require database to store username/password I want it to be stored on dynamoDb. I think storing online on AWS is a good idea since db will grow over time but php page can be stored and moved easily . Another reason I would like to try is whilst I will get to learn how to use NoSql on dynamo db!
Please guide me the right path to host php locally that uses Amazon dynamoDb for storing logins?
You can certainly connect to DynamoDB from outside of the Amazon environment as long as you have your credentials. The PHP Getting Started Guide should give you most of what you need.
When you're ready to move to an EC2 instance, a t2.nano machine is about USD $4.32 per month. That would let you setup a full PHP server that could also talk to the database and you wouldn't have to have it locally.

Creating A New MySQL User In Amazon RDS Environment

I need to create a new MySQL user with limited permission on an existing Amazon RDS instance. After encountering a couple error messages I was sort of able to do this using the official MySQL Administrator tool and the user now appears in the list. However, I'm unable to assign any schema privileges as all the users are greyed out. I'm logged in as the "master user" created when the instance was launched. Not sure where to go from here. I do have the RDS command line tools installed but wasn't able to track down anything there either. Ideas
Your best bet is probably to connect to the database with a mysql command line client and call the SQL commands to create a new user and assign him privileges.
For instance, you might run something like this:
mysql -u [your_master_username] -p -h YOURRDSENDPOINT.rds.amazonaws.com
CREATE USER 'jeffrey'#'%' IDENTIFIED BY 'somepassword';
GRANT SELECT ON [your_database].[some_table] TO 'jeffrey'#'%';
On windows you could use the mysql.exe client, wherever that is.
Useful Docs
AWS RDS security groups documentation (a common area of confusion): http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithSecurityGroups.html
User creation documentation: http://dev.mysql.com/doc/refman/5.5/en/create-user.html
Privilege granting documentation: http://dev.mysql.com/doc/refman/5.5/en/grant.html
I know this thread is a couple of years old and well I keep finding it so I wanted to get an update out about the AWS RDS and User Permissions.
You cannot use GRANT ALL for any user with an RDS. When you use the GRANT ALL statement you are also attempting to provide Global (as AWS Calls them Super Permissions) and with the way that the AWS RDS System is setup they do not allow assigning of Global Options to users.
You have to break out the Permissions to the following:
GRANT SELECT,INSERT,UPDATE,DELETE,DROP on
This will allow your user to be able to connect to the RDS once the security settings are setup to allow access from your EC2 Instances or from the Internet.
Hope this information helps anyone else that is running into the same issues that I was seeing with the AWS RDS Systems.
Waldo
I created like this:
CREATE USER 'jeffrey'#'localhost' IDENTIFIED BY 'somepassword';
GRANT SELECT ON mydatabase.* TO 'jeffrey'#'localhost';
But then, AWS rejected to login to that user. And I tried to change Admin privileges, but not success. And I change 'localhost' to '%' through mysql workbench. (or you can remove the user and recreate) like :
CREATE USER 'jeffrey'#'%' IDENTIFIED BY 'somepassword';
GRANT SELECT ON mydatabase.* TO 'jeffrey'#'%';
Then only I was able to loggin through this new user.
In addition:
Once you done this change, then your database allowed to connect from any ip. If you need to improve the security and restrict the accessing ip (Ex: if this is a staging database), you can set the bind-address in my.cnf file in your server.
bind-address = your.ip.add.ress
enter link description here
I had the most success using MySQL Workbench and executing raw SQL against RDS:
CREATE USER 'foo'#'localhost' IDENTIFIED BY 'password';
The bigger problem was permissions. Initially I tried:
Grant ALL on *.* to 'foo'#'localhost'
... which results in an Access Denied error.
Error Code: 1045. Access denied for user 'foo'#'%' (using password: YES)
The troublesome permission is "super" which RDS doesn't give me, and in turn I can't grant. As a result, I'm stuck doing permissions by hand:
Grant SELECT on *.* to 'foo'#'localhost';
Grant INSERT on *.* to 'foo'#'localhost';
Grant CREATE on *.* to 'foo'#'localhost';
I have used mySQL workbench and it works fine. just go to management/Users and Privileges, press "Add Account" button bottom left, and configure. You cannot give SUPER privileges, but most of the rest