# deployfish-mysql
`deployfish-mysql` is a plugin for [deployfish](https://github.com/caltechads/deployfish) that
allows you to manage databases in remote MySQL servers in AWS.
* `deploy mysql create {name}`: Create database a database and user, with appropriate `GRANT`s.
* `deploy mysql update {name}`: Update the user's password and `GRANT`s
* `deploy mysql validate {name}`: Validate that the username/password combination is valid
* `deploy mysql dump {name}`: Dump MySQL databases as SQL files to local file systems.
* `deploy mysql load {name} {filename}`: Load a local SQL file into remote MySQL databases
* `deploy mysql show-grants {name}`: Show GRANTs for your user
`{name}` above refers to the `name` of a MySQL connection from the `mysql:` section of your `deployfish.yml` file. See below for how the `mysql:` connection works.
## Install deployfish-mysql
pip install deployfish deployfish-mysql
## Configure deployfish-mysql
First follow the instructions for installing and configuring deployfish, then
add this stanza to your `~/.deployfish.yml` file:
```yaml
plugin.mysql:
enabled: true
```
NOTE: `~/.deployfish.yml` is the config file for deployfish itself. This is different from the `deployfish.yml` file that defines your services and tasks.
## Instrument your deployfish.yml
`deployfish-mysql` looks in your `deployfish.yml` file (the one with your services and task definitions, not the `~/.deployfish.yml` config file for deployfish iteslf) for a section named `mysql`, which has definitions of mysql databases:
```yaml
mysql:
- name: test
service: service-test
host: my-remote-rds-host.amazonaws.com
db: mydb
user: myuser
pass: password
- name: config-test
service: service-test
host: config.DB_HOST
db: config.DB_NAME
user: config.DB_USER
pass: config.DB_PASSWORD
services:
- name: dftest-test
cluster: my-cluster
environment: test
config:
- DEBUG=False
- DB_HOST=${terraform.rds_address}
- DB_NAME=dftest
- DB_USER=dftest_u
- DB_PASSWORD:secure:kms_key_arn=${env.DB_PASSWORD}
```
Entries in the `mysql:` section must minimally define these keys:
* `name`: the name of the connection. This will be used in all the `deploy mysql` commands as the connection name.
* `service`: the name of a service in the `services:` section. This will be used to determine which host we use to use for SSH when doing our mysql commands
* `host`: the hostname of the remote MySQL server
* `db`: the name of the database to work with in `host`
* `user`: the username of the user to use to authenticate to `host`
* `pass`: the password of the user to use to authenticate to `host`
These are optional keys that you can add to your connection definition:
* `port`: the port to connect to on the remote MySQL server. Default: 3306
* `character_set`: set the character set of your database to this (used for `deploy mysql create` and `deploy mysql update`). Default: `utf8`.
* `collation`: set the collation set of your database to this (used for `deploy mysql create` and `deploy mysql update`). Default: `utf8_unicode_ci`.
As you can see in the examples above, you can either hard code `host`, `db`, `user` and `password` in or you can reference `config` parameters from the `config:` section of the definition of our service. For the latter, `deployfish-mysql` will retrieve those parameters directly from AWS SSM Parameter Store, so ensure you write the service config to AWS before trying to establish a MySQL connection.
Raw data
{
"_id": null,
"home_page": "https://github.com/caltechads/deployfish-mysql",
"name": "deployfish-mysql",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "aws, ecs, docker, devops, mysql",
"author": "Caltech IMSS ADS",
"author_email": "imss-ads-staff@caltech.edu",
"download_url": "https://files.pythonhosted.org/packages/23/a5/2312cff8659c07b696ace22a7a811839992119bc1a2e383ca1cff01d0335/deployfish-mysql-1.2.16.tar.gz",
"platform": null,
"description": "# deployfish-mysql\n\n`deployfish-mysql` is a plugin for [deployfish](https://github.com/caltechads/deployfish) that\nallows you to manage databases in remote MySQL servers in AWS.\n\n* `deploy mysql create {name}`: Create database a database and user, with appropriate `GRANT`s.\n* `deploy mysql update {name}`: Update the user's password and `GRANT`s\n* `deploy mysql validate {name}`: Validate that the username/password combination is valid\n* `deploy mysql dump {name}`: Dump MySQL databases as SQL files to local file systems.\n* `deploy mysql load {name} {filename}`: Load a local SQL file into remote MySQL databases\n* `deploy mysql show-grants {name}`: Show GRANTs for your user\n\n`{name}` above refers to the `name` of a MySQL connection from the `mysql:` section of your `deployfish.yml` file. See below for how the `mysql:` connection works.\n\n## Install deployfish-mysql\n\n pip install deployfish deployfish-mysql\n\n## Configure deployfish-mysql\n\nFirst follow the instructions for installing and configuring deployfish, then\nadd this stanza to your `~/.deployfish.yml` file:\n\n```yaml\nplugin.mysql:\n enabled: true\n```\n\nNOTE: `~/.deployfish.yml` is the config file for deployfish itself. This is different from the `deployfish.yml` file that defines your services and tasks.\n\n## Instrument your deployfish.yml\n\n`deployfish-mysql` looks in your `deployfish.yml` file (the one with your services and task definitions, not the `~/.deployfish.yml` config file for deployfish iteslf) for a section named `mysql`, which has definitions of mysql databases:\n\n```yaml\nmysql:\n - name: test\n service: service-test\n host: my-remote-rds-host.amazonaws.com\n db: mydb\n user: myuser\n pass: password\n\n - name: config-test\n service: service-test\n host: config.DB_HOST\n db: config.DB_NAME\n user: config.DB_USER\n pass: config.DB_PASSWORD\n\nservices:\n - name: dftest-test\n cluster: my-cluster\n environment: test\n config:\n - DEBUG=False\n - DB_HOST=${terraform.rds_address}\n - DB_NAME=dftest\n - DB_USER=dftest_u\n - DB_PASSWORD:secure:kms_key_arn=${env.DB_PASSWORD}\n```\n\nEntries in the `mysql:` section must minimally define these keys:\n\n* `name`: the name of the connection. This will be used in all the `deploy mysql` commands as the connection name.\n* `service`: the name of a service in the `services:` section. This will be used to determine which host we use to use for SSH when doing our mysql commands\n* `host`: the hostname of the remote MySQL server\n* `db`: the name of the database to work with in `host`\n* `user`: the username of the user to use to authenticate to `host`\n* `pass`: the password of the user to use to authenticate to `host`\n\nThese are optional keys that you can add to your connection definition:\n\n* `port`: the port to connect to on the remote MySQL server. Default: 3306\n* `character_set`: set the character set of your database to this (used for `deploy mysql create` and `deploy mysql update`). Default: `utf8`.\n* `collation`: set the collation set of your database to this (used for `deploy mysql create` and `deploy mysql update`). Default: `utf8_unicode_ci`.\n\nAs you can see in the examples above, you can either hard code `host`, `db`, `user` and `password` in or you can reference `config` parameters from the `config:` section of the definition of our service. For the latter, `deployfish-mysql` will retrieve those parameters directly from AWS SSM Parameter Store, so ensure you write the service config to AWS before trying to establish a MySQL connection.\n",
"bugtrack_url": null,
"license": null,
"summary": "Deployfish MySQL plugin",
"version": "1.2.16",
"project_urls": {
"Homepage": "https://github.com/caltechads/deployfish-mysql",
"Issues": "https://github.com/caltechads/deployfish-mysql/issues",
"Source": "https://github.com/caltechads/deployfish-mysql"
},
"split_keywords": [
"aws",
" ecs",
" docker",
" devops",
" mysql"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5e97e493eefee5af3eccd4da938d5d6e5a6a8ea00722813fcfa44288cecee037",
"md5": "873700c95a235fe1d81700695e3931c5",
"sha256": "68857add21375946bd86f4123f7c40fa85d99eed787e0ae7cad5c8f4c0ca60df"
},
"downloads": -1,
"filename": "deployfish_mysql-1.2.16-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "873700c95a235fe1d81700695e3931c5",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.7",
"size": 14027,
"upload_time": "2024-04-10T18:42:43",
"upload_time_iso_8601": "2024-04-10T18:42:43.659663Z",
"url": "https://files.pythonhosted.org/packages/5e/97/e493eefee5af3eccd4da938d5d6e5a6a8ea00722813fcfa44288cecee037/deployfish_mysql-1.2.16-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "23a52312cff8659c07b696ace22a7a811839992119bc1a2e383ca1cff01d0335",
"md5": "2bd2b4472ce5ae63a7c5572984fb4e86",
"sha256": "524e5e43757e714e78289e2d08e00ad07667ea01efe1c4b288aedbb082ffd3c4"
},
"downloads": -1,
"filename": "deployfish-mysql-1.2.16.tar.gz",
"has_sig": false,
"md5_digest": "2bd2b4472ce5ae63a7c5572984fb4e86",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 13722,
"upload_time": "2024-04-10T18:42:45",
"upload_time_iso_8601": "2024-04-10T18:42:45.736695Z",
"url": "https://files.pythonhosted.org/packages/23/a5/2312cff8659c07b696ace22a7a811839992119bc1a2e383ca1cff01d0335/deployfish-mysql-1.2.16.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-10 18:42:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "caltechads",
"github_project": "deployfish-mysql",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "click",
"specs": [
[
">=",
"6.7"
]
]
},
{
"name": "bumpversion",
"specs": [
[
"==",
"0.5.3"
]
]
},
{
"name": "twine",
"specs": []
},
{
"name": "tox",
"specs": []
},
{
"name": "wheel",
"specs": []
},
{
"name": "pydevd-pycharm",
"specs": [
[
"~=",
"192.6817.19"
]
]
},
{
"name": "autopep8",
"specs": [
[
"==",
"0.8"
]
]
},
{
"name": "flake8",
"specs": [
[
"==",
"3.7.5"
]
]
},
{
"name": "pycodestyle",
"specs": [
[
"==",
"2.5.0"
]
]
},
{
"name": "mypy",
"specs": [
[
"==",
"0.701"
]
]
},
{
"name": "testfixtures",
"specs": [
[
"==",
"6.10.0"
]
]
},
{
"name": "mock",
"specs": [
[
"==",
"3.0.5"
]
]
},
{
"name": "nose",
"specs": [
[
"==",
"1.3.7"
]
]
},
{
"name": "ipython",
"specs": [
[
">=",
"7.13.0"
]
]
}
],
"lcname": "deployfish-mysql"
}