-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack: I can not use stack as param in another stack #26053
Comments
Looks like the error comes from Are you able to run this? from aws_cdk import (
Stack, CfnOutput,
aws_ec2 as ec2,
)
from constructs import Construct
class VpcStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
self.vpc = ec2.Vpc.from_lookup(self, 'Vpc', is_default=True)
@property
def get_vpc_id(self) -> str:
return self.vpc.vpc_id
class ConsumerStack(Stack):
def __init__(self, scope: Construct, construct_id: str, vpc_stack, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
CfnOutput(self, construct_id, value=str(vpc_stack.get_vpc_id)) On |
Yes, it works like my code has been implemented as well # str(vpc_stack.get_vpc_id) something likes <property object at 0x10d389e50>
CfnOutput(self, id, value=str(vpc_stack.get_vpc_id), export_name="tired") same way with you CfnOutput(self, construct_id, value=vpc_stack.get_vpc_id) that returned ConsumerStack | <property object at 0x1097f5a90> But I need to inject the real data into some next steps likes real subnetid, real vpc_id, etc.. subnet_ids=[
vpc_stack.get_etl_subnet_id_1a,
vpc_stack.get_etl_subnet_id_1b,
vpc_stack.get_etl_subnet_id_1c
],
transit_gateway_id=DX_TGW_ID,
vpc_id=vpc_stack.get_vpc_id, Normally it should be worked as I have done many times before, the real value will be put while cdk deploy running. If I remove str cast then error returned: ConsumerStack(app, "**### ConsumerStack**", vpc_stack=DebugVpcStack, env=env_sing)
File "/Users/wormym/cdp-cdk/.venv/lib/python3.8/site-packages/jsii/_runtime.py", line 112, in __call__
inst = super().__call__(*args, **kwargs)
File "/Users/wormym/cdp-cdk/edla_vpc/VpcConsumer.py", line 12, in __init__
CfnOutput(self, construct_id, value=vpc_stack.get_vpc_id)
File "/Users/wormym/cdp-cdk/.venv/lib/python3.8/site-packages/jsii/_runtime.py", line 112, in __call__
inst = super().__call__(*args, **kwargs)
File "/Users/wormym/cdp-cdk/.venv/lib/python3.8/site-packages/aws_cdk/__init__.py", line 5755, in __init__
props = CfnOutputProps(
File "/Users/wormym/cdp-cdk/.venv/lib/python3.8/site-packages/aws_cdk/__init__.py", line 5918, in __init__
check_type(argname="argument value", value=value, expected_type=type_hints["value"])
File "/Users/wormym/cdp-cdk/.venv/lib/python3.8/site-packages/typeguard/__init__.py", line 785, in check_type
raise TypeError(
TypeError: type of argument value must be str; got property instead Can you remove str() in Cfnoutput ? <property object at 0x1097f5a90> |
|
@wormym1011 Could you solve this issue? I have the same but with event bridge schema target parameters. |
Describe the bug
Code from app.py
Code from VPCStack.py
Code from VPCRoutingStack.py
Error return:
Expected Behavior
Actually I have many nested stack before from cdkv1 to v2 and migrated v1 to v2 as well. All working as expected till now. but this is new project and suddenly I faced this problem.
From my point of view the @Property already string, and it should be get the real value while runtime of cdk.
Current Behavior
It returned error
Traceback (most recent call last): File "app.py", line 13, in <module> VPCRoutingStack(app, "VPCRoutingStack", vpc_stack=VPCStack) File "/Users/wormym/cdp-cdk/.venv/lib/python3.8/site-packages/jsii/_runtime.py", line 112, in __call__ inst = super().__call__(*args, **kwargs) File "/Users/wormym/cdp-cdk/edla_vpc/VPCRoutingStack.py", line 21, in __init__ CfnOutput(self, id, value=vpc_stack.get_vpc_id, export_name="cccc") File "/Users/wormym/cdp-cdk/.venv/lib/python3.8/site-packages/jsii/_runtime.py", line 112, in __call__ inst = super().__call__(*args, **kwargs) File "/Users/wormym/cdp-cdk/.venv/lib/python3.8/site-packages/aws_cdk/__init__.py", line 5755, in __init__ props = CfnOutputProps( File "/Users/wormym/cdp-cdk/.venv/lib/python3.8/site-packages/aws_cdk/__init__.py", line 5918, in __init__ check_type(argname="argument value", value=value, expected_type=type_hints["value"]) File "/Users/wormym/cdp-cdk/.venv/lib/python3.8/site-packages/typeguard/__init__.py", line 785, in check_type raise TypeError( TypeError: type of argument value must be str; got property instead
Reproduction Steps
init cdk with python language
Create 3 files that I explained:
Then run cdk deploy and error occurred
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.84
Framework Version
No response
Node.js Version
node 16/18
OS
os x / ubuntu
Language
Python
Language Version
3.8
Other information
requirements.txt:
aws-cdk-lib==2.84.0
constructs==10.2.55
python-dotenv
The text was updated successfully, but these errors were encountered: