Explain that Vpc.fromLookup cannot use deploy-time values
See original GitHub issueNote: for support questions, please first reference our documentation, then use Stackoverflow. This repository’s issues are intended for feature requests and bug reports.
-
I’m submitting a …
- 🪲 bug report
- 🚀 feature request
- 📚 construct library gap
- ☎️ security issue or vulnerability => Please see policy
- ❓ support request => Please see note at the top of this template.
-
What is the current behavior? If the current behavior is a 🪲bug🪲: Please provide the steps to reproduce
class VpcStack(core.Stack):
def __init__(self, app: core.App, id: str, **kwargs) -> None:
super().__init__(app, id, **kwargs)
vpc = aws_ec2.Vpc(scope=self, id='Vpc', cidr=some_cidr))
core.CfnOutput(
scope=self,
id='VpcOutput',
value=vpc.vpc_id,
export_name='Vpc'
)
class OtherStack(core.Stack):
def __init__(self, app: core.App, id: str, **kwargs) -> None:
super().__init__(app, id, **kwargs)
vpc_id = core.Fn.import_value('Vpc')
aws_s3.Bucket(
scope=self,
id='Bucket',
bucket_name=vpc_id
)
vpc = aws_ec2.Vpc.from_lookup(
scope=self,
id='Vpc',
vpc_id=vpc_id
)
jsii.errors.JSIIError: Invalid context key "vpc-provider:account=***************:filter.vpc-id=${Token[TOKEN.99]}:region=eu-west-1". It contains unresolved tokens
Bucket resolves fine and inherits name from vpc_id. The vpc is not imported though.
-
What is the expected behavior (or behavior of feature suggested)? Vpc.from_lookup imports vpc from the output
-
What is the motivation / use case for changing the behavior or adding this feature? I cannot import existing vpc without hardcoding id
-
Please tell us about your environment:
- CDK CLI Version: 1.1.0
- Module Version: 1.1.0
- OS: [all]
- Language: [all]
-
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:17 (1 by maintainers)
Sorry to be calling attention to an old issue, but what is the recommended way of reusing a vpc without having to hard code the vpc id. It seems like a very common use case, and using name tags for
fromLookup
works, but also feels fragile since name tags don’t have to be unique.@eladb I’ll add my voice to this request. My use case is the following:
I don’t want to manually pass the VPC ID around and hard code it in any scripts to be as flexible as possible.
So, I would very much like to store the VPC ID in the SSM parameter store from the first stack and then retrieve it from the SSM parameter store in other stacks that need the VPC ID.
The storing and retrieval is actually not a problem, but I can’t “hydrate” a VPC from the VPC ID alone, because of the error
All arguments to Vpc.fromLookup() must be concrete (no Tokens)
.