Documentation
¶
Overview ¶
Package resource manages the state update and deletion of Terraform resources.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DestroyResources ¶
func DestroyResources(resources []DestroyableResource, parallel int) int
DestroyResources destroys a given list of resources, which may depend on each other.
If at least one resource is successfully destroyed per run (iteration through the list of given resources), the remaining, failed resources will be retried in a next run (until all resources are destroyed or some destroys have permanently failed).
Types ¶
type DestroyableResource ¶
DestroyableResource implementations can destroy a Terraform resource.
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource represents a Terraform resource that can be destroyed.
func New ¶
func New(terraformType, id string, attrs map[string]cty.Value, provider *provider.TerraformProvider) *Resource
New creates a destroyable Terraform resource.
To destroy a resource, its Terraform Type and ID (both together uniquely identify a resource), plus a provider that will handle the destroy is needed. Note: if a resource's internal state representation is known, use NewWithState() instead.
For some resources, additionally to the ID a list of attributes needs to be populated to destroy it.
func NewWithState ¶
func NewWithState(terraformType, id string, provider *provider.TerraformProvider, state *cty.Value) *Resource
NewWithState creates a destroyable Terraform resource.
This constructor is used if a resource's internal state representation is known based on a present Terraform state file. A resource created with this constructor can be destroyed more reliable than with New(), which is used when the state is not known.
func (*Resource) UpdateState ¶
UpdateState updates the state of the resource (i.e., refreshes all its attributes). If the resource is already gone, the updated state will be nil (more precisely, of type cty.NilVal).
type RetryDestroyError ¶
type RetryDestroyError struct { Err error // Resource is the resource for which a destroy has failed. Resource DestroyableResource }
RetryDestroyError is returned when destroying of a resource has failed, most likely due to being a dependency for another resource. It may be worth retrying once the dependent resource is gone.
func NewRetryDestroyError ¶
func NewRetryDestroyError(err error, r DestroyableResource) *RetryDestroyError
NewRetryDestroyError creates a RetryDestroyError.
func (RetryDestroyError) Error ¶
func (r RetryDestroyError) Error() string
type UpdatableResource ¶
type UpdatableResource interface { Type() string ID() string State() *cty.Value UpdateState() error }
UpdatableResource implementations can update a Terraform resource's state.
func UpdateResources ¶
func UpdateResources(resources []UpdatableResource, parallel int) []UpdatableResource
UpdateResources updates the state of a given list of resources in parallel. Only updated resources are returned which still exist remotely (e.g., in AWS).