elasticache: Serverless cache attr_endpoint returning aws_cdk.Reference
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 74
Description
### Describe the bug
The `attr_endpoint` attribute of the `CfnServerlessCache` should be a string or be resolvable to a string but instead it's `aws_cdk.Reference` instead.
### Expected Behavior
I expected that this script should be able to run:
```
import aws_cdk as cdk
from aws_cdk import (
Stack,
aws_elasticache as elasticache,
aws_ssm as ssm
)
from constructs import Construct
import os
class test_stack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
self.redis_cluster = elasticache.CfnServerlessCache(
self,
"RedisCluster",
engine="redis",
serverless_cache_name="ServerlessCache",
)
self.redis_endpoint = ssm.StringParameter(
self,
"redis-endpoint",
parameter_name="redis_endpoint",
string_value=self.redis_cluster.attr_endpoint
)
if __name__ == "__main__":
app = cdk.App()
test_stack(app, "test",
env=cdk.Environment(
account=os.getenv('CDK_DEFAULT_ACCOUNT'),
region=os.getenv('CDK_DEFAULT_REGION')
))
app.synth()
```
### Current Behavior
Instead of running successfully this traceback is returned:
Traceback (most recent call last):
File "/Users/home/test.py", line 32, in
test_stack(app, "test",
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jsii/_runtime.py", line 118, in __call__
inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
File "/Users/home/test.py", line 22, in __init__
self.redis_endpoint = ssm.StringParameter(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jsii/_runtime.py", line 118, in __call__
inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aws_cdk/aws_ssm/__init__.py", line 8397, in __init__
props = StringParameterProps(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aws_cdk/aws_ssm/__init__.py", line 8924, in __init__
check_type(argname="argument string_value", value=string_value, expected_type=type_hints["string_value"])
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/typeguard/__init__.py", line 785, in check_type
raise TypeError(
TypeError: type of argument string_value must be str; got aws_cdk.Reference instead
### Reproduction Steps
Running this script below should reproduce the bug:
```
import aws_cdk as cdk
from aws_cdk import (
Stack,
aws_elasticache as elasticache,
aws_ssm as ssm
)
from constructs import Construct
import os
class test_stack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
self.redis_cluster = elasticache.CfnServerlessCache(
self,
"RedisCluster",
engine="redis",
serverless_cache_name="ServerlessCache",
)
self.redis_endpoint = ssm.StringParameter(
self,
"redis-endpoint",
parameter_name="redis_endpoint",
string_value=self.redis_cluster.attr_endpoint
)
if __name__ == "__main__":
app = cdk.App()
test_stack(app, "test",
env=cdk.Environment(
account=os.getenv('CDK_DEFAULT_ACCOUNT'),
region=os.getenv('CDK_DEFAULT_REGION')
))
app.synth()
```
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.113.0
### Framework Version
_No response_
### Node.js Version
v18.2.0
### OS
MacOS 13.5.2
### Language
Python
### Language Version
3.10
### Other information
_No response_
Contributor guide
Research direction
Start at the CfnServerlessCache.attr_endpoint entry point and compare its value handling with the ssm.StringParameter string_value input. Run the provided Python reproduction and synthesize the stack to observe the failure. Done means attr_endpoint is accepted as a string or string-resolvable value without the reported type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100