Closed chkp-amirtal closed 3 years ago
Hey @amirtal-cp, thanks for testing out tgmigrate! I realize I have forgotten to update the documentation after changing around on the commands. I will update it ASAP.
The -d flag have been replaced with a plan
sub-command instead.
Also there is a issue with using the terragrunt hooks #10 that I haven't figured out on how to resolve. As a work around I call tgmigrate separately before running terragrunt when needed.
hi, thanks for the update.
i was using the 'plan' command, and running it manually independent of terragrunt plan/apply commands. but i am facing an issue where 'tgmigrate plan' does not complete. there are no errors returned, just hangs (ctrl-c returns to the shell without additional output)
.tgmigrate.hcl :
migration {
migration = "./migrations"
history {
storage "s3" {
bucket = "terraform-state-storage-112233445566"
region = "eu-west-1"
assume_role = "arn:aws:iam::112233445566:role/builder"
key = "history.json"
}
}
state "s3" {
bucket = "terraform-state-storage-112233445566"
region = "eu-west-1"
assume_role = "arn:aws:iam::112233445566:role/builder"
}
}
V20210518__grafana-test.hcl :
migration {
environments = [
"sandbox",
]
description = <<EOF
- Move grafana to separate module (test).
EOF
}
migrate "move" "grafana" {
from {
state = "sandbox/us-east-1"
resource = "module.eks.module.eks_cluster_base.helm_release.grafana"
}
to {
state = "sandbox/us-east-1"
resource = "module.eks.module.grafana[0].helm_release.grafana"
}
}
migrate "move" "grafana-envs" {
from {
state = "sandbox/us-east-1"
resource = "module.eks.module.eks_cluster_base.kubernetes_secret.grafana-envs"
}
to {
state = "sandbox/us-east-1"
resource = "module.eks.module.grafana[0].kubernetes_secret.grafana-envs"
}
}
migrate "move" "grafana_db" {
from {
state = "sandbox/us-east-1"
resource = "module.eks.module.grafana_db"
}
to {
state = "sandbox/us-east-1"
resource = "module.eks.module.grafana[0].module.grafana_db"
}
}
output:
❯ tgmigrate plan
2021/05/18 23:40:17 Downloading sandbox/us-east-1/terraform.tfstate to /Users/amirtal/git/infra/terraform/sandbox/us-east-1/.tgmigrate_cache/state/sandbox/us-east-1/terraform.tfstate
Migrations for V20210518__grafana-test.hcl will be applied
Moving module.eks.module.eks_cluster_base.helm_release.grafana from sandbox/us-east-1 to sandbox/us-east-1 module.eks.module.grafana[0].helm_release.grafana
Moving module.eks.module.eks_cluster_base.kubernetes_secret.grafana-envs from sandbox/us-east-1 to sandbox/us-east-1 module.eks.module.grafana[0].kubernetes_secret.grafana-envs
Moving module.eks.module.grafana_db from sandbox/us-east-1 to sandbox/us-east-1 module.eks.module.grafana[0].module.grafana_db
2021/05/18 23:45:43 Uploading sandbox/us-east-1/terraform.tfstate to s3://terraform-state-storage-112233445566/sandbox/us-east-1/terraform.tfstate
^C
note that there is ~5min delay from the 'Moving ...' notification (shows up instantly when running command), to the 'Uploading ...' line (which actually never completes, i.e. file in s3 is not changed).
also tried running migration plan for only a single resource:
❯ tgmigrate plan
2021/05/19 00:11:16 Downloading sandbox/us-east-1/terraform.tfstate to /Users/amirtal/git/devops-infra/terraform/sandbox/us-east-1/.tgmigrate_cache/state/sandbox/us-east-1/terraform.tfstate
Migrations for V20210518__grafana-test.hcl will be applied
Moving module.eks.module.eks_cluster_base.kubernetes_secret.grafana-envs from sandbox/us-east-1 to sandbox/us-east-1 module.eks.module.grafana[0].kubernetes_secret.grafana-envs
2021/05/19 00:16:53 Uploading sandbox/us-east-1/terraform.tfstate to s3://devops-iaas-terraform-state-storage-891423113723/sandbox/us-east-1/terraform.tfstate
with same result.
using macOS (catalina 10.15.7), tgmigrate version 0.1.7 terraform v0.13.5 terragrunt v0.28.7
is there an option for more verbose output/log ?
(possibly fork this as a new issue.)
Hey, forking this into a new issue would be nice, I have updated the documentation now so then I can close this issue.
The issue where it's stuck uploading the state file to the bucket is obviously a bug.. Since it's a plan command it's actually just outputting the changes but it's not really changing the state, maybe a renaming to "check" would make more sense. Also, the "Uploading" in the plan means that it's just a dry run upload. If you would like to test the changes you can do it like this:
on the example given:
there is a reference to a non-existing parameter:
flag provided but not defined: -d
how (if possible) should the plan action be used?