DatabaseInstance

class aws_cdk.aws_rds.DatabaseInstance(scope, id, *, character_set_name=None, credentials=None, storage_encrypted=None, storage_encryption_key=None, engine, allocated_storage=None, allow_major_version_upgrade=None, database_name=None, instance_type=None, license_model=None, parameters=None, timezone=None, vpc, auto_minor_version_upgrade=None, availability_zone=None, backup_retention=None, ca_certificate=None, cloudwatch_logs_exports=None, cloudwatch_logs_retention=None, cloudwatch_logs_retention_role=None, copy_tags_to_snapshot=None, delete_automated_backups=None, deletion_protection=None, domain=None, domain_role=None, enable_performance_insights=None, iam_authentication=None, instance_identifier=None, iops=None, max_allocated_storage=None, monitoring_interval=None, monitoring_role=None, multi_az=None, network_type=None, option_group=None, parameter_group=None, performance_insight_encryption_key=None, performance_insight_retention=None, port=None, preferred_backup_window=None, preferred_maintenance_window=None, processor_features=None, publicly_accessible=None, removal_policy=None, s3_export_buckets=None, s3_export_role=None, s3_import_buckets=None, s3_import_role=None, security_groups=None, storage_throughput=None, storage_type=None, subnet_group=None, vpc_subnets=None)

Bases: DatabaseInstanceBase

A database instance.

Resource:

AWS::RDS::DBInstance

ExampleMetadata:

infused

Example:

# vpc: ec2.Vpc


iops_instance = rds.DatabaseInstance(self, "IopsInstance",
    engine=rds.DatabaseInstanceEngine.mysql(version=rds.MysqlEngineVersion.VER_8_0_39),
    vpc=vpc,
    storage_type=rds.StorageType.IO1,
    iops=5000
)

