CfnDatabase

class aws_cdk.aws_lightsail.CfnDatabase(scope, id, *, master_database_name, master_username, relational_database_blueprint_id, relational_database_bundle_id, relational_database_name, availability_zone=None, backup_retention=None, ca_certificate_identifier=None, master_user_password=None, preferred_backup_window=None, preferred_maintenance_window=None, publicly_accessible=None, relational_database_parameters=None, rotate_master_user_password=None, tags=None)

Bases: CfnResource

A CloudFormation AWS::Lightsail::Database.

The AWS::Lightsail::Database resource specifies an Amazon Lightsail database.

CloudformationResource

AWS::Lightsail::Database

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_lightsail as lightsail

cfn_database = lightsail.CfnDatabase(self, "MyCfnDatabase",
    master_database_name="masterDatabaseName",
    master_username="masterUsername",
    relational_database_blueprint_id="relationalDatabaseBlueprintId",
    relational_database_bundle_id="relationalDatabaseBundleId",
    relational_database_name="relationalDatabaseName",

    # the properties below are optional
    availability_zone="availabilityZone",
    backup_retention=False,
    ca_certificate_identifier="caCertificateIdentifier",
    master_user_password="masterUserPassword",
    preferred_backup_window="preferredBackupWindow",
    preferred_maintenance_window="preferredMaintenanceWindow",
    publicly_accessible=False,
    relational_database_parameters=[lightsail.CfnDatabase.RelationalDatabaseParameterProperty(
        allowed_values="allowedValues",
        apply_method="applyMethod",
        apply_type="applyType",
        data_type="dataType",
        description="description",
        is_modifiable=False,
        parameter_name="parameterName",
        parameter_value="parameterValue"
    )],
    rotate_master_user_password=False,
    tags=[CfnTag(
        key="key",
        value="value"
    )]
)

Create a new AWS::Lightsail::Database.

Parameters
  • scope (Construct) –

    • scope in which this resource is defined.

  • id (str) –

    • scoped id of the resource.

  • master_database_name (str) – The meaning of this parameter differs according to the database engine you use. MySQL The name of the database to create when the Lightsail database resource is created. If this parameter isn’t specified, no database is created in the database resource. Constraints: - Must contain 1-64 letters or numbers. - Must begin with a letter. Subsequent characters can be letters, underscores, or numbers (0-9). - Can’t be a word reserved by the specified database engine. For more information about reserved words in MySQL, see the Keywords and Reserved Words articles for MySQL 5.6 , MySQL 5.7 , and MySQL 8.0 . PostgreSQL The name of the database to create when the Lightsail database resource is created. If this parameter isn’t specified, a database named postgres is created in the database resource. Constraints: - Must contain 1-63 letters or numbers. - Must begin with a letter. Subsequent characters can be letters, underscores, or numbers (0-9). - Can’t be a word reserved by the specified database engine. For more information about reserved words in PostgreSQL, see the SQL Key Words articles for PostgreSQL 9.6 , PostgreSQL 10 , PostgreSQL 11 , and PostgreSQL 12 .

  • master_username (str) –

    The name for the primary user. MySQL Constraints: - Required for MySQL. - Must be 1-16 letters or numbers. Can contain underscores. - First character must be a letter. - Can’t be a reserved word for the chosen database engine. For more information about reserved words in MySQL 5.6 or 5.7, see the Keywords and Reserved Words articles for MySQL 5.6 , MySQL 5.7 , or MySQL 8.0 . PostgreSQL Constraints: - Required for PostgreSQL. - Must be 1-63 letters or numbers. Can contain underscores. - First character must be a letter. - Can’t be a reserved word for the chosen database engine. For more information about reserved words in MySQL 5.6 or 5.7, see the Keywords and Reserved Words articles for PostgreSQL 9.6 , PostgreSQL 10 , PostgreSQL 11 , and PostgreSQL 12 .

  • relational_database_blueprint_id (str) – The blueprint ID for the database (for example, mysql_8_0 ).

  • relational_database_bundle_id (str) – The bundle ID for the database (for example, medium_1_0 ).

  • relational_database_name (str) – The name of the instance.

  • availability_zone (Optional[str]) – The Availability Zone for the database.

  • backup_retention (Union[bool, IResolvable, None]) – A Boolean value indicating whether automated backup retention is enabled for the database.

  • ca_certificate_identifier (Optional[str]) – The certificate associated with the database.

  • master_user_password (Optional[str]) – The password for the primary user of the database. The password can include any printable ASCII character except the following: /, “, or @. It cannot contain spaces. .. epigraph:: The MasterUserPassword and RotateMasterUserPassword parameters cannot be used together in the same template. MySQL Constraints: Must contain 8-41 characters. PostgreSQL Constraints: Must contain 8-128 characters.

  • preferred_backup_window (Optional[str]) – The daily time range during which automated backups are created for the database (for example, 16:00-16:30 ).

  • preferred_maintenance_window (Optional[str]) – The weekly time range during which system maintenance can occur for the database, formatted as follows: ddd:hh24:mi-ddd:hh24:mi . For example, Tue:17:00-Tue:17:30 .

  • publicly_accessible (Union[bool, IResolvable, None]) – A Boolean value indicating whether the database is accessible to anyone on the internet.

  • relational_database_parameters (Union[IResolvable, Sequence[Union[IResolvable, RelationalDatabaseParameterProperty, Dict[str, Any]]], None]) – An array of parameters for the database.

  • rotate_master_user_password (Union[bool, IResolvable, None]) – A Boolean value indicating whether to change the primary user password to a new, strong password generated by Lightsail . .. epigraph:: The RotateMasterUserPassword and MasterUserPassword parameters cannot be used together in the same template.

  • tags (Optional[Sequence[Union[CfnTag, Dict[str, Any]]]]) – An array of key-value pairs to apply to this resource. For more information, see Tag in the AWS CloudFormation User Guide . .. epigraph:: The Value of Tags is optional for Lightsail resources.

Methods

add_deletion_override(path)

Syntactic sugar for addOverride(path, undefined).

Parameters

path (str) – The path of the value to delete.

Return type

None

add_depends_on(target)

Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

Parameters

target (CfnResource) –

Return type

None

add_metadata(key, value)

Add a value to the CloudFormation Resource Metadata.

Parameters
  • key (str) –

  • value (Any) –

See

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.

Return type

None

add_override(path, value)

Adds an override to the synthesized CloudFormation resource.

To add a property override, either use addPropertyOverride or prefix path with “Properties.” (i.e. Properties.TopicName).

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example:

cfn_resource.add_override("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", ["myattribute"])
cfn_resource.add_override("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE")

would add the overrides Example:

"Properties": {
   "GlobalSecondaryIndexes": [
     {
       "Projection": {
         "NonKeyAttributes": [ "myattribute" ]
         ...
       }
       ...
     },
     {
       "ProjectionType": "INCLUDE"
       ...
     },
   ]
   ...
}

The value argument to addOverride will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.

Parameters
  • path (str) –

    • The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.

  • value (Any) –

    • The value. Could be primitive or complex.

Return type

None

add_property_deletion_override(property_path)

Adds an override that deletes the value of a property from the resource definition.

Parameters

property_path (str) – The path to the property.

Return type

None

add_property_override(property_path, value)

Adds an override to a resource property.

Syntactic sugar for addOverride("Properties.<...>", value).

Parameters
  • property_path (str) – The path of the property.

  • value (Any) – The value.

Return type

None

apply_removal_policy(policy=None, *, apply_to_update_replace_policy=None, default=None)

Sets the deletion policy of the resource based on the removal policy specified.

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 (Optional[RemovalPolicy]) –

  • apply_to_update_replace_policy (Optional[bool]) – Apply the same deletion policy to the resource’s “UpdateReplacePolicy”. Default: true

  • default (Optional[RemovalPolicy]) – The default policy to apply in case the removal policy is not defined. Default: - Default value is resource specific. To determine the default value for a resoure, please consult that specific resource’s documentation.

Return type

None

get_att(attribute_name)

Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.

Parameters

attribute_name (str) – The name of the attribute.

Return type

Reference

get_metadata(key)

Retrieve a value value from the CloudFormation Resource Metadata.

Parameters

key (str) –

See

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.

Return type

Any

inspect(inspector)

Examines the CloudFormation resource and discloses attributes.

Parameters

inspector (TreeInspector) –

  • tree inspector to collect and process attributes.

Return type

None

override_logical_id(new_logical_id)

Overrides the auto-generated logical ID with a specific ID.

Parameters

new_logical_id (str) – The new logical ID to use for this stack element.

Return type

None

to_string()

Returns a string representation of this construct.

Return type

str

Returns

a string representation of this resource

Attributes

CFN_RESOURCE_TYPE_NAME = 'AWS::Lightsail::Database'
attr_database_arn

