You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-4Lines changed: 17 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
4
4
ℹ️ Currently only supports generating import IDs for AWS resources.
5
5
6
-
`tfblocks` is a utility that generates `import` or `removed` blocks for Terraform resources by reading your Terraform state. These blocks can be especially useful when migrating a large number of resources between different Terraform states as you can define your migrations as code, and safely apply them as normal Terraform changes. They can, however, be a hassle to write by hand - enter `tfblocks`!
6
+
`tfblocks` is a utility that generates `import`, `moved`, or `removed` blocks for Terraform resources by reading your Terraform state. These blocks can be especially useful when migrating a large number of resources between different Terraform states as you can define your migrations as code, and safely apply them as normal Terraform changes. They can, however, be a hassle to write by hand - enter `tfblocks`!
### Generate import blocks for a specific resource type
70
72
```
71
-
terraform show -json | tfblocks import "aws_s3_bucket.*" "module.*.aws_s3_bucket.*" "module[*].aws_s3_bucket.*"
73
+
terraform show -json | tfblocks import "*.aws_s3_bucket.*" "aws_s3_bucket.*"
72
74
```
73
75
74
76
### Generate import blocks for resources in specific files
75
77
```
76
78
terraform show -json | tfblocks import -f "main.tf"
77
79
```
78
80
81
+
### Group generated blocks by source files
82
+
By including all Terraform files in a specific directory as context, tfblocks will group all the generated blocks by the source file of the associated resource (this works both for `import`, `move` and `removed`):
83
+
```
84
+
terraform show -json | tfblocks import -f "*.tf"
85
+
```
86
+
79
87
### Generate removed blocks for all resources
80
88
```
81
89
terraform show -json | tfblocks remove
82
90
```
83
91
84
-
### List all resource addresses
92
+
### Generate moved blocks for all resources
93
+
```
94
+
terraform show -json | tfblocks move
95
+
```
96
+
97
+
### Count resources in a given file
85
98
```
86
-
terraform show -json | tfblocks list
99
+
terraform show -json | tfblocks list -f main.tf | wc -l
0 commit comments