libZSservicesZSamazonka-secretsmanagerZSamazonka-secretsmanager
Copyright(c) 2013-2021 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityauto-generated
Portabilitynon-portable (GHC extensions)
Safe HaskellNone

Amazonka.SecretsManager.RotateSecret

Description

Configures and starts the asynchronous process of rotating this secret. If you include the configuration parameters, the operation sets those values for the secret and then immediately starts a rotation. If you do not include the configuration parameters, the operation starts a rotation with the values already stored in the secret. After the rotation completes, the protected service and its clients all use the new version of the secret.

This required configuration information includes the ARN of an Amazon Web Services Lambda function and optionally, the time between scheduled rotations. The Lambda rotation function creates a new version of the secret and creates or updates the credentials on the protected service to match. After testing the new credentials, the function marks the new secret with the staging label AWSCURRENT so that your clients all immediately begin to use the new version. For more information about rotating secrets and how to configure a Lambda function to rotate the secrets for your protected service, see Rotating Secrets in Amazon Web Services Secrets Manager in the Amazon Web Services Secrets Manager User Guide.

Secrets Manager schedules the next rotation when the previous one completes. Secrets Manager schedules the date by adding the rotation interval (number of days) to the actual date of the last rotation. The service chooses the hour within that 24-hour date window randomly. The minute is also chosen somewhat randomly, but weighted towards the top of the hour and influenced by a variety of factors that help distribute load.

The rotation function must end with the versions of the secret in one of two states:

  • The AWSPENDING and AWSCURRENT staging labels are attached to the same version of the secret, or
  • The AWSPENDING staging label is not attached to any version of the secret.

If the AWSPENDING staging label is present but not attached to the same version as AWSCURRENT then any later invocation of RotateSecret assumes that a previous rotation request is still in progress and returns an error.

Minimum permissions

To run this command, you must have the following permissions:

  • secretsmanager:RotateSecret
  • lambda:InvokeFunction (on the function specified in the secret's metadata)

Related operations

  • To list the secrets in your account, use ListSecrets.
  • To get the details for a version of a secret, use DescribeSecret.
  • To create a new version of a secret, use CreateSecret.
  • To attach staging labels to or remove staging labels from a version of a secret, use UpdateSecretVersionStage.
Synopsis

Creating a Request

data RotateSecret Source #

See: newRotateSecret smart constructor.

Constructors

RotateSecret' 

Fields

  • rotationRules :: Maybe RotationRulesType

    A structure that defines the rotation configuration for this secret.

  • clientRequestToken :: Maybe Text

    (Optional) Specifies a unique identifier for the new version of the secret that helps ensure idempotency.

    If you use the Amazon Web Services CLI or one of the Amazon Web Services SDK to call this operation, then you can leave this parameter empty. The CLI or SDK generates a random UUID for you and includes that in the request for this parameter. If you don't use the SDK and instead generate a raw HTTP request to the Secrets Manager service endpoint, then you must generate a ClientRequestToken yourself for new versions and include that value in the request.

    You only need to specify your own value if you implement your own retry logic and want to ensure that a given secret is not created twice. We recommend that you generate a UUID-type value to ensure uniqueness within the specified secret.

    Secrets Manager uses this value to prevent the accidental creation of duplicate versions if there are failures and retries during the function's processing. This value becomes the VersionId of the new version.

  • rotationLambdaARN :: Maybe Text

    (Optional) Specifies the ARN of the Lambda function that can rotate the secret.

  • secretId :: Text

    Specifies the secret that you want to rotate. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.

    For an ARN, we recommend that you specify a complete ARN rather than a partial ARN.

Instances

Instances details
Eq RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

Read RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

Show RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

Generic RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

Associated Types

type Rep RotateSecret :: Type -> Type #

NFData RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

Methods

rnf :: RotateSecret -> () #

Hashable RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

ToJSON RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

AWSRequest RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

Associated Types

type AWSResponse RotateSecret #

ToHeaders RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

ToPath RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

ToQuery RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

type Rep RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

type Rep RotateSecret = D1 ('MetaData "RotateSecret" "Amazonka.SecretsManager.RotateSecret" "libZSservicesZSamazonka-secretsmanagerZSamazonka-secretsmanager" 'False) (C1 ('MetaCons "RotateSecret'" 'PrefixI 'True) ((S1 ('MetaSel ('Just "rotationRules") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe RotationRulesType)) :*: S1 ('MetaSel ('Just "clientRequestToken") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text))) :*: (S1 ('MetaSel ('Just "rotationLambdaARN") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "secretId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text))))
type AWSResponse RotateSecret Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

newRotateSecret Source #

Create a value of RotateSecret with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.