The Amazon Resource Name (ARN) of the database (for example, arn:aws:lightsail:us-east-2:123456789101:RelationalDatabase/244ad76f-8aad-4741-809f-12345EXAMPLE ).

CloudformationAttribute

DatabaseArn

Return type

str

availability_zone

The Availability Zone for the database.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-availabilityzone

Return type

Optional[str]

backup_retention

A Boolean value indicating whether automated backup retention is enabled for the database.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-backupretention

Return type

Union[bool, IResolvable, None]

ca_certificate_identifier

The certificate associated with the database.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-cacertificateidentifier

Return type

Optional[str]

cfn_options

Options for this resource, such as condition, update policy etc.

Return type

ICfnResourceOptions

cfn_resource_type

AWS resource type.

Return type

str

creation_stack

return:

the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.

Return type

List[str]

logical_id

The logical ID for this CloudFormation stack element.

The logical ID of the element is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

Return type

str

Returns

the logical ID as a stringified token. This value will only get resolved during synthesis.

master_database_name

The meaning of this parameter differs according to the database engine you use.

MySQL

The name of the database to create when the Lightsail database resource is created. If this parameter isn’t specified, no database is created in the database resource.

Constraints:

  • Must contain 1-64 letters or numbers.

  • Must begin with a letter. Subsequent characters can be letters, underscores, or numbers (0-9).

  • Can’t be a word reserved by the specified database engine.

For more information about reserved words in MySQL, see the Keywords and Reserved Words articles for MySQL 5.6 , MySQL 5.7 , and MySQL 8.0 .

PostgreSQL

The name of the database to create when the Lightsail database resource is created. If this parameter isn’t specified, a database named postgres is created in the database resource.

Constraints:

  • Must contain 1-63 letters or numbers.

  • Must begin with a letter. Subsequent characters can be letters, underscores, or numbers (0-9).

  • Can’t be a word reserved by the specified database engine.

For more information about reserved words in PostgreSQL, see the SQL Key Words articles for PostgreSQL 9.6 , PostgreSQL 10 , PostgreSQL 11 , and PostgreSQL 12 .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-masterdatabasename

Return type

str

master_user_password

The password for the primary user of the database.

The password can include any printable ASCII character except the following: /, “, or @. It cannot contain spaces. .. epigraph:

The ``MasterUserPassword`` and ``RotateMasterUserPassword`` parameters cannot be used together in the same template.

MySQL

Constraints: Must contain 8-41 characters.

PostgreSQL

Constraints: Must contain 8-128 characters.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-masteruserpassword

Return type

Optional[str]

master_username

The name for the primary user.

MySQL

Constraints:

  • Required for MySQL.

  • Must be 1-16 letters or numbers. Can contain underscores.

  • First character must be a letter.

  • Can’t be a reserved word for the chosen database engine.

For more information about reserved words in MySQL 5.6 or 5.7, see the Keywords and Reserved Words articles for MySQL 5.6 , MySQL 5.7 , or MySQL 8.0 .

PostgreSQL

Constraints:

  • Required for PostgreSQL.

  • Must be 1-63 letters or numbers. Can contain underscores.

  • First character must be a letter.

  • Can’t be a reserved word for the chosen database engine.

For more information about reserved words in MySQL 5.6 or 5.7, see the Keywords and Reserved Words articles for PostgreSQL 9.6 , PostgreSQL 10 , PostgreSQL 11 , and PostgreSQL 12 .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-masterusername

Return type

str

node

The construct tree node associated with this construct.

Return type

ConstructNode

preferred_backup_window

The daily time range during which automated backups are created for the database (for example, 16:00-16:30 ).

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-preferredbackupwindow

Return type

Optional[str]

preferred_maintenance_window

ddd:hh24:mi-ddd:hh24:mi .

For example, Tue:17:00-Tue:17:30 .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-preferredmaintenancewindow

Type

The weekly time range during which system maintenance can occur for the database, formatted as follows

Return type

Optional[str]

publicly_accessible

A Boolean value indicating whether the database is accessible to anyone on the internet.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-publiclyaccessible

Return type

Union[bool, IResolvable, None]

ref

Return a string that will be resolved to a CloudFormation { Ref } for this element.

If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).

Return type

str

relational_database_blueprint_id

The blueprint ID for the database (for example, mysql_8_0 ).

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-relationaldatabaseblueprintid

Return type

str

relational_database_bundle_id

