Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform state backup and restore tool #314

Merged
merged 3 commits into from
May 26, 2022

Conversation

loheagn
Copy link
Contributor

@loheagn loheagn commented May 25, 2022

This PR fixes #310

Signed-off-by: loheagn [email protected]

Signed-off-by: loheagn <[email protected]>
@codecov
Copy link

codecov bot commented May 25, 2022

Codecov Report

❗ No coverage uploaded for pull request base (master@971d169). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master     #314   +/-   ##
=========================================
  Coverage          ?   78.18%           
=========================================
  Files             ?       23           
  Lines             ?     1595           
  Branches          ?        0           
=========================================
  Hits              ?     1247           
  Misses            ?      268           
  Partials          ?       80           
Flag Coverage Δ
e2e 0.00% <0.00%> (?)
unit 81.87% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 971d169...d2d836b. Read the comment docs.

},
}
restoreCmd.Flags().StringVar(&stateJSONPath, "state", "state.back.json", "the path of the backed up Terraform state file")
restoreCmd.Flags().StringVar(&configurationPath, "configuration", "configuration.back.yaml", "the path of the backed up configuration objcet yaml file")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
restoreCmd.Flags().StringVar(&configurationPath, "configuration", "configuration.back.yaml", "the path of the backed up configuration objcet yaml file")
restoreCmd.Flags().StringVar(&configurationPath, "configuration", "configuration.yaml", "the path of the backed up configuration objcet yaml file")

Normally the configuration file is there, no need to have a backup.


## `restore`

The main usage of the `restore` subcommand is to import an "outside" Terraform instance (maybe created by the terraform command line or managed by another terraform-controller before) to the terraform-controller in the target kubernetes without recreating the cloud resources.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The main usage of the `restore` subcommand is to import an "outside" Terraform instance (maybe created by the terraform command line or managed by another terraform-controller before) to the terraform-controller in the target kubernetes without recreating the cloud resources.
The main usage of the `restore` subcommand is to import an "outside" Terraform instance (maybe created by the terraform command line or managed by another terraform-controller before) to the terraform-controller in the target Kubernetes without recreating the cloud resources.

To use the `restore` subcommand, you should:

1. Prepare the `configuration.yaml` file and the `state.json` file whose content is the state json of the Terraform instance which would be imported.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a typical scenario, great! Here is another one, please cover it in this PR or in a later one #310 (comment).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this should be covered by backup command?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add the backup command in the next PR.

Signed-off-by: loheagn <[email protected]>
Copy link
Collaborator

@zzxwill zzxwill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@zzxwill zzxwill merged commit 2117b20 into kubevela:master May 26, 2022
@loheagn loheagn deleted the backup_restore branch May 26, 2022 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backup and restore the Terraform state
2 participants