Package com.pulumi.aws.secretsmanager
Class SecretVersion
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.secretsmanager.SecretVersion
-
public class SecretVersion extends com.pulumi.resources.CustomResourceProvides a resource to manage AWS Secrets Manager secret version including its secret value. To manage secret metadata, see the `aws.secretsmanager.Secret` resource. > **NOTE:** If the `AWSCURRENT` staging label is present on this version during resource deletion, that label cannot be removed and will be skipped to prevent errors when fully deleting the secret. That label will leave this secret version active even after the resource is deleted from this provider unless the secret itself is deleted. Move the `AWSCURRENT` staging label before or after deleting this resource from this provider to fully trigger version deprecation if necessary. > **NOTE:** This resource manages one specific version of a secret. If something else creates newer versions, such as rotation, another Pulumi program, or the console, this resource keeps tracking its own version even after that version is no longer `AWSCURRENT`. To read the current value of a secret, use the `aws.secretsmanager.SecretVersion` data source. > **NOTE:** When a secret's KMS key changes, Secrets Manager re-encrypts only the `AWSCURRENT`, `AWSPENDING`, and `AWSPREVIOUS` versions with the new key. Once the previous key is disabled or deleted, older versions can no longer be decrypted. If this resource's version is one of them, Pulumi keeps the value from state and shows a warning, but cannot import the version or move staging labels onto it. If the version is still `AWSCURRENT` or `AWSPENDING`, reading it fails. See [Change the encryption key for a secret](https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_update-encryption-key.html). ## Example Usage ### Simple String Value
### Key-Value Pairs Secrets Manager also accepts key-value pairs in JSON.package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.secretsmanager.SecretVersion; import com.pulumi.aws.secretsmanager.SecretVersionArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var example = new SecretVersion("example", SecretVersionArgs.builder() .secretId(exampleAwsSecretsmanagerSecret.id()) .secretString("example-string-to-protect") .build()); } }
Reading key-value pairs from JSON back into a native mappackage generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.secretsmanager.SecretVersion; import com.pulumi.aws.secretsmanager.SecretVersionArgs; import static com.pulumi.codegen.internal.Serialization.*; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { final var config = ctx.config(); final var example = config.get("example").orElse(Map.ofEntries( Map.entry("key1", "value1"), Map.entry("key2", "value2") )); var exampleSecretVersion = new SecretVersion("exampleSecretVersion", SecretVersionArgs.builder() .secretId(exampleAwsSecretsmanagerSecret.id()) .secretString(serializeJson( example)) .build()); } }
## Import ### Identity Schema #### Required * `secretId` - (String) ID of the secret. * `versionId` - (String) ID of the secret version. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import `aws.secretsmanager.SecretVersion` using the secret ID and version ID. For example: ```sh $ pulumi import aws:secretsmanager/secretVersion:SecretVersion example 'arn:aws:secretsmanager:us-east-1:123456789012:secret:example-123456|xxxxx-xxxxxxx-xxxxxxx-xxxxx' ```package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.std.StdFunctions; import com.pulumi.std.inputs.JsondecodeArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { ctx.export("example", StdFunctions.jsondecode(JsondecodeArgs.builder() .input(exampleAwsSecretsmanagerSecretVersion.secretString()) .build()).result().key1()); } }
-
-
Constructor Summary
Constructors Constructor Description SecretVersion(java.lang.String name)SecretVersion(java.lang.String name, SecretVersionArgs args)SecretVersion(java.lang.String name, SecretVersionArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>arn()static SecretVersionget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, SecretVersionState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.Boolean>hasSecretStringWo()com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<java.lang.String>secretArn()com.pulumi.core.Output<java.util.Optional<java.lang.String>>secretBinary()com.pulumi.core.Output<java.lang.String>secretId()com.pulumi.core.Output<java.util.Optional<java.lang.String>>secretString()com.pulumi.core.Output<java.util.Optional<java.lang.String>>secretStringWo()com.pulumi.core.Output<java.util.Optional<java.lang.Integer>>secretStringWoVersion()com.pulumi.core.Output<java.lang.String>versionId()com.pulumi.core.Output<java.util.List<java.lang.String>>versionStages()
-
-
-
Constructor Detail
-
SecretVersion
public SecretVersion(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
SecretVersion
public SecretVersion(java.lang.String name, SecretVersionArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
SecretVersion
public SecretVersion(java.lang.String name, SecretVersionArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
arn
public com.pulumi.core.Output<java.lang.String> arn()
- Returns:
- (**Deprecated**) ARN of the secret. Use `secretArn` instead.
-
hasSecretStringWo
public com.pulumi.core.Output<java.lang.Boolean> hasSecretStringWo()
- Returns:
- Whether a write-only secret string value is set.
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
-
secretArn
public com.pulumi.core.Output<java.lang.String> secretArn()
- Returns:
- ARN of the secret.
-
secretBinary
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> secretBinary()
- Returns:
- Binary data that you want to encrypt and store in this version of the secret. This is required if `secretString` or `secretStringWo` is not set. Needs to be encoded to base64.
-
secretId
public com.pulumi.core.Output<java.lang.String> secretId()
- Returns:
- Secret to which you want to add a new version. You can specify either the ARN or the friendly name of the secret. The secret must already exist.
-
secretString
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> secretString()
- Returns:
- Text data that you want to encrypt and store in this version of the secret. This is required if `secretBinary` or `secretStringWo` is not set.
-
secretStringWo
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> secretStringWo()
- Returns:
- **NOTE:** This field is write-only and its value will not be updated in state as part of read operations. Text data that you want to encrypt and store in this version of the secret. This is required if `secretBinary` or `secretString` is not set. If set, requires `secretStringWoVersion` to be set.
-
secretStringWoVersion
public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> secretStringWoVersion()
- Returns:
- Required when `secretStringWo` is set. Changing this value triggers an update to `secretStringWo`.
-
versionId
public com.pulumi.core.Output<java.lang.String> versionId()
- Returns:
- Unique identifier of the version of the secret.
-
versionStages
public com.pulumi.core.Output<java.util.List<java.lang.String>> versionStages()
- Returns:
- List of staging labels that are attached to this version of the secret. A staging label must be unique to a single version of the secret. If you specify a staging label that's already associated with a different version of the same secret then that staging label is automatically removed from the other version and attached to this version. If you do not specify a value, then AWS Secrets Manager automatically moves the staging label `AWSCURRENT` to this new version on creation. > **NOTE:** If `versionStages` is configured, you must include the `AWSCURRENT` staging label if this secret version is the only version or if the label is currently present on this secret version, otherwise this provider will show a perpetual difference.
-
get
public static SecretVersion get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable SecretVersionState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-