Skip to content

Commit

Permalink
Fix aws region (#109)
Browse files Browse the repository at this point in the history
* fixes #108, Put region flag in aws command

* update CHANGELOG.md
  • Loading branch information
pradeepbhadani authored Jun 5, 2019
1 parent 5a790eb commit 676b625
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [2.0.1] - 2019-06-05

### Added
- `region` flag to `mysql_user.sh` script.

## [2.0.0] - 2019-05-23

### Added
Expand Down
1 change: 1 addition & 0 deletions db.tf
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ resource "null_resource" "mysql_rw_user" {
MYSQL_DB = "${var.apiary_database_name}"
MYSQL_SECRET_ARN = "${data.aws_secretsmanager_secret.db_rw_user.arn}"
MYSQL_PERMISSIONS = "ALL"
AWS_REGION = "${var.aws_region}"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/mysql-user.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
MYSQL_OPTIONS="-h $MYSQL_HOST --user=$MYSQL_MASTER_USER --password=$MYSQL_MASTER_PASSWORD"
MYSQL_USER=$(aws secretsmanager get-secret-value --secret-id ${MYSQL_SECRET_ARN}|jq .SecretString -r|jq .username -r)
MYSQL_PASSWORD=$(aws secretsmanager get-secret-value --secret-id ${MYSQL_SECRET_ARN}|jq .SecretString -r|jq .password -r)
MYSQL_PASSWORD=$(aws secretsmanager get-secret-value --secret-id ${MYSQL_SECRET_ARN} --region ${AWS_REGION}|jq .SecretString -r|jq .password -r)

echo "GRANT $MYSQL_PERMISSIONS ON $MYSQL_DB.* TO '$MYSQL_USER'@\`%\` IDENTIFIED BY '$MYSQL_PASSWORD';"|mysql $MYSQL_OPTIONS

0 comments on commit 676b625

Please sign in to comment.