Skip to content

Commit

Permalink
docs: add info on which schema attributes will cause delete create
Browse files Browse the repository at this point in the history
Add to the schema attribute descriptions which changes will cause
terraform to destroy and recreate a resource.
  • Loading branch information
hmlanigan committed Nov 14, 2024
1 parent 66d016c commit c7a9b4b
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 78 deletions.
12 changes: 6 additions & 6 deletions docs/resources/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ resource "juju_application" "this" {

### Required

- `model` (String) The name of the model where the application is to be deployed.
- `model` (String) The name of the model where the application is to be deployed. Changing this value will cause the application to be destroyed and recreated by terraform.

### Optional

- `charm` (Block List) The name of the charm to be installed from Charmhub. (see [below for nested schema](#nestedblock--charm))
- `charm` (Block List) The charm installed from Charmhub. (see [below for nested schema](#nestedblock--charm))
- `config` (Map of String) Application specific configuration. Must evaluate to a string, integer or boolean.
- `constraints` (String) Constraints imposed on this application.
- `constraints` (String) Constraints imposed on this application. Changing this value will cause the application to be destroyed and recreated by terraform.
- `endpoint_bindings` (Attributes Set) Configure endpoint bindings (see [below for nested schema](#nestedatt--endpoint_bindings))
- `expose` (Block List) Makes an application publicly available over the network (see [below for nested schema](#nestedblock--expose))
- `name` (String) A custom name for the application deployment. If empty, uses the charm's name.
- `placement` (String) Specify the target location for the application's units
- `name` (String) A custom name for the application deployment. If empty, uses the charm's name.Changing this value will cause the application to be destroyed and recreated by terraform.
- `placement` (String) Specify the target location for the application's units. Changing this value will cause the application to be destroyed and recreated by terraform.
- `resources` (Map of String) Charm resources. Must evaluate to a string. A resource could be a resource revision number from CharmHub or a custom OCI image resource.
Specify a resource other than the default for a charm. Note that not all charms have resources.

Expand All @@ -82,7 +82,7 @@ Notes:

Required:

- `name` (String) The name of the charm
- `name` (String) The name of the charm to be deployed. Changing this value will cause the application to be destroyed and recreated by terraform.

Optional:

Expand Down
10 changes: 5 additions & 5 deletions docs/resources/credential.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ resource "juju_credential" "this" {

### Required

- `auth_type` (String) Credential authorization type
- `name` (String) The name to be assigned to the credential
- `auth_type` (String) Credential authorization type.
- `name` (String) The name to be assigned to the credential. Changing this value will cause the credential to be destroyed and recreated by terraform.

### Optional

- `attributes` (Map of String, Sensitive) Credential attributes accordingly to the cloud
- `client_credential` (Boolean) Add credentials to the client
- `cloud` (Block List) JuJu Cloud where the credentials will be used to access (see [below for nested schema](#nestedblock--cloud))
- `controller_credential` (Boolean) Add credentials to the controller
- `client_credential` (Boolean) Add credentials to the client.
- `cloud` (Block List) Juju Cloud where the credentials will be used to access. (see [below for nested schema](#nestedblock--cloud))
- `controller_credential` (Boolean) Add credentials to the controller.

### Read-Only

Expand Down
14 changes: 7 additions & 7 deletions docs/resources/machine.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ resource "juju_machine" "this_machine" {

### Required

- `model` (String) The Juju model in which to add a new machine.
- `model` (String) The Juju model in which to add a new machine. Changing this value will cause the machine to be destroyed and recreated by terraform.

### Optional

- `base` (String) The operating system to install on the new machine(s). E.g. [email protected].
- `constraints` (String) Machine constraints that overwrite those available from 'juju get-model-constraints' and provider's defaults.
- `disks` (String) Storage constraints for disks to attach to the machine(s).
- `base` (String) The operating system to install on the new machine(s). E.g. [email protected]. Changing this value will cause the machine to be destroyed and recreated by terraform.
- `constraints` (String) Machine constraints that overwrite those available from 'juju get-model-constraints' and provider's defaults. Changing this value will cause the application to be destroyed and recreated by terraform.
- `disks` (String) Storage constraints for disks to attach to the machine(s). Changing this value will cause the machine to be destroyed and recreated by terraform.
- `name` (String) A name for the machine resource in Terraform.
- `placement` (String) Additional information about how to allocate the machine in the cloud.
- `placement` (String) Additional information about how to allocate the machine in the cloud. Changing this value will cause the application to be destroyed and recreated by terraform.
- `private_key_file` (String) The file path to read the private key from.
- `public_key_file` (String) The file path to read the public key from.
- `series` (String, Deprecated) The operating system series to install on the new machine(s).
- `ssh_address` (String) The user@host directive for manual provisioning an existing machine via ssh. Requires public_key_file & private_key_file arguments.
- `series` (String, Deprecated) The operating system series to install on the new machine(s). Changing this value will cause the machine to be destroyed and recreated by terraform.
- `ssh_address` (String) The user@host directive for manual provisioning an existing machine via ssh. Requires public_key_file & private_key_file arguments. Changing this value will cause the machine to be destroyed and recreated by terraform.

### Read-Only

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource "juju_model" "this" {

### Optional

- `cloud` (Block List) JuJu Cloud where the model will operate (see [below for nested schema](#nestedblock--cloud))
- `cloud` (Block List) Juju Cloud where the model will operate. Changing this value will cause the model to be destroyed and recreated by terraform. (see [below for nested schema](#nestedblock--cloud))
- `config` (Map of String) Override default model configuration
- `constraints` (String) Constraints imposed to this model
- `credential` (String) Credential used to add the model
Expand Down
8 changes: 4 additions & 4 deletions docs/resources/offer.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ resource "juju_integration" "this" {

### Required

- `application_name` (String) The name of the application.
- `endpoint` (String) The endpoint name.
- `model` (String) The name of the model to operate in.
- `application_name` (String) The name of the application. Changing this value will cause the offer to be destroyed and recreated by terraform.
- `endpoint` (String) The endpoint name. Changing this value will cause the offer to be destroyed and recreated by terraform.
- `model` (String) The name of the model to operate in. Changing this value will cause the offer to be destroyed and recreated by terraform.

### Optional

- `name` (String) The name of the offer.
- `name` (String) The name of the offer. Changing this value will cause the offer to be destroyed and recreated by terraform.

### Read-Only

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource "juju_application" "my-application" {

### Required

- `model` (String) The model in which the secret belongs.
- `model` (String) The model in which the secret belongs. Changing this value will cause the secret to be destroyed and recreated by terraform.
- `value` (Map of String, Sensitive) The value map of the secret. There can be more than one key-value pair.

### Optional
Expand Down
6 changes: 3 additions & 3 deletions docs/resources/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ A resource that represents a Juju User.

### Required

- `name` (String) The name to be assigned to the user
- `password` (String, Sensitive) The password to be assigned to the user
- `name` (String) The username to be assigned to the user. Changing this value will cause the user to be destroyed and recreated by terraform.
- `password` (String, Sensitive) The password to be assigned to the user.

### Optional

- `display_name` (String) The display name to be assigned to the user (optional)
- `display_name` (String) The display name to be assigned to the user (optional).

### Read-Only

Expand Down
31 changes: 18 additions & 13 deletions internal/provider/resource_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,19 @@ func (r *applicationResource) Schema(_ context.Context, _ resource.SchemaRequest
" is not supported.",
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Description: "A custom name for the application deployment. If empty, uses the charm's name.",
Optional: true,
Computed: true,
Description: "A custom name for the application deployment. If empty, uses the charm's name." +
"Changing this value will cause the application to be destroyed and recreated by terraform.",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
stringplanmodifier.UseStateForUnknown(),
},
},
"model": schema.StringAttribute{
Description: "The name of the model where the application is to be deployed.",
Required: true,
Description: "The name of the model where the application is to be deployed. Changing this value" +
" will cause the application to be destroyed and recreated by terraform.",
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
},
Expand All @@ -157,8 +159,9 @@ func (r *applicationResource) Schema(_ context.Context, _ resource.SchemaRequest
ElementType: types.StringType,
},
"constraints": schema.StringAttribute{
Description: "Constraints imposed on this application.",
Optional: true,
Description: "Constraints imposed on this application. Changing this value will cause the" +
" application to be destroyed and recreated by terraform.",
Optional: true,
// Set as "computed" to pre-populate and preserve any implicit constraints
Computed: true,
PlanModifiers: []planmodifier.String{
Expand Down Expand Up @@ -213,9 +216,10 @@ func (r *applicationResource) Schema(_ context.Context, _ resource.SchemaRequest
Default: booldefault.StaticBool(false),
},
"placement": schema.StringAttribute{
Description: "Specify the target location for the application's units",
Optional: true,
Computed: true,
Description: "Specify the target location for the application's units. Changing this value" +
" will cause the application to be destroyed and recreated by terraform.",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
stringplanmodifier.UseStateForUnknown(),
Expand Down Expand Up @@ -267,12 +271,13 @@ func (r *applicationResource) Schema(_ context.Context, _ resource.SchemaRequest
},
Blocks: map[string]schema.Block{
CharmKey: schema.ListNestedBlock{
Description: "The name of the charm to be installed from Charmhub.",
Description: "The charm installed from Charmhub.",
NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Required: true,
Description: "The name of the charm",
Required: true,
Description: "The name of the charm to be deployed. Changing this value will cause" +
" the application to be destroyed and recreated by terraform.",
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
},
Expand Down
13 changes: 7 additions & 6 deletions internal/provider/resource_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (c *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest,
},
},
},
Description: "JuJu Cloud where the credentials will be used to access",
Description: "Juju Cloud where the credentials will be used to access.",
PlanModifiers: []planmodifier.List{
listplanmodifier.RequiresReplace(),
},
Expand All @@ -88,24 +88,25 @@ func (c *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest,
Sensitive: true,
},
"auth_type": schema.StringAttribute{
Description: "Credential authorization type",
Description: "Credential authorization type.",
Required: true,
},
"client_credential": schema.BoolAttribute{
Description: "Add credentials to the client",
Description: "Add credentials to the client.",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
},
"controller_credential": schema.BoolAttribute{
Description: "Add credentials to the controller",
Description: "Add credentials to the controller.",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
},
"name": schema.StringAttribute{
Description: "The name to be assigned to the credential",
Required: true,
Description: "The name to be assigned to the credential. Changing this value will cause the" +
" credential to be destroyed and recreated by terraform.",
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand Down
41 changes: 25 additions & 16 deletions internal/provider/resource_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,18 @@ func (r *machineResource) Schema(_ context.Context, req resource.SchemaRequest,
},
},
ModelKey: schema.StringAttribute{
Description: "The Juju model in which to add a new machine.",
Required: true,
Description: "The Juju model in which to add a new machine. Changing this value will cause the machine" +
" to be destroyed and recreated by terraform.",
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
ConstraintsKey: schema.StringAttribute{
Description: "Machine constraints that overwrite those available from 'juju get-model-constraints' and provider's defaults.",
Optional: true,
Description: "Machine constraints that overwrite those available from 'juju get-model-constraints' " +
"and provider's defaults. Changing this value will cause the application to be destroyed and" +
" recreated by terraform.",
Optional: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
},
Expand All @@ -128,8 +131,9 @@ func (r *machineResource) Schema(_ context.Context, req resource.SchemaRequest,
},
},
DisksKey: schema.StringAttribute{
Description: "Storage constraints for disks to attach to the machine(s).",
Optional: true,
Description: "Storage constraints for disks to attach to the machine(s). Changing this" +
" value will cause the machine to be destroyed and recreated by terraform.",
Optional: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
},
Expand All @@ -140,9 +144,10 @@ func (r *machineResource) Schema(_ context.Context, req resource.SchemaRequest,
},
},
BaseKey: schema.StringAttribute{
Description: "The operating system to install on the new machine(s). E.g. [email protected].",
Optional: true,
Computed: true,
Description: "The operating system to install on the new machine(s). E.g. [email protected]. Changing this" +
" value will cause the machine to be destroyed and recreated by terraform.",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
stringplanmodifier.UseStateForUnknown(),
Expand All @@ -156,9 +161,10 @@ func (r *machineResource) Schema(_ context.Context, req resource.SchemaRequest,
},
},
SeriesKey: schema.StringAttribute{
Description: "The operating system series to install on the new machine(s).",
Optional: true,
Computed: true,
Description: "The operating system series to install on the new machine(s). Changing this value" +
" will cause the machine to be destroyed and recreated by terraform.",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
stringplanmodifier.UseStateForUnknown(),
Expand All @@ -169,11 +175,13 @@ func (r *machineResource) Schema(_ context.Context, req resource.SchemaRequest,
path.MatchRoot(BaseKey),
}...),
},
DeprecationMessage: "Configure base instead. This attribute will be removed in the next major version of the provider.",
DeprecationMessage: "Configure base instead. This attribute will be removed in the next" +
" major version of the provider.",
},
PlacementKey: schema.StringAttribute{
Description: "Additional information about how to allocate the machine in the cloud.",
Optional: true,
Description: "Additional information about how to allocate the machine in the cloud. Changing" +
" this value will cause the application to be destroyed and recreated by terraform.",
Optional: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
stringplanmodifier.UseStateForUnknown(),
Expand All @@ -192,7 +200,8 @@ func (r *machineResource) Schema(_ context.Context, req resource.SchemaRequest,
},
SSHAddressKey: schema.StringAttribute{
Description: "The user@host directive for manual provisioning an existing machine via ssh. " +
"Requires public_key_file & private_key_file arguments.",
"Requires public_key_file & private_key_file arguments. Changing this value will cause the" +
" machine to be destroyed and recreated by terraform.",
Optional: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/resource_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ func (r *modelResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
},
Blocks: map[string]schema.Block{
"cloud": schema.ListNestedBlock{
Description: "JuJu Cloud where the model will operate",
Description: "Juju Cloud where the model will operate. Changing this value will cause the" +
" model to be destroyed and recreated by terraform.",
PlanModifiers: []planmodifier.List{
listplanmodifier.RequiresReplace(),
},
Expand Down
22 changes: 13 additions & 9 deletions internal/provider/resource_offer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,36 @@ func (o *offerResource) Schema(_ context.Context, req resource.SchemaRequest, re
Description: "A resource that represent a Juju Offer.",
Attributes: map[string]schema.Attribute{
"model": schema.StringAttribute{
Description: "The name of the model to operate in.",
Required: true,
Description: "The name of the model to operate in. Changing this value will cause the" +
" offer to be destroyed and recreated by terraform.",
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"name": schema.StringAttribute{
Description: "The name of the offer.",
Optional: true,
Computed: true,
Description: "The name of the offer. Changing this value will cause the offer" +
" to be destroyed and recreated by terraform.",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
stringplanmodifier.RequiresReplaceIfConfigured(),
stringplanmodifier.UseStateForUnknown(),
},
},
"application_name": schema.StringAttribute{
Description: "The name of the application.",
Required: true,
Description: "The name of the application. Changing this value will cause the offer" +
" to be destroyed and recreated by terraform.",
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"endpoint": schema.StringAttribute{
Description: "The endpoint name.",
Required: true,
Description: "The endpoint name. Changing this value will cause the offer" +
" to be destroyed and recreated by terraform.",
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand Down
Loading

0 comments on commit c7a9b4b

Please sign in to comment.