Describe the bug
After changing two lines of code (replacing DatabaseInstance with DatabaseInstanceFromSnapshot and adding a snapshot_identifier) the resulting DB instance object's secret property changed from a usable value to None. The documentation doesn't mention in which circumstances the secret value is not None, but this is surprising.
Expected Behavior
secret should still be an ISecret.
Current Behavior
secret is None.
Reproduction Steps
Succeeds:
from os import environ
from typing import Any, Optional
from aws_cdk import App, Environment, Stack, aws_ec2, aws_rds
from constructs import Construct
app = App()
environment = Environment(
account=environ["CDK_DEFAULT_ACCOUNT"], region=environ["CDK_DEFAULT_REGION"]
)
class DBStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs: Optional[Any]) -> None:
super().__init__(scope, construct_id, **kwargs)
db = aws_rds.DatabaseInstance(
self,
"db-replica",
engine=aws_rds.DatabaseInstanceEngine.postgres(
version=aws_rds.PostgresEngineVersion.VER_10_16
),
vpc=aws_ec2.Vpc.from_lookup(self, "vpc", tags={"bde-processor-db-replica": "yes"}),
vpc_subnets=aws_ec2.SubnetSelection(subnet_type=aws_ec2.SubnetType.PRIVATE_ISOLATED),
)
assert db.secret is not None
db_stack = DBStack(app, "database-stack", env=environment)
app.synth()
Fails:
from os import environ
from typing import Any, Optional
from aws_cdk import App, Environment, Stack, aws_ec2, aws_rds
from constructs import Construct
app = App()
environment = Environment(
account=environ["CDK_DEFAULT_ACCOUNT"], region=environ["CDK_DEFAULT_REGION"]
)
class DBStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs: Optional[Any]) -> None:
super().__init__(scope, construct_id, **kwargs)
db = aws_rds.DatabaseInstanceFromSnapshot(
self,
"db-replica",
snapshot_identifier="release-test",
engine=aws_rds.DatabaseInstanceEngine.postgres(
version=aws_rds.PostgresEngineVersion.VER_10_16
),
vpc=aws_ec2.Vpc.from_lookup(self, "vpc", tags={"bde-processor-db-replica": "yes"}),
vpc_subnets=aws_ec2.SubnetSelection(subnet_type=aws_ec2.SubnetType.PRIVATE_ISOLATED),
)
assert db.secret is not None
db_stack = DBStack(app, "database-stack", env=environment)
app.synth()
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.24.1 (build 585f9ca)
Framework Version
No response
Node.js Version
v14.18.1
OS
NixOS
Language
Python
Language Version
3.8.11
Other information
No response
Describe the bug
After changing two lines of code (replacing
DatabaseInstancewithDatabaseInstanceFromSnapshotand adding asnapshot_identifier) the resulting DB instance object'ssecretproperty changed from a usable value toNone. The documentation doesn't mention in which circumstances thesecretvalue is notNone, but this is surprising.Expected Behavior
secretshould still be anISecret.Current Behavior
secretisNone.Reproduction Steps
Succeeds:
Fails:
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.24.1 (build 585f9ca)
Framework Version
No response
Node.js Version
v14.18.1
OS
NixOS
Language
Python
Language Version
3.8.11
Other information
No response