Comments (3)
I think the feature was implemented in v0.2.2 via #11.
I cannot reproduce it with the latest (v0.2.7). Which version are you using?
bash-5.0# tfmigrate -v
0.2.7
bash-5.0# terraform state list
aws_security_group.bar
aws_security_group.foo
bash-5.0# cat main.tf
resource "aws_security_group" "foo2" {
name = "foo"
}
resource "aws_security_group" "bar2" {
name = "bar"
}
bash-5.0# cat test.hcl
migration "state" "test" {
force = true
actions = [
"mv aws_security_group.foo aws_security_group.foo2",
]
}
bash-5.0# tfmigrate plan test.hcl
2021/09/03 07:15:37 [INFO] [runner] load migration file: test.hcl
2021/09/03 07:15:37 [INFO] [migrator] start state migrator plan
2021/09/03 07:15:37 [INFO] [migrator@.] terraform version: 1.0.5
2021/09/03 07:15:37 [INFO] [migrator@.] initialize work dir
2021/09/03 07:15:39 [INFO] [migrator@.] switch to remote workspace default
2021/09/03 07:15:40 [INFO] [migrator@.] get the current remote state
2021/09/03 07:15:41 [INFO] [migrator@.] override backend to local
2021/09/03 07:15:41 [INFO] [executor@.] create an override file
2021/09/03 07:15:41 [INFO] [migrator@.] creating local workspace folder in: terraform.tfstate.d/default
2021/09/03 07:15:41 [INFO] [executor@.] switch backend to local
2021/09/03 07:15:43 [INFO] [migrator@.] compute a new state
2021/09/03 07:15:43 [INFO] [migrator@.] check diffs
2021/09/03 07:15:46 [INFO] [migrator@.] unexpected diffs, ignoring as force option is true: failed to run command (exited 2): terraform plan -state=/tmp/tmp096906093 -out=/tmp/tfplan045121000 -input=false -no-color -detailed-exitcode
stdout:
aws_security_group.bar: Refreshing state... [id=sg-e5de8a85]
aws_security_group.foo2: Refreshing state... [id=sg-21ac42f1]
Note: Objects have changed outside of Terraform
Terraform detected the following changes made outside of Terraform since the
last "terraform apply":
# aws_security_group.foo2 has been changed
~ resource "aws_security_group" "foo2" {
id = "sg-21ac42f1"
name = "foo"
+ tags = {}
# (7 unchanged attributes hidden)
}
# aws_security_group.bar has been changed
~ resource "aws_security_group" "bar" {
id = "sg-e5de8a85"
name = "bar"
+ tags = {}
# (7 unchanged attributes hidden)
}
Unless you have made equivalent changes to your configuration, or ignored the
relevant attributes using ignore_changes, the following plan may include
actions to undo or respond to these changes.
─────────────────────────────────────────────────────────────────────────────
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
- destroy
Terraform will perform the following actions:
# aws_security_group.bar will be destroyed
- resource "aws_security_group" "bar" {
- arn = "arn:aws:ec2:ap-northeast-1:000000000000:security-group/sg-e5de8a85" -> null
- description = "Managed by Terraform" -> null
- egress = [
- {
- cidr_blocks = [
- "0.0.0.0/0",
]
- description = ""
- from_port = 0
- ipv6_cidr_blocks = []
- prefix_list_ids = []
- protocol = "-1"
- security_groups = []
- self = false
- to_port = 0
},
] -> null
- id = "sg-e5de8a85" -> null
- ingress = [] -> null
- name = "bar" -> null
- owner_id = "000000000000" -> null
- revoke_rules_on_delete = false -> null
- tags = {} -> null
- tags_all = {} -> null
}
# aws_security_group.bar2 will be created
+ resource "aws_security_group" "bar2" {
+ arn = (known after apply)
+ description = "Managed by Terraform"
+ egress = (known after apply)
+ id = (known after apply)
+ ingress = (known after apply)
+ name = "bar"
+ name_prefix = (known after apply)
+ owner_id = (known after apply)
+ revoke_rules_on_delete = false
+ tags_all = (known after apply)
+ vpc_id = (known after apply)
}
Plan: 1 to add, 0 to change, 1 to destroy.
─────────────────────────────────────────────────────────────────────────────
Saved the plan to: /tmp/tfplan045121000
To perform exactly these actions, run the following command to apply:
terraform apply "/tmp/tfplan045121000"
stderr:
2021/09/03 07:15:46 [INFO] [executor@.] remove the override file
2021/09/03 07:15:46 [INFO] [executor@.] remove the workspace state folder
2021/09/03 07:15:46 [INFO] [executor@.] switch back to remote
2021/09/03 07:15:48 [INFO] [migrator] state migrator plan success!
P.S. Thank for your offering, but I'm currently not accepting any money for my OSS projects. Thanks!
from tfmigrate.
Hi, thank you for your reply! I am on the latest version:
$ tfmigrate -v
0.2.7
I think maybe this only happens when it's a multi_state
migration. I should have mentioned that in the original post, sorry.
from tfmigrate.
@jeffgran I confirmed and fixed it in v0.2.9 via #40. Thank you for reporting!
from tfmigrate.
Related Issues (20)
- Running in a Terraform Cloud Agent HOT 5
- Reusability of terraform state command HOT 2
- Migrating states from codebases with different terraform version HOT 3
- tfmigrate reports success despite backend not properly configured HOT 1
- Cannot use `*` with tfmigrate actions HOT 4
- Feature request: Display of state plan for to_dir in multi-state HOT 3
- tfmigrate reports migration plan success when Terraform plan command returns an error HOT 2
- Feature request: add an option to skip `terraform plan`-ing HOT 4
- Feature request: support replace-provider HOT 5
- Change tfmigrate-storage license from MPL2 to MIT HOT 3
- Feature request: support skip_plan in state migration HOT 2
- Feature request: support actions spanning multiple HCL files targeting the same projects HOT 4
- multi_state xmv attempts to migrate data sources? HOT 4
- Possible to optimise multi_state_mv execution time?
- Possible to optimise multi_state_mv execution time? HOT 1
- OpenTofu support HOT 3
- Add terraform >=1.1 moved resource documentation? HOT 1
- [bug] Does not work when working with terragrunt & dynamic backend config
- Error executing ftmigrate on MacOS 14.0 (ARM) HOT 1
- split resources with dependencies. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tfmigrate.