-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement full ImportState for secret and access secret resources.
Do not use ImportStatePassthroughID. This allows for importing these resources by the secret name rather than requiring the secret URI. It will be the only time we Read one of the resources by name rather than ID. Terraform errors if the ID attribute name provided in the ImportStateRequest is not written to state at some point. In state, this will be modelname:secretname. Updating docs with new examples and updated schema information.
- Loading branch information
Showing
10 changed files
with
238 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
# Secrets can be imported by using the URI as in the juju show-secrets output. | ||
# Example: | ||
# $juju show-secret secret-name | ||
# coh2uo2ji6m0ue9a7tj0: | ||
# revision: 1 | ||
# owner: <model> | ||
# name: secret-name | ||
# created: 2024-04-19T08:46:25Z | ||
# updated: 2024-04-19T08:46:25Z | ||
$ terraform import juju_secret.secret-name coh2uo2ji6m0ue9a7tj0 | ||
# Secrets can be imported by using the model and secret names. | ||
$ terraform import juju_secret.secret-name testmodel:secret-name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
resource "juju_secret" "this" { | ||
resource "juju_secret" "my-secret" { | ||
model = juju_model.development.name | ||
name = "this_secret_name" | ||
name = "my_secret_name" | ||
value = { | ||
key1 = "value1" | ||
key2 = "value2" | ||
} | ||
info = "This is the secret" | ||
} | ||
|
||
resource "juju_application" "my-application" { | ||
# | ||
config = { | ||
# Reference my-secret within the plan by using the secret_id | ||
secret = juju_secret.my-secret.secret_id | ||
} | ||
# | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
# Secret access can be imported by using the URI as in the juju show-secrets output. | ||
# Example: | ||
# $juju show-secret secret-name | ||
# coh2uo2ji6m0ue9a7tj0: | ||
# revision: 1 | ||
# owner: <model> | ||
# name: secret-name | ||
# created: 2024-04-19T08:46:25Z | ||
# updated: 2024-04-19T08:46:25Z | ||
$ terraform import juju_access_secret.access-secret-name coh2uo2ji6m0ue9a7tj0 | ||
# Secret access can be imported by using the model and secret names. | ||
$ terraform import juju_access_secret.access-secret-name modelname:secret-name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
resource "juju_access_secret" "this" { | ||
resource "juju_secret" "my-secret" { | ||
model = juju_model.development.name | ||
name = "my_secret_name" | ||
value = { | ||
key1 = "value1" | ||
key2 = "value2" | ||
} | ||
info = "This is the secret" | ||
} | ||
|
||
resource "juju_access_secret" "my-secret-access" { | ||
model = juju_model.development.name | ||
applications = [ | ||
juju_application.app.name, juju_application.app2.name | ||
] | ||
secret_id = juju_secret.that.secret_id | ||
# Use the secret_id from your secret resource or data source. | ||
secret_id = juju_secret.my-secret.secret_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.