CfnRotationSchedulePropsMixin
- class aws_cdk.mixins_preview.aws_secretsmanager.mixins.CfnRotationSchedulePropsMixin(props, *, strategy=None)
Bases:
MixinConfigure the rotation schedule and Lambda rotation function for a secret. For more information, see How rotation works .
For database credentials, refer to the following resources:
Amazon RDS master user credentials: AWS::RDS::DBCluster MasterUserSecret
Amazon Redshift admin user credentials: AWS::Redshift::Cluster
Choose one of the following options for the rotation function:
Create a new rotation function using
HostedRotationLambdabased on a Secrets Manager rotation function template .Use an existing rotation function by specifying its ARN with
RotationLambdaARN.
For database secrets defined in the same CloudFormation template as the database or service:
Use the AWS::SecretsManager::SecretTargetAttachment resource to populate the secret with connection details.
Add a
DependsOnattribute to theRotationScheduleresource that uses aSecretTargetAttachment. This ensures the rotation is configured after the secret is populated with connection details. > You can define only one rotation schedule per secret.
- See:
- CloudformationResource:
AWS::SecretsManager::RotationSchedule
- Mixin:
true
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview import mixins from aws_cdk.mixins_preview.aws_secretsmanager import mixins as secretsmanager_mixins cfn_rotation_schedule_props_mixin = secretsmanager_mixins.CfnRotationSchedulePropsMixin(secretsmanager_mixins.CfnRotationScheduleMixinProps( external_secret_rotation_metadata=[secretsmanager_mixins.CfnRotationSchedulePropsMixin.ExternalSecretRotationMetadataItemProperty( key="key", value="value" )], external_secret_rotation_role_arn="externalSecretRotationRoleArn", hosted_rotation_lambda=secretsmanager_mixins.CfnRotationSchedulePropsMixin.HostedRotationLambdaProperty( exclude_characters="excludeCharacters", kms_key_arn="kmsKeyArn", master_secret_arn="masterSecretArn", master_secret_kms_key_arn="masterSecretKmsKeyArn", rotation_lambda_name="rotationLambdaName", rotation_type="rotationType", runtime="runtime", superuser_secret_arn="superuserSecretArn", superuser_secret_kms_key_arn="superuserSecretKmsKeyArn", vpc_security_group_ids="vpcSecurityGroupIds", vpc_subnet_ids="vpcSubnetIds" ), rotate_immediately_on_update=False, rotation_lambda_arn="rotationLambdaArn", rotation_rules=secretsmanager_mixins.CfnRotationSchedulePropsMixin.RotationRulesProperty( automatically_after_days=123, duration="duration", schedule_expression="scheduleExpression" ), secret_id="secretId" ), strategy=mixins.PropertyMergeStrategy.OVERRIDE )
Create a mixin to apply properties to
AWS::SecretsManager::RotationSchedule.- Parameters:
props (
Union[CfnRotationScheduleMixinProps,Dict[str,Any]]) – L1 properties to apply.strategy (
Optional[PropertyMergeStrategy]) – (experimental) Strategy for merging nested properties. Default: - PropertyMergeStrategy.MERGE
Methods
- apply_to(construct)
Apply the mixin properties to the construct.
- Parameters:
construct (
IConstruct)- Return type:
- supports(construct)
Check if this mixin supports the given construct.
- Parameters:
construct (
IConstruct)- Return type:
bool
Attributes
- CFN_PROPERTY_KEYS = ['externalSecretRotationMetadata', 'externalSecretRotationRoleArn', 'hostedRotationLambda', 'rotateImmediatelyOnUpdate', 'rotationLambdaArn', 'rotationRules', 'secretId']
Static Methods
- classmethod is_mixin(x)
(experimental) Checks if
xis a Mixin.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsMixin.- Stability:
experimental
ExternalSecretRotationMetadataItemProperty
- class CfnRotationSchedulePropsMixin.ExternalSecretRotationMetadataItemProperty(*, key=None, value=None)
Bases:
objectThe metadata needed to successfully rotate a managed external secret.
A list of key value pairs in JSON format specified by the partner. For more information, see Managed external secret partners .
- Parameters:
key (
Optional[str]) – The key that identifies the item.value (
Optional[str]) – The value of the specified item.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_secretsmanager import mixins as secretsmanager_mixins external_secret_rotation_metadata_item_property = secretsmanager_mixins.CfnRotationSchedulePropsMixin.ExternalSecretRotationMetadataItemProperty( key="key", value="value" )
Attributes
- key
The key that identifies the item.
HostedRotationLambdaProperty
- class CfnRotationSchedulePropsMixin.HostedRotationLambdaProperty(*, exclude_characters=None, kms_key_arn=None, master_secret_arn=None, master_secret_kms_key_arn=None, rotation_lambda_name=None, rotation_type=None, runtime=None, superuser_secret_arn=None, superuser_secret_kms_key_arn=None, vpc_security_group_ids=None, vpc_subnet_ids=None)
Bases:
objectCreates a new Lambda rotation function based on one of the Secrets Manager rotation function templates .
You must specify
Transform: AWS::SecretsManager-2024-09-16at the beginning of the CloudFormation template.For Amazon RDS master user credentials, see AWS::RDS::DBCluster MasterUserSecret .
For Amazon Redshift admin user credentials, see AWS::Redshift::Cluster .
- Parameters:
exclude_characters (
Optional[str]) – A string of the characters that you don’t want in the password.kms_key_arn (
Optional[str]) – The ARN of the KMS key that Secrets Manager uses to encrypt the secret. If you don’t specify this value, then Secrets Manager uses the keyaws/secretsmanager. Ifaws/secretsmanagerdoesn’t yet exist, then Secrets Manager creates it for you automatically the first time it encrypts the secret value.master_secret_arn (
Optional[str]) – The ARN of the secret that contains superuser credentials, if you use the Alternating users rotation strategy . CloudFormation grants the execution role for the Lambda rotation functionGetSecretValuepermission to the secret in this property. For more information, see Lambda rotation function execution role permissions for Secrets Manager . You must create the superuser secret before you can set this property. You must also include the superuser secret ARN as a key in the JSON of the rotating secret so that the Lambda rotation function can find it. CloudFormation does not hardcode secret ARNs in the Lambda rotation function, so you can use the function to rotate multiple secrets. For more information, see JSON structure of Secrets Manager secrets . You can specifyMasterSecretArnorSuperuserSecretArnbut not both. They represent the same superuser secret.master_secret_kms_key_arn (
Optional[str]) –The ARN of the KMS key that Secrets Manager used to encrypt the superuser secret, if you use the alternating users strategy and the superuser secret is encrypted with a customer managed key. You don’t need to specify this property if the superuser secret is encrypted using the key
aws/secretsmanager. CloudFormation grants the execution role for the Lambda rotation functionDecrypt,DescribeKey, andGenerateDataKeypermission to the key in this property. For more information, see Lambda rotation function execution role permissions for Secrets Manager . You can specifyMasterSecretKmsKeyArnorSuperuserSecretKmsKeyArnbut not both. They represent the same superuser secret KMS key .rotation_lambda_name (
Optional[str]) – The name of the Lambda rotation function.rotation_type (
Optional[str]) – The rotation template to base the rotation function on, one of the following:. -Db2SingleUserto use the template SecretsManagerRDSDb2RotationSingleUser . -Db2MultiUserto use the template SecretsManagerRDSDb2RotationMultiUser . -MySQLSingleUserto use the template SecretsManagerRDSMySQLRotationSingleUser . -MySQLMultiUserto use the template SecretsManagerRDSMySQLRotationMultiUser . -PostgreSQLSingleUserto use the template SecretsManagerRDSPostgreSQLRotationSingleUser -PostgreSQLMultiUserto use the template SecretsManagerRDSPostgreSQLRotationMultiUser . -OracleSingleUserto use the template SecretsManagerRDSOracleRotationSingleUser . -OracleMultiUserto use the template SecretsManagerRDSOracleRotationMultiUser . -MariaDBSingleUserto use the template SecretsManagerRDSMariaDBRotationSingleUser . -MariaDBMultiUserto use the template SecretsManagerRDSMariaDBRotationMultiUser . -SQLServerSingleUserto use the template SecretsManagerRDSSQLServerRotationSingleUser . -SQLServerMultiUserto use the template SecretsManagerRDSSQLServerRotationMultiUser . -RedshiftSingleUserto use the template SecretsManagerRedshiftRotationSingleUsr . -RedshiftMultiUserto use the template SecretsManagerRedshiftRotationMultiUser . -MongoDBSingleUserto use the template SecretsManagerMongoDBRotationSingleUser . -MongoDBMultiUserto use the template SecretsManagerMongoDBRotationMultiUser .runtime (
Optional[str]) –Do not set this value if you are using
Transform: AWS::SecretsManager-2024-09-16. Over time, the updated rotation lambda artifacts vended by AWS may not be compatible with the code or shared object files defined in the rotation function deployment package. .. epigraph:: Only define theRuntimekey if: - You are usingTransform: AWS::SecretsManager-2020-07-23. - The code or shared object files defined in the rotation function deployment package are incompatible with Python 3.10. The Python Runtime version for with the rotation function. By default, CloudFormation deploys Python 3.10 binaries for the rotation function. To use a different version of Python, you must do the following two steps: - Deploy the matching version Python binaries with your rotation function. - Set the version number in this field. For example, for Python 3.10, enter python3.10 . If you only do one of the steps, your rotation function will be incompatible with the binaries. For more information, see Why did my Lambda rotation function fail with a “pg module not found” error .superuser_secret_arn (
Optional[str]) –The ARN of the secret that contains superuser credentials, if you use the Alternating users rotation strategy . CloudFormation grants the execution role for the Lambda rotation function
GetSecretValuepermission to the secret in this property. For more information, see Lambda rotation function execution role permissions for Secrets Manager . You must create the superuser secret before you can set this property. You must also include the superuser secret ARN as a key in the JSON of the rotating secret so that the Lambda rotation function can find it. CloudFormation does not hardcode secret ARNs in the Lambda rotation function, so you can use the function to rotate multiple secrets. For more information, see JSON structure of Secrets Manager secrets . You can specifyMasterSecretArnorSuperuserSecretArnbut not both. They represent the same superuser secret.superuser_secret_kms_key_arn (
Optional[str]) –The ARN of the KMS key that Secrets Manager used to encrypt the superuser secret, if you use the alternating users strategy and the superuser secret is encrypted with a customer managed key. You don’t need to specify this property if the superuser secret is encrypted using the key
aws/secretsmanager. CloudFormation grants the execution role for the Lambda rotation functionDecrypt,DescribeKey, andGenerateDataKeypermission to the key in this property. For more information, see Lambda rotation function execution role permissions for Secrets Manager . You can specifyMasterSecretKmsKeyArnorSuperuserSecretKmsKeyArnbut not both. They represent the same superuser secret KMS key .vpc_security_group_ids (
Optional[str]) – A comma-separated list of security group IDs applied to the target database. The template applies the same security groups as on the Lambda rotation function that is created as part of this stack.vpc_subnet_ids (
Optional[str]) – A comma separated list of VPC subnet IDs of the target database network. The Lambda rotation function is in the same subnet group.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_secretsmanager import mixins as secretsmanager_mixins hosted_rotation_lambda_property = secretsmanager_mixins.CfnRotationSchedulePropsMixin.HostedRotationLambdaProperty( exclude_characters="excludeCharacters", kms_key_arn="kmsKeyArn", master_secret_arn="masterSecretArn", master_secret_kms_key_arn="masterSecretKmsKeyArn", rotation_lambda_name="rotationLambdaName", rotation_type="rotationType", runtime="runtime", superuser_secret_arn="superuserSecretArn", superuser_secret_kms_key_arn="superuserSecretKmsKeyArn", vpc_security_group_ids="vpcSecurityGroupIds", vpc_subnet_ids="vpcSubnetIds" )
Attributes
- exclude_characters
A string of the characters that you don’t want in the password.
- kms_key_arn
The ARN of the KMS key that Secrets Manager uses to encrypt the secret.
If you don’t specify this value, then Secrets Manager uses the key
aws/secretsmanager. Ifaws/secretsmanagerdoesn’t yet exist, then Secrets Manager creates it for you automatically the first time it encrypts the secret value.
- master_secret_arn
The ARN of the secret that contains superuser credentials, if you use the Alternating users rotation strategy . CloudFormation grants the execution role for the Lambda rotation function
GetSecretValuepermission to the secret in this property. For more information, see Lambda rotation function execution role permissions for Secrets Manager .You must create the superuser secret before you can set this property.
You must also include the superuser secret ARN as a key in the JSON of the rotating secret so that the Lambda rotation function can find it. CloudFormation does not hardcode secret ARNs in the Lambda rotation function, so you can use the function to rotate multiple secrets. For more information, see JSON structure of Secrets Manager secrets .
You can specify
MasterSecretArnorSuperuserSecretArnbut not both. They represent the same superuser secret.
- master_secret_kms_key_arn
The ARN of the KMS key that Secrets Manager used to encrypt the superuser secret, if you use the alternating users strategy and the superuser secret is encrypted with a customer managed key. You don’t need to specify this property if the superuser secret is encrypted using the key
aws/secretsmanager. CloudFormation grants the execution role for the Lambda rotation functionDecrypt,DescribeKey, andGenerateDataKeypermission to the key in this property. For more information, see Lambda rotation function execution role permissions for Secrets Manager .You can specify
MasterSecretKmsKeyArnorSuperuserSecretKmsKeyArnbut not both. They represent the same superuser secret KMS key .
- rotation_lambda_name
The name of the Lambda rotation function.
- rotation_type
.
Db2SingleUserto use the template SecretsManagerRDSDb2RotationSingleUser .Db2MultiUserto use the template SecretsManagerRDSDb2RotationMultiUser .MySQLSingleUserto use the template SecretsManagerRDSMySQLRotationSingleUser .MySQLMultiUserto use the template SecretsManagerRDSMySQLRotationMultiUser .PostgreSQLSingleUserto use the template SecretsManagerRDSPostgreSQLRotationSingleUserPostgreSQLMultiUserto use the template SecretsManagerRDSPostgreSQLRotationMultiUser .OracleSingleUserto use the template SecretsManagerRDSOracleRotationSingleUser .OracleMultiUserto use the template SecretsManagerRDSOracleRotationMultiUser .MariaDBSingleUserto use the template SecretsManagerRDSMariaDBRotationSingleUser .MariaDBMultiUserto use the template SecretsManagerRDSMariaDBRotationMultiUser .SQLServerSingleUserto use the template SecretsManagerRDSSQLServerRotationSingleUser .SQLServerMultiUserto use the template SecretsManagerRDSSQLServerRotationMultiUser .RedshiftSingleUserto use the template SecretsManagerRedshiftRotationSingleUsr .RedshiftMultiUserto use the template SecretsManagerRedshiftRotationMultiUser .MongoDBSingleUserto use the template SecretsManagerMongoDBRotationSingleUser .MongoDBMultiUserto use the template SecretsManagerMongoDBRotationMultiUser .
- See:
- Type:
The rotation template to base the rotation function on, one of the following
- runtime
Do not set this value if you are using
Transform: AWS::SecretsManager-2024-09-16.Over time, the updated rotation lambda artifacts vended by AWS may not be compatible with the code or shared object files defined in the rotation function deployment package. .. epigraph:
Only define the ``Runtime`` key if: - You are using ``Transform: AWS::SecretsManager-2020-07-23`` . - The code or shared object files defined in the rotation function deployment package are incompatible with Python 3.10.
The Python Runtime version for with the rotation function. By default, CloudFormation deploys Python 3.10 binaries for the rotation function. To use a different version of Python, you must do the following two steps:
Deploy the matching version Python binaries with your rotation function.
Set the version number in this field. For example, for Python 3.10, enter python3.10 .
If you only do one of the steps, your rotation function will be incompatible with the binaries. For more information, see Why did my Lambda rotation function fail with a “pg module not found” error .
- superuser_secret_arn
The ARN of the secret that contains superuser credentials, if you use the Alternating users rotation strategy . CloudFormation grants the execution role for the Lambda rotation function
GetSecretValuepermission to the secret in this property. For more information, see Lambda rotation function execution role permissions for Secrets Manager .You must create the superuser secret before you can set this property.
You must also include the superuser secret ARN as a key in the JSON of the rotating secret so that the Lambda rotation function can find it. CloudFormation does not hardcode secret ARNs in the Lambda rotation function, so you can use the function to rotate multiple secrets. For more information, see JSON structure of Secrets Manager secrets .
You can specify
MasterSecretArnorSuperuserSecretArnbut not both. They represent the same superuser secret.
- superuser_secret_kms_key_arn
The ARN of the KMS key that Secrets Manager used to encrypt the superuser secret, if you use the alternating users strategy and the superuser secret is encrypted with a customer managed key. You don’t need to specify this property if the superuser secret is encrypted using the key
aws/secretsmanager. CloudFormation grants the execution role for the Lambda rotation functionDecrypt,DescribeKey, andGenerateDataKeypermission to the key in this property. For more information, see Lambda rotation function execution role permissions for Secrets Manager .You can specify
MasterSecretKmsKeyArnorSuperuserSecretKmsKeyArnbut not both. They represent the same superuser secret KMS key .
- vpc_security_group_ids
A comma-separated list of security group IDs applied to the target database.
The template applies the same security groups as on the Lambda rotation function that is created as part of this stack.
- vpc_subnet_ids
A comma separated list of VPC subnet IDs of the target database network.
The Lambda rotation function is in the same subnet group.
RotationRulesProperty
- class CfnRotationSchedulePropsMixin.RotationRulesProperty(*, automatically_after_days=None, duration=None, schedule_expression=None)
Bases:
objectThe rotation schedule and window.
We recommend you use
ScheduleExpressionto set a cron or rate expression for the schedule andDurationto set the length of the rotation window. .. epigraph:When changing an existing rotation schedule and setting ``RotateImmediatelyOnUpdate`` to ``false`` : - If using ``AutomaticallyAfterDays`` or a ``ScheduleExpression`` with ``rate()`` , the previously scheduled rotation might still occur. - To prevent unintended rotations, use a ``ScheduleExpression`` with ``cron()`` for granular control over rotation windows.
- Parameters:
automatically_after_days (
Union[int,float,None]) – The number of days between automatic scheduled rotations of the secret. You can use this value to check that your secret meets your compliance guidelines for how often secrets must be rotated. InDescribeSecretandListSecrets, this value is calculated from the rotation schedule after every successful rotation. InRotateSecret, you can set the rotation schedule inRotationRuleswithAutomaticallyAfterDaysorScheduleExpression, but not both.duration (
Optional[str]) – The length of the rotation window in hours, for example3hfor a three hour window. Secrets Manager rotates your secret at any time during this window. The window must not extend into the next rotation window or the next UTC day. The window starts according to theScheduleExpression. If you don’t specify aDuration, for aScheduleExpressionin hours, the window automatically closes after one hour. For aScheduleExpressionin days, the window automatically closes at the end of the UTC day. For more information, including examples, see Schedule expressions in Secrets Manager rotation in the Secrets Manager Users Guide .schedule_expression (
Optional[str]) –A
cron()orrate()expression that defines the schedule for rotating your secret. Secrets Manager rotation schedules use UTC time zone. Secrets Manager rotates your secret any time during a rotation window. Secrets Managerrate()expressions represent the interval in hours or days that you want to rotate your secret, for examplerate(12 hours)orrate(10 days). You can rotate a secret as often as every four hours. If you use arate()expression, the rotation window starts at midnight. For a rate in hours, the default rotation window closes after one hour. For a rate in days, the default rotation window closes at the end of the day. You can set theDurationto change the rotation window. The rotation window must not extend into the next UTC day or into the next rotation window. You can use acron()expression to create a rotation schedule that is more detailed than a rotation interval. For more information, including examples, see Schedule expressions in Secrets Manager rotation in the Secrets Manager Users Guide . For a cron expression that represents a schedule in hours, the default rotation window closes after one hour. For a cron expression that represents a schedule in days, the default rotation window closes at the end of the day. You can set theDurationto change the rotation window. The rotation window must not extend into the next UTC day or into the next rotation window.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_secretsmanager import mixins as secretsmanager_mixins rotation_rules_property = secretsmanager_mixins.CfnRotationSchedulePropsMixin.RotationRulesProperty( automatically_after_days=123, duration="duration", schedule_expression="scheduleExpression" )
Attributes
- automatically_after_days
The number of days between automatic scheduled rotations of the secret.
You can use this value to check that your secret meets your compliance guidelines for how often secrets must be rotated.
In
DescribeSecretandListSecrets, this value is calculated from the rotation schedule after every successful rotation. InRotateSecret, you can set the rotation schedule inRotationRuleswithAutomaticallyAfterDaysorScheduleExpression, but not both.
- duration
The length of the rotation window in hours, for example
3hfor a three hour window.Secrets Manager rotates your secret at any time during this window. The window must not extend into the next rotation window or the next UTC day. The window starts according to the
ScheduleExpression. If you don’t specify aDuration, for aScheduleExpressionin hours, the window automatically closes after one hour. For aScheduleExpressionin days, the window automatically closes at the end of the UTC day. For more information, including examples, see Schedule expressions in Secrets Manager rotation in the Secrets Manager Users Guide .
- schedule_expression
A
cron()orrate()expression that defines the schedule for rotating your secret.Secrets Manager rotation schedules use UTC time zone. Secrets Manager rotates your secret any time during a rotation window.
Secrets Manager
rate()expressions represent the interval in hours or days that you want to rotate your secret, for examplerate(12 hours)orrate(10 days). You can rotate a secret as often as every four hours. If you use arate()expression, the rotation window starts at midnight. For a rate in hours, the default rotation window closes after one hour. For a rate in days, the default rotation window closes at the end of the day. You can set theDurationto change the rotation window. The rotation window must not extend into the next UTC day or into the next rotation window.You can use a
cron()expression to create a rotation schedule that is more detailed than a rotation interval. For more information, including examples, see Schedule expressions in Secrets Manager rotation in the Secrets Manager Users Guide . For a cron expression that represents a schedule in hours, the default rotation window closes after one hour. For a cron expression that represents a schedule in days, the default rotation window closes at the end of the day. You can set theDurationto change the rotation window. The rotation window must not extend into the next UTC day or into the next rotation window.