gp3_instance = rds.DatabaseInstance(self, "Gp3Instance",
    engine=rds.DatabaseInstanceEngine.mysql(version=rds.MysqlEngineVersion.VER_8_0_39),
    vpc=vpc,
    allocated_storage=500,
    storage_type=rds.StorageType.GP3,
    storage_throughput=500
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • character_set_name (Optional[str]) – For supported engines, specifies the character set to associate with the DB instance. Default: - RDS default character set name

  • credentials (Optional[Credentials]) – Credentials for the administrative user. Default: - A username of ‘admin’ (or ‘postgres’ for PostgreSQL) and SecretsManager-generated password

  • storage_encrypted (Optional[bool]) – Indicates whether the DB instance is encrypted. Default: - true if storageEncryptionKey has been provided, false otherwise

  • storage_encryption_key (Optional[IKey]) – The KMS key that’s used to encrypt the DB instance. Default: - default master key if storageEncrypted is true, no key otherwise

  • engine (IInstanceEngine) – The database engine.

  • allocated_storage (Union[int, float, None]) – The allocated storage size, specified in gibibytes (GiB). Default: 100

  • allow_major_version_upgrade (Optional[bool]) – Whether to allow major version upgrades. Default: false

  • database_name (Optional[str]) – The name of the database. Default: - no name

  • instance_type (Optional[InstanceType]) – The name of the compute and memory capacity for the instance. Default: - m5.large (or, more specifically, db.m5.large)

  • license_model (Optional[LicenseModel]) – The license model. Default: - RDS default license model

  • parameters (Optional[Mapping[str, str]]) – The parameters in the DBParameterGroup to create automatically. You can only specify parameterGroup or parameters but not both. You need to use a versioned engine to auto-generate a DBParameterGroup. Default: - None

  • timezone (Optional[str]) – The time zone of the instance. This is currently supported only by Microsoft Sql Server. Default: - RDS default timezone

  • vpc (IVpc) – The VPC network where the DB subnet group should be created.

  • auto_minor_version_upgrade (Optional[bool]) – Indicates that minor engine upgrades are applied automatically to the DB instance during the maintenance window. Default: true

  • availability_zone (Optional[str]) – The name of the Availability Zone where the DB instance will be located. Default: - no preference

  • backup_retention (Optional[Duration]) – The number of days during which automatic DB snapshots are retained. Set to zero to disable backups. When creating a read replica, you must enable automatic backups on the source database instance by setting the backup retention to a value other than zero. Default: - Duration.days(1) for source instances, disabled for read replicas

  • ca_certificate (Optional[CaCertificate]) – The identifier of the CA certificate for this DB instance. Specifying or updating this property triggers a reboot. For RDS DB engines: Default: - RDS will choose a certificate authority

  • cloudwatch_logs_exports (Optional[Sequence[str]]) – The list of log types that need to be enabled for exporting to CloudWatch Logs. Default: - no log exports

  • cloudwatch_logs_retention (Optional[RetentionDays]) – The number of days log events are kept in CloudWatch Logs. When updating this property, unsetting it doesn’t remove the log retention policy. To remove the retention policy, set the value to Infinity. Default: - logs never expire

  • cloudwatch_logs_retention_role (Optional[IRole]) – The IAM role for the Lambda function associated with the custom resource that sets the retention policy. Default: - a new role is created.

  • copy_tags_to_snapshot (Optional[bool]) – Indicates whether to copy all of the user-defined tags from the DB instance to snapshots of the DB instance. Default: true

  • delete_automated_backups (Optional[bool]) – Indicates whether automated backups should be deleted or retained when you delete a DB instance. Default: true

  • deletion_protection (Optional[bool]) – Indicates whether the DB instance should have deletion protection enabled. Default: - true if removalPolicy is RETAIN, false otherwise

  • domain (Optional[str]) – The Active Directory directory ID to create the DB instance in. Default: - Do not join domain

  • domain_role (Optional[IRole]) – The IAM role to be used when making API calls to the Directory Service. The role needs the AWS-managed policy AmazonRDSDirectoryServiceAccess or equivalent. Default: - The role will be created for you if DatabaseInstanceNewProps#domain is specified

  • enable_performance_insights (Optional[bool]) – Whether to enable Performance Insights for the DB instance. Default: - false, unless performanceInsightRetention or performanceInsightEncryptionKey is set.

  • iam_authentication (Optional[bool]) – Whether to enable mapping of AWS Identity and Access Management (IAM) accounts to database accounts. Default: false

  • instance_identifier (Optional[str]) – A name for the DB instance. If you specify a name, AWS CloudFormation converts it to lowercase. Default: - a CloudFormation generated name

  • iops (Union[int, float, None]) – The number of I/O operations per second (IOPS) that the database provisions. The value must be equal to or greater than 1000. Default: - no provisioned iops if storage type is not specified. For GP3: 3,000 IOPS if allocated storage is less than 400 GiB for MariaDB, MySQL, and PostgreSQL, less than 200 GiB for Oracle and less than 20 GiB for SQL Server. 12,000 IOPS otherwise (except for SQL Server where the default is always 3,000 IOPS).

  • max_allocated_storage (Union[int, float, None]) – Upper limit to which RDS can scale the storage in GiB(Gibibyte). Default: - No autoscaling of RDS instance

  • monitoring_interval (Optional[Duration]) – The interval, in seconds, between points when Amazon RDS collects enhanced monitoring metrics for the DB instance. Default: - no enhanced monitoring

  • monitoring_role (Optional[IRole]) – Role that will be used to manage DB instance monitoring. Default: - A role is automatically created for you

  • multi_az (Optional[bool]) – Specifies if the database instance is a multiple Availability Zone deployment. Default: false

  • network_type (Optional[NetworkType]) – The network type of the DB instance. Default: - IPV4

  • option_group (Optional[IOptionGroup]) – The option group to associate with the instance. Default: - no option group

  • parameter_group (Optional[IParameterGroup]) – The DB parameter group to associate with the instance. Default: - no parameter group

  • performance_insight_encryption_key (Optional[IKey]) – The AWS KMS key for encryption of Performance Insights data. Default: - default master key

  • performance_insight_retention (Optional[PerformanceInsightRetention]) – The amount of time, in days, to retain Performance Insights data. Default: 7 this is the free tier

  • port (Union[int, float, None]) – The port for the instance. Default: - the default port for the chosen engine.

  • preferred_backup_window (Optional[str]) – The daily time range during which automated backups are performed. Constraints: - Must be in the format hh24:mi-hh24:mi. - Must be in Universal Coordinated Time (UTC). - Must not conflict with the preferred maintenance window. - Must be at least 30 minutes. Default: - a 30-minute window selected at random from an 8-hour block of time for each AWS Region. To see the time blocks available, see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithAutomatedBackups.html#USER_WorkingWithAutomatedBackups.BackupWindow

  • preferred_maintenance_window (Optional[str]) – The weekly time range (in UTC) during which system maintenance can occur. Format: ddd:hh24:mi-ddd:hh24:mi Constraint: Minimum 30-minute window Default: - a 30-minute window selected at random from an 8-hour block of time for each AWS Region, occurring on a random day of the week. To see the time blocks available, see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.Maintenance.html#Concepts.DBMaintenance

  • processor_features (Union[ProcessorFeatures, Dict[str, Any], None]) – The number of CPU cores and the number of threads per core. Default: - the default number of CPU cores and threads per core for the chosen instance class. See https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html#USER_ConfigureProcessor

  • publicly_accessible (Optional[bool]) – Indicates whether the DB instance is an internet-facing instance. If not specified, the instance’s vpcSubnets will be used to determine if the instance is internet-facing or not. Default: - true if the instance’s vpcSubnets is subnetType: SubnetType.PUBLIC, false otherwise

  • removal_policy (Optional[RemovalPolicy]) – The CloudFormation policy to apply when the instance is removed from the stack or replaced during an update. Default: - RemovalPolicy.SNAPSHOT (remove the resource, but retain a snapshot of the data)

  • s3_export_buckets (Optional[Sequence[IBucket]]) – S3 buckets that you want to load data into. This property must not be used if s3ExportRole is used. For Microsoft SQL Server: Default: - None

  • s3_export_role (Optional[IRole]) – Role that will be associated with this DB instance to enable S3 export. This property must not be used if s3ExportBuckets is used. For Microsoft SQL Server: Default: - New role is created if s3ExportBuckets is set, no role is defined otherwise

  • s3_import_buckets (Optional[Sequence[IBucket]]) – S3 buckets that you want to load data from. This feature is only supported by the Microsoft SQL Server, Oracle, and PostgreSQL engines. This property must not be used if s3ImportRole is used. For Microsoft SQL Server: Default: - None

  • s3_import_role (Optional[IRole]) – Role that will be associated with this DB instance to enable S3 import. This feature is only supported by the Microsoft SQL Server, Oracle, and PostgreSQL engines. This property must not be used if s3ImportBuckets is used. For Microsoft SQL Server: Default: - New role is created if s3ImportBuckets is set, no role is defined otherwise

  • security_groups (Optional[Sequence[ISecurityGroup]]) – The security groups to assign to the DB instance. Default: - a new security group is created

  • storage_throughput (Union[int, float, None]) – The storage throughput, specified in mebibytes per second (MiBps). Only applicable for GP3. Default: - 125 MiBps if allocated storage is less than 400 GiB for MariaDB, MySQL, and PostgreSQL, less than 200 GiB for Oracle and less than 20 GiB for SQL Server. 500 MiBps otherwise (except for SQL Server where the default is always 125 MiBps).

  • storage_type (Optional[StorageType]) – The storage type. Storage types supported are gp2, io1, standard. Default: GP2

  • subnet_group (Optional[ISubnetGroup]) – Existing subnet group for the instance. Default: - a new subnet group will be created.

  • vpc_subnets (Union[SubnetSelection, Dict[str, Any], None]) – The type of subnets to add to the created DB subnet group. Default: - private subnets

Methods

add_proxy(id, *, secrets, vpc, borrow_timeout=None, client_password_auth_type=None, db_proxy_name=None, debug_logging=None, iam_auth=None, idle_client_timeout=None, init_query=None, max_connections_percent=None, max_idle_connections_percent=None, require_tls=None, role=None, security_groups=None, session_pinning_filters=None, vpc_subnets=None)

Add a new db proxy to this instance.

Parameters:
  • id (str) –

  • secrets (Sequence[ISecret]) – The secret that the proxy uses to authenticate to the RDS DB instance or Aurora DB cluster. These secrets are stored within Amazon Secrets Manager. One or more secrets are required.

  • vpc (IVpc) – The VPC to associate with the new proxy.

  • borrow_timeout (Optional[Duration]) – The duration for a proxy to wait for a connection to become available in the connection pool. Only applies when the proxy has opened its maximum number of connections and all connections are busy with client sessions. Value must be between 1 second and 1 hour, or Duration.seconds(0) to represent unlimited. Default: cdk.Duration.seconds(120)

  • client_password_auth_type (Optional[ClientPasswordAuthType]) – Specifies the details of authentication used by a proxy to log in as a specific database user. Default: - CloudFormation defaults will apply given the specified database engine.

  • db_proxy_name (Optional[str]) – The identifier for the proxy. This name must be unique for all proxies owned by your AWS account in the specified AWS Region. An identifier must begin with a letter and must contain only ASCII letters, digits, and hyphens; it can’t end with a hyphen or contain two consecutive hyphens. Default: - Generated by CloudFormation (recommended)

  • debug_logging (Optional[bool]) – Whether the proxy includes detailed information about SQL statements in its logs. This information helps you to debug issues involving SQL behavior or the performance and scalability of the proxy connections. The debug information includes the text of SQL statements that you submit through the proxy. Thus, only enable this setting when needed for debugging, and only when you have security measures in place to safeguard any sensitive information that appears in the logs. Default: false

  • iam_auth (Optional[bool]) – Whether to require or disallow AWS Identity and Access Management (IAM) authentication for connections to the proxy. Default: false

  • idle_client_timeout (Optional[Duration]) – The number of seconds that a connection to the proxy can be inactive before the proxy disconnects it. You can set this value higher or lower than the connection timeout limit for the associated database. Default: cdk.Duration.minutes(30)

  • init_query (Optional[str]) – One or more SQL statements for the proxy to run when opening each new database connection. Typically used with SET statements to make sure that each connection has identical settings such as time zone and character set. For multiple statements, use semicolons as the separator. You can also include multiple variables in a single SET statement, such as SET x=1, y=2. not currently supported for PostgreSQL. Default: - no initialization query

  • max_connections_percent (Union[int, float, None]) – The maximum size of the connection pool for each target in a target group. For Aurora MySQL, it is expressed as a percentage of the max_connections setting for the RDS DB instance or Aurora DB cluster used by the target group. 1-100 Default: 100

  • max_idle_connections_percent (Union[int, float, None]) – Controls how actively the proxy closes idle database connections in the connection pool. A high value enables the proxy to leave a high percentage of idle connections open. A low value causes the proxy to close idle client connections and return the underlying database connections to the connection pool. For Aurora MySQL, it is expressed as a percentage of the max_connections setting for the RDS DB instance or Aurora DB cluster used by the target group. between 0 and MaxConnectionsPercent Default: 50

  • require_tls (Optional[bool]) – A Boolean parameter that specifies whether Transport Layer Security (TLS) encryption is required for connections to the proxy. By enabling this setting, you can enforce encrypted TLS connections to the proxy. Default: true

  • role (Optional[IRole]) – IAM role that the proxy uses to access secrets in AWS Secrets Manager. Default: - A role will automatically be created

  • security_groups (Optional[Sequence[ISecurityGroup]]) – One or more VPC security groups to associate with the new proxy. Default: - No security groups

  • session_pinning_filters (Optional[Sequence[SessionPinningFilter]]) – Each item in the list represents a class of SQL operations that normally cause all later statements in a session using a proxy to be pinned to the same underlying database connection. Including an item in the list exempts that class of SQL operations from the pinning behavior. Default: - no session pinning filters

  • vpc_subnets (Union[SubnetSelection, Dict[str, Any], None]) – The subnets used by the proxy. Default: - the VPC default strategy if not specified.

Return type:

DatabaseProxy

add_rotation_multi_user(id, *, secret, automatically_after=None, endpoint=None, exclude_characters=None, rotate_immediately_on_update=None, security_group=None, vpc_subnets=None)

Adds the multi user rotation to this instance.

Parameters:
  • id (str) –

  • secret (ISecret) – The secret to rotate. It must be a JSON string with the following format:: { “engine”: <required: database engine>, “host”: <required: instance host name>, “username”: <required: username>, “password”: <required: password>, “dbname”: <optional: database name>, “port”: <optional: if not specified, default port will be used>, “masterarn”: <required: the arn of the master secret which will be used to create users/change passwords> }

  • automatically_after (Optional[Duration]) – Specifies the number of days after the previous rotation before Secrets Manager triggers the next automatic rotation. Default: - 30 days

  • endpoint (Optional[IInterfaceVpcEndpoint]) – The VPC interface endpoint to use for the Secrets Manager API. If you enable private DNS hostnames for your VPC private endpoint (the default), you don’t need to specify an endpoint. The standard Secrets Manager DNS hostname the Secrets Manager CLI and SDKs use by default (https://secretsmanager..amazonaws.com) automatically resolves to your VPC endpoint. Default: https://secretsmanager..amazonaws.com

  • exclude_characters (Optional[str]) – Specifies characters to not include in generated passwords. Default: “ %+~`#$&*()|[]{}:;<>?!’/@”"

  • rotate_immediately_on_update (Optional[bool]) – Specifies whether to rotate the secret immediately or wait until the next scheduled rotation window. Default: true

  • security_group (Optional[ISecurityGroup]) – The security group for the Lambda rotation function. Default: - a new security group is created

  • vpc_subnets (Union[SubnetSelection, Dict[str, Any], None]) – Where to place the rotation Lambda function. Default: - same placement as instance or cluster

Return type:

SecretRotation

add_rotation_single_user(*, automatically_after=None, endpoint=None, exclude_characters=None, rotate_immediately_on_update=None, security_group=None, vpc_subnets=None)

Adds the single user rotation of the master password to this instance.

Parameters:
  • automatically_after (Optional[Duration]) – Specifies the number of days after the previous rotation before Secrets Manager triggers the next automatic rotation. Default: - 30 days

  • endpoint (Optional[IInterfaceVpcEndpoint]) – The VPC interface endpoint to use for the Secrets Manager API. If you enable private DNS hostnames for your VPC private endpoint (the default), you don’t need to specify an endpoint. The standard Secrets Manager DNS hostname the Secrets Manager CLI and SDKs use by default (https://secretsmanager..amazonaws.com) automatically resolves to your VPC endpoint. Default: https://secretsmanager..amazonaws.com

  • exclude_characters (Optional[str]) – Specifies characters to not include in generated passwords. Default: “ %+~`#$&*()|[]{}:;<>?!’/@”"

  • rotate_immediately_on_update (Optional[bool]) – Specifies whether to rotate the secret immediately or wait until the next scheduled rotation window. Default: true

  • security_group (Optional[ISecurityGroup]) – The security group for the Lambda rotation function. Default: - a new security group is created

  • vpc_subnets (Union[SubnetSelection, Dict[str, Any], None]) – Where to place the rotation Lambda function. Default: - same placement as instance or cluster

Return type:

SecretRotation

apply_removal_policy(policy)

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:

policy (RemovalPolicy) –

Return type:

None

as_secret_attachment_target()

Renders the secret attachment target specifications.

Return type:

SecretAttachmentTargetProps

grant_connect(grantee, db_user=None)

Grant the given identity connection access to the database.

Parameters:
  • grantee (IGrantable) – the Principal to grant the permissions to.

  • db_user (Optional[str]) – the name of the database user to allow connecting as to the db instance, or the default database user, obtained from the Secret, if not specified.

Return type:

Grant

metric(metric_name, *, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

Return the given named metric for this DBInstance.

Parameters:
  • metric_name (str) –

  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

metric_cpu_utilization(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

The percentage of CPU utilization.

Average over 5 minutes

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

metric_database_connections(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

The number of database connections in use.

Average over 5 minutes

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

metric_free_storage_space(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

The amount of available storage space.

Average over 5 minutes

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

metric_freeable_memory(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

The amount of available random access memory.

Average over 5 minutes

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

metric_read_iops(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

The average number of disk write I/O operations per second.

Average over 5 minutes

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

metric_write_iops(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

The average number of disk read I/O operations per second.

Average over 5 minutes

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

on_event(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)

Defines a CloudWatch event rule which triggers for instance events.

Use rule.addEventPattern(pattern) to specify a filter.

Parameters:
  • id (str) –

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

  • cross_stack_scope (Optional[Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

Return type:

Rule

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

cloudwatch_log_groups

The log group is created when cloudwatchLogsExports is set.

Each export value will create a separate log group.

connections

Access to network connections.

db_instance_endpoint_address

The instance endpoint address.

db_instance_endpoint_port

The instance endpoint port.

engine

The engine of this database Instance.

May be not known for imported Instances if it wasn’t provided explicitly, or for read replicas.

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

instance_arn

The instance arn.

instance_endpoint

The instance endpoint.

instance_identifier

The instance identifier.

instance_resource_id

The AWS Region-unique, immutable identifier for the DB instance.

This identifier is found in AWS CloudTrail log entries whenever the AWS KMS key for the DB instance is accessed.

node

The tree node.

secret

The AWS Secrets Manager secret attached to the instance.

stack

The stack in which this resource is defined.

vpc

The VPC where this database instance is deployed.

Static Methods

classmethod from_database_instance_attributes(scope, id, *, instance_endpoint_address, instance_identifier, port, security_groups, engine=None, instance_resource_id=None)

Import an existing database instance.

Parameters:
  • scope (Construct) –

  • id (str) –

  • instance_endpoint_address (str) – The endpoint address.

  • instance_identifier (str) – The instance identifier.

  • port (Union[int, float]) – The database port.

  • security_groups (Sequence[ISecurityGroup]) – The security groups of the instance.

  • engine (Optional[IInstanceEngine]) – The engine of the existing database Instance. Default: - the imported Instance’s engine is unknown

  • instance_resource_id (Optional[str]) – The AWS Region-unique, immutable identifier for the DB instance. This identifier is found in AWS CloudTrail log entries whenever the AWS KMS key for the DB instance is accessed.

Return type:

IDatabaseInstance

classmethod is_construct(x)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.

classmethod is_owned_resource(construct)

Returns true if the construct was created by CDK, and false otherwise.

Parameters:

construct (IConstruct) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool