pub struct StateCommand { /* private fields */ }Expand description
Command for managing Terraform state.
use terraform_wrapper::{Terraform, TerraformCommand};
use terraform_wrapper::commands::state::StateCommand;
let tf = Terraform::builder().working_dir("/tmp/infra").build()?;
// List resources in state
let output = StateCommand::list().execute(&tf).await?;
// Show a specific resource
let output = StateCommand::show("null_resource.example")
.execute(&tf)
.await?;Implementations§
Source§impl StateCommand
impl StateCommand
Sourcepub fn rm(addresses: Vec<String>) -> Self
pub fn rm(addresses: Vec<String>) -> Self
Remove resources from the state (without destroying them).
Sourcepub fn replace_provider(from: &str, to: &str) -> Self
pub fn replace_provider(from: &str, to: &str) -> Self
Replace a provider in the state.
Migrates resources from one provider to another without modifying the actual infrastructure.
StateCommand::replace_provider(
"registry.terraform.io/-/aws",
"registry.terraform.io/hashicorp/aws",
)
.auto_approve()
.execute(&tf)
.await?;Sourcepub fn auto_approve(self) -> Self
pub fn auto_approve(self) -> Self
Skip interactive approval (-auto-approve).
Applies to replace-provider subcommand only.
Sourcepub fn dry_run(self) -> Self
pub fn dry_run(self) -> Self
Preview the operation without making changes (-dry-run).
Applies to mv and rm subcommands only; ignored for other subcommands.
Sourcepub fn lock(self, enabled: bool) -> Self
pub fn lock(self, enabled: bool) -> Self
Enable or disable state locking (-lock).
Applies to mv, rm, and replace-provider subcommands.
Sourcepub fn lock_timeout(self, timeout: &str) -> Self
pub fn lock_timeout(self, timeout: &str) -> Self
Duration to wait for state lock (-lock-timeout).
Applies to mv, rm, and replace-provider subcommands.
Trait Implementations§
Source§impl Clone for StateCommand
impl Clone for StateCommand
Source§fn clone(&self) -> StateCommand
fn clone(&self) -> StateCommand
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StateCommand
impl Debug for StateCommand
Source§impl TerraformCommand for StateCommand
impl TerraformCommand for StateCommand
Source§type Output = CommandOutput
type Output = CommandOutput
The output type produced by this command.
Source§async fn execute(&self, tf: &Terraform) -> Result<CommandOutput>
async fn execute(&self, tf: &Terraform) -> Result<CommandOutput>
Execute this command against the given Terraform client.
Source§fn supports_input(&self) -> bool
fn supports_input(&self) -> bool
Whether this command supports the
-input=false flag. Read moreAuto Trait Implementations§
impl Freeze for StateCommand
impl RefUnwindSafe for StateCommand
impl Send for StateCommand
impl Sync for StateCommand
impl Unpin for StateCommand
impl UnsafeUnpin for StateCommand
impl UnwindSafe for StateCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more