Hi there,
Terraform v0.9.0
Please list the resources as a list, for example:
provider "mysql" {
alias = "apps"
endpoint = "${var.db_apps_endpoint}"
username = "root"
password = "root_secret"
}
resource "mysql_database" "ocsng" {
provider = "mysql.apps"
name = "ocsng"
}
resource "mysql_user" "ocsng" {
provider = "mysql.apps"
user = "ocsng"
host = "%"
password = "user_secret"
}
resource "mysql_grant" "ocsng" {
provider = "mysql.apps"
user = "${mysql_user.ocsng.user}"
host = "${mysql_user.ocsng.host}"
database = "${mysql_database.ocsng.name}"
privileges = ["SELECT", "UPDATE"]
}
After applying, delete the user ocsng in your database manually.
Then, after a terraform plan this output appears:
mysql_database.ocsng: Refreshing state... (ID: ocsng)
mysql_user.ocsng: Refreshing state... (ID: ocsng@%)
mysql_grant.ocsng: Refreshing state... (ID: ocsng@%:ocsng)
2017/03/16 18:05:19 [INFO] terraform: building graph: GraphTypePlan
No changes. Infrastructure is up-to-date.
This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, Terraform
doesn't need to do anything.
Terraform informing me that the user is not existing in the database instance and needs to be recreated.
Terraform says No changes. Infrastructure is up-to-date..
terraform apply and a valid endpoint.terraform plan again and see the unexpected output that the infrastructure is up-to-date.(After research: The user does not get removed from the local state, same goes probably also for the other resources from the MySQL provider. Removing them from the state manually again with terraform state rm mysql_user.username let's terraform create the user again.)
ReadUser only returns nil here
Good find! It should be trivial to implement, given that we have mysql admin credentials already.
The same report is valid for mysql_grants: https://github.com/hashicorp/terraform/blob/master/builtin/providers/mysql/resource_grant.go#L90
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.