The following record fields are available, with the corresponding lenses provided for backwards compatibility:

$sel:rotationRules:RotateSecret', rotateSecret_rotationRules - A structure that defines the rotation configuration for this secret.

$sel:clientRequestToken:RotateSecret', rotateSecret_clientRequestToken - (Optional) Specifies a unique identifier for the new version of the secret that helps ensure idempotency.

If you use the Amazon Web Services CLI or one of the Amazon Web Services SDK to call this operation, then you can leave this parameter empty. The CLI or SDK generates a random UUID for you and includes that in the request for this parameter. If you don't use the SDK and instead generate a raw HTTP request to the Secrets Manager service endpoint, then you must generate a ClientRequestToken yourself for new versions and include that value in the request.

You only need to specify your own value if you implement your own retry logic and want to ensure that a given secret is not created twice. We recommend that you generate a UUID-type value to ensure uniqueness within the specified secret.

Secrets Manager uses this value to prevent the accidental creation of duplicate versions if there are failures and retries during the function's processing. This value becomes the VersionId of the new version.

$sel:rotationLambdaARN:RotateSecret', rotateSecret_rotationLambdaARN - (Optional) Specifies the ARN of the Lambda function that can rotate the secret.

$sel:secretId:RotateSecret', rotateSecret_secretId - Specifies the secret that you want to rotate. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.

For an ARN, we recommend that you specify a complete ARN rather than a partial ARN.

Request Lenses

rotateSecret_rotationRules :: Lens' RotateSecret (Maybe RotationRulesType) Source #

A structure that defines the rotation configuration for this secret.

rotateSecret_clientRequestToken :: Lens' RotateSecret (Maybe Text) Source #

(Optional) Specifies a unique identifier for the new version of the secret that helps ensure idempotency.

If you use the Amazon Web Services CLI or one of the Amazon Web Services SDK to call this operation, then you can leave this parameter empty. The CLI or SDK generates a random UUID for you and includes that in the request for this parameter. If you don't use the SDK and instead generate a raw HTTP request to the Secrets Manager service endpoint, then you must generate a ClientRequestToken yourself for new versions and include that value in the request.

You only need to specify your own value if you implement your own retry logic and want to ensure that a given secret is not created twice. We recommend that you generate a UUID-type value to ensure uniqueness within the specified secret.

Secrets Manager uses this value to prevent the accidental creation of duplicate versions if there are failures and retries during the function's processing. This value becomes the VersionId of the new version.

rotateSecret_rotationLambdaARN :: Lens' RotateSecret (Maybe Text) Source #

(Optional) Specifies the ARN of the Lambda function that can rotate the secret.

rotateSecret_secretId :: Lens' RotateSecret Text Source #

Specifies the secret that you want to rotate. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.

For an ARN, we recommend that you specify a complete ARN rather than a partial ARN.

Destructuring the Response

data RotateSecretResponse Source #

See: newRotateSecretResponse smart constructor.

Constructors

RotateSecretResponse' 

Fields

Instances

Instances details
Eq RotateSecretResponse Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

Read RotateSecretResponse Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

Show RotateSecretResponse Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

Generic RotateSecretResponse Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

Associated Types

type Rep RotateSecretResponse :: Type -> Type #

NFData RotateSecretResponse Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

Methods

rnf :: RotateSecretResponse -> () #

type Rep RotateSecretResponse Source # 
Instance details

Defined in Amazonka.SecretsManager.RotateSecret

type Rep RotateSecretResponse = D1 ('MetaData "RotateSecretResponse" "Amazonka.SecretsManager.RotateSecret" "libZSservicesZSamazonka-secretsmanagerZSamazonka-secretsmanager" 'False) (C1 ('MetaCons "RotateSecretResponse'" 'PrefixI 'True) ((S1 ('MetaSel ('Just "versionId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "arn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text))) :*: (S1 ('MetaSel ('Just "name") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "httpStatus") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int))))

newRotateSecretResponse Source #

Create a value of RotateSecretResponse with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.

The following record fields are available, with the corresponding lenses provided for backwards compatibility:

$sel:versionId:RotateSecretResponse', rotateSecretResponse_versionId - The ID of the new version of the secret created by the rotation started by this request.

$sel:arn:RotateSecretResponse', rotateSecretResponse_arn - The ARN of the secret.

$sel:name:RotateSecretResponse', rotateSecretResponse_name - The friendly name of the secret.

$sel:httpStatus:RotateSecretResponse', rotateSecretResponse_httpStatus - The response's http status code.

Response Lenses

rotateSecretResponse_versionId :: Lens' RotateSecretResponse (Maybe Text) Source #

The ID of the new version of the secret created by the rotation started by this request.