Import Date
This command check if every tf import block has an defined decorator above This decorator must contain an date when the block was created. It allows the detection of old import blocks which can be remoted at a certain point in time
Szenario
If you want to import already existing cloud resources into your terraform you can use import blocks in your code. If this blocks are used it is a good idea to remove them after a specific time or after it could be ensured that these blocks are taken by terraform. By using the first option ( after a specific time ) this Command can help you.
By executing tfutility importdate .
it can be ensured every import block has an decorator which contains a create date.
If these create date are expired ( defined by an additional expire date or an duration command line argument ) these checks will be fail until this import block is removed
Terraform
1#$ cat test.tf
2import {
3 to = "resource.aws_s3_bucket.example"
4 id = "arandoms3bucket"
5}
1# @importdate(start="01-01-1970")
2import {
3 to = ""
4 id = ""
5}
1# @importdate(start="01-01-1970", expire="19-01-2038")
2import {
3 to = ""
4 id = ""
5}
you can also overwrite the expire date with your own duration like:
`bash
tfutility moveddate --expire-after 60 /workspace
`
The –expire-after value is in Days.
If –allow-failure is not set the Application wil exit with exitcode 1 and without –silent it logs all expired moved blocks
usage: tfutility importdate [-h] [--expire-after EXPIRE_AFTER] [-s]
[--allow-failure]
paths [paths ...]
Positional Arguments
- paths
Path to one or more TF-Files. Its also Possible to set a folder. It searches only *.tf files
Named Arguments
- --expire-after
Returns all blocks that are older than the specified time period. The time span in days
- -s, --silent
Prevent any log output
Default:
False
- --allow-failure
If this flag was set, the module logs only all occurences but does not exit with code 1
Default:
False