Secret
Provides a resource to manage AWS Secrets Manager secret metadata. To manage secret rotation, see the aws.secretsmanager.SecretRotation resource. To manage a secret value, see the aws.secretsmanager.SecretVersion resource.
Example Usage
Basic
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = new Aws.SecretsManager.Secret("example", new Aws.SecretsManager.SecretArgs
{
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/secretsmanager"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := secretsmanager.NewSecret(ctx, "example", nil)
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
example = aws.secretsmanager.Secret("example")import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.secretsmanager.Secret("example", {});Rotation Configuration
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var rotation_example = new Aws.SecretsManager.Secret("rotation-example", new Aws.SecretsManager.SecretArgs
{
RotationLambdaArn = aws_lambda_function.Example.Arn,
RotationRules = new Aws.SecretsManager.Inputs.SecretRotationRulesArgs
{
AutomaticallyAfterDays = 7,
},
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/secretsmanager"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := secretsmanager.NewSecret(ctx, "rotation_example", &secretsmanager.SecretArgs{
RotationLambdaArn: pulumi.String(aws_lambda_function.Example.Arn),
RotationRules: &secretsmanager.SecretRotationRulesArgs{
AutomaticallyAfterDays: pulumi.Int(7),
},
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
rotation_example = aws.secretsmanager.Secret("rotation-example",
rotation_lambda_arn=aws_lambda_function["example"]["arn"],
rotation_rules={
"automaticallyAfterDays": 7,
})import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const rotation_example = new aws.secretsmanager.Secret("rotation-example", {
rotationLambdaArn: aws_lambda_function_example.arn,
rotationRules: {
automaticallyAfterDays: 7,
},
});Create a Secret Resource
new Secret(name: string, args?: SecretArgs, opts?: CustomResourceOptions);def Secret(resource_name, opts=None, description=None, kms_key_id=None, name=None, name_prefix=None, policy=None, recovery_window_in_days=None, rotation_lambda_arn=None, rotation_rules=None, tags=None, __props__=None);func NewSecret(ctx *Context, name string, args *SecretArgs, opts ...ResourceOption) (*Secret, error)public Secret(string name, SecretArgs? args = null, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args SecretArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args SecretArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SecretArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
Secret Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The Secret resource accepts the following input properties:
- Description string
A description of the secret.
- Kms
Key stringId Specifies the ARN or alias of the AWS KMS customer master key (CMK) to be used to encrypt the secret values in the versions stored in this secret. If you don’t specify this value, then Secrets Manager defaults to using the AWS account’s default CMK (the one named
aws/secretsmanager). If the default KMS CMK with that name doesn’t yet exist, then AWS Secrets Manager creates it for you automatically the first time.- Name string
Specifies the friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters:
/_+=.@-Conflicts withname_prefix.- Name
Prefix string Creates a unique name beginning with the specified prefix. Conflicts with
name.- Policy string
A valid JSON document representing a resource policy.
- Recovery
Window intIn Days Specifies the number of days that AWS Secrets Manager waits before it can delete the secret. This value can be
0to force deletion without recovery or range from7to30days. The default value is30.- Rotation
Lambda stringArn Specifies the ARN of the Lambda function that can rotate the secret. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- Rotation
Rules SecretRotation Rules Args A structure that defines the rotation configuration for this secret. Defined below. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- Dictionary<string, string>
Specifies a key-value map of user-defined tags that are attached to the secret.
- Description string
A description of the secret.
- Kms
Key stringId Specifies the ARN or alias of the AWS KMS customer master key (CMK) to be used to encrypt the secret values in the versions stored in this secret. If you don’t specify this value, then Secrets Manager defaults to using the AWS account’s default CMK (the one named
aws/secretsmanager). If the default KMS CMK with that name doesn’t yet exist, then AWS Secrets Manager creates it for you automatically the first time.- Name string
Specifies the friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters:
/_+=.@-Conflicts withname_prefix.- Name
Prefix string Creates a unique name beginning with the specified prefix. Conflicts with
name.- Policy string
A valid JSON document representing a resource policy.
- Recovery
Window intIn Days Specifies the number of days that AWS Secrets Manager waits before it can delete the secret. This value can be
0to force deletion without recovery or range from7to30days. The default value is30.- Rotation
Lambda stringArn Specifies the ARN of the Lambda function that can rotate the secret. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- Rotation
Rules SecretRotation Rules A structure that defines the rotation configuration for this secret. Defined below. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- map[string]string
Specifies a key-value map of user-defined tags that are attached to the secret.
- description string
A description of the secret.
- kms
Key stringId Specifies the ARN or alias of the AWS KMS customer master key (CMK) to be used to encrypt the secret values in the versions stored in this secret. If you don’t specify this value, then Secrets Manager defaults to using the AWS account’s default CMK (the one named
aws/secretsmanager). If the default KMS CMK with that name doesn’t yet exist, then AWS Secrets Manager creates it for you automatically the first time.- name string
Specifies the friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters:
/_+=.@-Conflicts withname_prefix.- name
Prefix string Creates a unique name beginning with the specified prefix. Conflicts with
name.- policy string
A valid JSON document representing a resource policy.
- recovery
Window numberIn Days Specifies the number of days that AWS Secrets Manager waits before it can delete the secret. This value can be
0to force deletion without recovery or range from7to30days. The default value is30.- rotation
Lambda stringArn Specifies the ARN of the Lambda function that can rotate the secret. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- rotation
Rules SecretRotation Rules A structure that defines the rotation configuration for this secret. Defined below. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- {[key: string]: string}
Specifies a key-value map of user-defined tags that are attached to the secret.
- description str
A description of the secret.
- kms_
key_ strid Specifies the ARN or alias of the AWS KMS customer master key (CMK) to be used to encrypt the secret values in the versions stored in this secret. If you don’t specify this value, then Secrets Manager defaults to using the AWS account’s default CMK (the one named
aws/secretsmanager). If the default KMS CMK with that name doesn’t yet exist, then AWS Secrets Manager creates it for you automatically the first time.- name str
Specifies the friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters:
/_+=.@-Conflicts withname_prefix.- name_
prefix str Creates a unique name beginning with the specified prefix. Conflicts with
name.- policy str
A valid JSON document representing a resource policy.
- recovery_
window_ floatin_ days Specifies the number of days that AWS Secrets Manager waits before it can delete the secret. This value can be
0to force deletion without recovery or range from7to30days. The default value is30.- rotation_
lambda_ strarn Specifies the ARN of the Lambda function that can rotate the secret. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- rotation_
rules Dict[SecretRotation Rules] A structure that defines the rotation configuration for this secret. Defined below. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- Dict[str, str]
Specifies a key-value map of user-defined tags that are attached to the secret.
Outputs
All input properties are implicitly available as output properties. Additionally, the Secret resource produces the following output properties:
Look up an Existing Secret Resource
Get an existing Secret resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: SecretState, opts?: CustomResourceOptions): Secretstatic get(resource_name, id, opts=None, arn=None, description=None, kms_key_id=None, name=None, name_prefix=None, policy=None, recovery_window_in_days=None, rotation_enabled=None, rotation_lambda_arn=None, rotation_rules=None, tags=None, __props__=None);func GetSecret(ctx *Context, name string, id IDInput, state *SecretState, opts ...ResourceOption) (*Secret, error)public static Secret Get(string name, Input<string> id, SecretState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
- Arn string
Amazon Resource Name (ARN) of the secret.
- Description string
A description of the secret.
- Kms
Key stringId Specifies the ARN or alias of the AWS KMS customer master key (CMK) to be used to encrypt the secret values in the versions stored in this secret. If you don’t specify this value, then Secrets Manager defaults to using the AWS account’s default CMK (the one named
aws/secretsmanager). If the default KMS CMK with that name doesn’t yet exist, then AWS Secrets Manager creates it for you automatically the first time.- Name string
Specifies the friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters:
/_+=.@-Conflicts withname_prefix.- Name
Prefix string Creates a unique name beginning with the specified prefix. Conflicts with
name.- Policy string
A valid JSON document representing a resource policy.
- Recovery
Window intIn Days Specifies the number of days that AWS Secrets Manager waits before it can delete the secret. This value can be
0to force deletion without recovery or range from7to30days. The default value is30.- Rotation
Enabled bool Specifies whether automatic rotation is enabled for this secret.
- Rotation
Lambda stringArn Specifies the ARN of the Lambda function that can rotate the secret. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- Rotation
Rules SecretRotation Rules Args A structure that defines the rotation configuration for this secret. Defined below. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- Dictionary<string, string>
Specifies a key-value map of user-defined tags that are attached to the secret.
- Arn string
Amazon Resource Name (ARN) of the secret.
- Description string
A description of the secret.
- Kms
Key stringId Specifies the ARN or alias of the AWS KMS customer master key (CMK) to be used to encrypt the secret values in the versions stored in this secret. If you don’t specify this value, then Secrets Manager defaults to using the AWS account’s default CMK (the one named
aws/secretsmanager). If the default KMS CMK with that name doesn’t yet exist, then AWS Secrets Manager creates it for you automatically the first time.- Name string
Specifies the friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters:
/_+=.@-Conflicts withname_prefix.- Name
Prefix string Creates a unique name beginning with the specified prefix. Conflicts with
name.- Policy string
A valid JSON document representing a resource policy.
- Recovery
Window intIn Days Specifies the number of days that AWS Secrets Manager waits before it can delete the secret. This value can be
0to force deletion without recovery or range from7to30days. The default value is30.- Rotation
Enabled bool Specifies whether automatic rotation is enabled for this secret.
- Rotation
Lambda stringArn Specifies the ARN of the Lambda function that can rotate the secret. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- Rotation
Rules SecretRotation Rules A structure that defines the rotation configuration for this secret. Defined below. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- map[string]string
Specifies a key-value map of user-defined tags that are attached to the secret.
- arn string
Amazon Resource Name (ARN) of the secret.
- description string
A description of the secret.
- kms
Key stringId Specifies the ARN or alias of the AWS KMS customer master key (CMK) to be used to encrypt the secret values in the versions stored in this secret. If you don’t specify this value, then Secrets Manager defaults to using the AWS account’s default CMK (the one named
aws/secretsmanager). If the default KMS CMK with that name doesn’t yet exist, then AWS Secrets Manager creates it for you automatically the first time.- name string
Specifies the friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters:
/_+=.@-Conflicts withname_prefix.- name
Prefix string Creates a unique name beginning with the specified prefix. Conflicts with
name.- policy string
A valid JSON document representing a resource policy.
- recovery
Window numberIn Days Specifies the number of days that AWS Secrets Manager waits before it can delete the secret. This value can be
0to force deletion without recovery or range from7to30days. The default value is30.- rotation
Enabled boolean Specifies whether automatic rotation is enabled for this secret.
- rotation
Lambda stringArn Specifies the ARN of the Lambda function that can rotate the secret. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- rotation
Rules SecretRotation Rules A structure that defines the rotation configuration for this secret. Defined below. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- {[key: string]: string}
Specifies a key-value map of user-defined tags that are attached to the secret.
- arn str
Amazon Resource Name (ARN) of the secret.
- description str
A description of the secret.
- kms_
key_ strid Specifies the ARN or alias of the AWS KMS customer master key (CMK) to be used to encrypt the secret values in the versions stored in this secret. If you don’t specify this value, then Secrets Manager defaults to using the AWS account’s default CMK (the one named
aws/secretsmanager). If the default KMS CMK with that name doesn’t yet exist, then AWS Secrets Manager creates it for you automatically the first time.- name str
Specifies the friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters:
/_+=.@-Conflicts withname_prefix.- name_
prefix str Creates a unique name beginning with the specified prefix. Conflicts with
name.- policy str
A valid JSON document representing a resource policy.
- recovery_
window_ floatin_ days Specifies the number of days that AWS Secrets Manager waits before it can delete the secret. This value can be
0to force deletion without recovery or range from7to30days. The default value is30.- rotation_
enabled bool Specifies whether automatic rotation is enabled for this secret.
- rotation_
lambda_ strarn Specifies the ARN of the Lambda function that can rotate the secret. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- rotation_
rules Dict[SecretRotation Rules] A structure that defines the rotation configuration for this secret. Defined below. Use the
aws.secretsmanager.SecretRotationresource to manage this configuration instead. As of version 2.67.0, removal of this configuration will no longer remove rotation due to supporting the new resource. Either import the new resource and remove the configuration or manually remove rotation.- Dict[str, str]
Specifies a key-value map of user-defined tags that are attached to the secret.
Supporting Types
SecretRotationRules
- Automatically
After intDays Specifies the number of days between automatic scheduled rotations of the secret.
- Automatically
After intDays Specifies the number of days between automatic scheduled rotations of the secret.
- automatically
After numberDays Specifies the number of days between automatic scheduled rotations of the secret.
- automatically
After floatDays Specifies the number of days between automatic scheduled rotations of the secret.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.