Git Product home page Git Product logo

Comments (3)

aleksanderaleksic avatar aleksanderaleksic commented on August 31, 2024 1

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:

  1. tgmigrate apply
  2. terragrunt plan
  3. tgmigrate revert

from tgmigrate.

aleksanderaleksic avatar aleksanderaleksic commented on August 31, 2024

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.

from tgmigrate.

chkp-amirtal avatar chkp-amirtal commented on August 31, 2024

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.)

from tgmigrate.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.