OptionGroup
- class aws_cdk.aws_rds.OptionGroup(scope, id, *, configurations, engine, description=None)
Bases:
Resource
An option group.
- ExampleMetadata:
lit=aws-rds/test/integ.instance.lit.ts infused
Example:
# Set open cursors with parameter group parameter_group = rds.ParameterGroup(self, "ParameterGroup", engine=rds.DatabaseInstanceEngine.oracle_se2(version=rds.OracleEngineVersion.VER_19_0_0_0_2020_04_R1), parameters={ "open_cursors": "2500" } ) option_group = rds.OptionGroup(self, "OptionGroup", engine=rds.DatabaseInstanceEngine.oracle_se2(version=rds.OracleEngineVersion.VER_19_0_0_0_2020_04_R1), configurations=[cdk.aws_rds.OptionConfiguration( name="LOCATOR" ), cdk.aws_rds.OptionConfiguration( name="OEM", port=1158, vpc=vpc ) ] ) # Allow connections to OEM option_group.option_connections.OEM.connections.allow_default_port_from_any_ipv4() # Database instance with production values instance = rds.DatabaseInstance(self, "Instance", engine=rds.DatabaseInstanceEngine.oracle_se2(version=rds.OracleEngineVersion.VER_19_0_0_0_2020_04_R1), license_model=rds.LicenseModel.BRING_YOUR_OWN_LICENSE, instance_type=ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MEDIUM), multi_az=True, storage_type=rds.StorageType.IO1, credentials=rds.Credentials.from_username("syscdk"), vpc=vpc, database_name="ORCL", storage_encrypted=True, backup_retention=cdk.Duration.days(7), monitoring_interval=cdk.Duration.seconds(60), enable_performance_insights=True, cloudwatch_logs_exports=["trace", "audit", "alert", "listener" ], cloudwatch_logs_retention=logs.RetentionDays.ONE_MONTH, auto_minor_version_upgrade=True, # required to be true if LOCATOR is used in the option group option_group=option_group, parameter_group=parameter_group, removal_policy=RemovalPolicy.DESTROY ) # Allow connections on default port from any IPV4 instance.connections.allow_default_port_from_any_ipv4() # Rotate the master user password every 30 days instance.add_rotation_single_user() # Add alarm for high CPU cloudwatch.Alarm(self, "HighCPU", metric=instance.metric_cPUUtilization(), threshold=90, evaluation_periods=1 ) # Trigger Lambda function on instance availability events fn = lambda_.Function(self, "Function", code=lambda_.Code.from_inline("exports.handler = (event) => console.log(event);"), handler="index.handler", runtime=lambda_.Runtime.NODEJS_18_X ) availability_rule = instance.on_event("Availability", target=targets.LambdaFunction(fn)) availability_rule.add_event_pattern( detail={ "EventCategories": ["availability" ] } )
- Parameters:
scope (
Construct
) –id (
str
) –configurations (
Sequence
[Union
[OptionConfiguration
,Dict
[str
,Any
]]]) – The configurations for this option group.engine (
IInstanceEngine
) – The database engine that this option group is associated with.description (
Optional
[str
]) – A description of the option group. Default: a CDK generated description
Methods
- add_configuration(*, name, port=None, security_groups=None, settings=None, version=None, vpc=None)
Adds a configuration to this OptionGroup.
This method is a no-op for an imported OptionGroup.
- Parameters:
name (
str
) – The name of the option.port (
Union
[int
,float
,None
]) – The port number that this option uses. Ifport
is specified thenvpc
must also be specified. Default: - no portsecurity_groups (
Optional
[Sequence
[ISecurityGroup
]]) – Optional list of security groups to use for this option, ifvpc
is specified. If no groups are provided, a default one will be created. Default: - a default group will be created ifport
orvpc
are specified.settings (
Optional
[Mapping
[str
,str
]]) – The settings for the option. Default: - no settingsversion (
Optional
[str
]) – The version for the option. Default: - no versionvpc (
Optional
[IVpc
]) – The VPC where a security group should be created for this option. Ifvpc
is specified thenport
must also be specified. Default: - no VPC
- Return type:
bool
- 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
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- 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.
- node
The tree node.
- option_connections
The connections object for the options.
- option_group_name
The name of the option group.
- stack
The stack in which this resource is defined.
Static Methods
- classmethod from_option_group_name(scope, id, option_group_name)
Import an existing option group.
- Parameters:
scope (
Construct
) –id (
str
) –option_group_name (
str
) –
- Return type:
- classmethod is_construct(x)
Checks if
x
is a construct.Use this method instead of
instanceof
to properly detectConstruct
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 classConstruct
in each copy of theconstructs
library is seen as a different class, and an instance of one class will not test asinstanceof
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 theconstructs
library can be accidentally installed, andinstanceof
will behave unpredictably. It is safest to avoid usinginstanceof
, 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 extendsConstruct
.
- 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