The bundle ID for the database (for example, medium_1_0 ).

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-relationaldatabasebundleid

Return type

str

relational_database_name

The name of the instance.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-relationaldatabasename

Return type

str

relational_database_parameters

An array of parameters for the database.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-relationaldatabaseparameters

Return type

Union[IResolvable, List[Union[IResolvable, RelationalDatabaseParameterProperty]], None]

rotate_master_user_password

A Boolean value indicating whether to change the primary user password to a new, strong password generated by Lightsail .

The RotateMasterUserPassword and MasterUserPassword parameters cannot be used together in the same template.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-rotatemasteruserpassword

Return type

Union[bool, IResolvable, None]

stack

The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).

Return type

Stack

tags

An array of key-value pairs to apply to this resource.

For more information, see Tag in the AWS CloudFormation User Guide . .. epigraph:

The ``Value`` of ``Tags`` is optional for Lightsail resources.
Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lightsail-database.html#cfn-lightsail-database-tags

Return type

TagManager

Static Methods

classmethod is_cfn_element(x)

Returns true if a construct is a stack element (i.e. part of the synthesized cloudformation template).

Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.

Parameters

x (Any) –

Return type

bool

Returns

The construct as a stack element or undefined if it is not a stack element.

classmethod is_cfn_resource(construct)

Check whether the given construct is a CfnResource.

Parameters

construct (IConstruct) –

Return type

bool

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool

RelationalDatabaseParameterProperty

class CfnDatabase.RelationalDatabaseParameterProperty(*, allowed_values=None, apply_method=None, apply_type=None, data_type=None, description=None, is_modifiable=None, parameter_name=None, parameter_value=None)

Bases: object

RelationalDatabaseParameter is a property of the AWS::Lightsail::Database resource. It describes parameters for the database.

Parameters
  • allowed_values (Optional[str]) – The valid range of values for the parameter.

  • apply_method (Optional[str]) – Indicates when parameter updates are applied. Can be immediate or pending-reboot .

  • apply_type (Optional[str]) – Specifies the engine-specific parameter type.

  • data_type (Optional[str]) – The valid data type of the parameter.

  • description (Optional[str]) – A description of the parameter.

  • is_modifiable (Union[bool, IResolvable, None]) – A Boolean value indicating whether the parameter can be modified.

  • parameter_name (Optional[str]) – The name of the parameter.

  • parameter_value (Optional[str]) – The value for the parameter.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lightsail-database-relationaldatabaseparameter.html

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_lightsail as lightsail

relational_database_parameter_property = lightsail.CfnDatabase.RelationalDatabaseParameterProperty(
    allowed_values="allowedValues",
    apply_method="applyMethod",
    apply_type="applyType",
    data_type="dataType",
    description="description",
    is_modifiable=False,
    parameter_name="parameterName",
    parameter_value="parameterValue"
)

Attributes

allowed_values

The valid range of values for the parameter.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lightsail-database-relationaldatabaseparameter.html#cfn-lightsail-database-relationaldatabaseparameter-allowedvalues

Return type

Optional[str]

apply_method

Indicates when parameter updates are applied.

Can be immediate or pending-reboot .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lightsail-database-relationaldatabaseparameter.html#cfn-lightsail-database-relationaldatabaseparameter-applymethod

Return type

Optional[str]

apply_type

Specifies the engine-specific parameter type.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lightsail-database-relationaldatabaseparameter.html#cfn-lightsail-database-relationaldatabaseparameter-applytype

Return type

Optional[str]

data_type

The valid data type of the parameter.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lightsail-database-relationaldatabaseparameter.html#cfn-lightsail-database-relationaldatabaseparameter-datatype

Return type

Optional[str]

description

A description of the parameter.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lightsail-database-relationaldatabaseparameter.html#cfn-lightsail-database-relationaldatabaseparameter-description

Return type

Optional[str]

is_modifiable

A Boolean value indicating whether the parameter can be modified.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lightsail-database-relationaldatabaseparameter.html#cfn-lightsail-database-relationaldatabaseparameter-ismodifiable

Return type

Union[bool, IResolvable, None]

parameter_name

The name of the parameter.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lightsail-database-relationaldatabaseparameter.html#cfn-lightsail-database-relationaldatabaseparameter-parametername

Return type

Optional[str]

parameter_value

The value for the parameter.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lightsail-database-relationaldatabaseparameter.html#cfn-lightsail-database-relationaldatabaseparameter-parametervalue

Return type

Optional[str]