-
Notifications
You must be signed in to change notification settings - Fork 4k
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
How to use FnImportValue where CDK wants a string or list of string? #674
Comments
CDK tokens, such as Would that work for your use case? |
Thank you -- that would work. How about in places where CloudFormation accepted Resources:
LoadBalancer:
Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
Properties:
Subnets: !Split [ ",", !ImportValue shared-infra-PublicSubnetIDs ]
AutoScalingGroup:
Type: 'AWS::AutoScaling::AutoScalingGroup'
Properties:
VPCZoneIdentifier: !Split [ ",", !ImportValue shared-infra-PrivateSubnetIDs ] |
You are being bitten by this issue: #607 For your second problem (can't use a const parts = new FnSplit(',', new FnImportValue('shared-infra-PublicSubnetIDs);
const array = [
new SomeType(new FnSelect(0, parts))),
new SomeType(new FnSelect(1, parts))),
new SomeType(new FnSelect(2, parts))),
...
]; But if you don't how many elements there are, unfortunately that won't work. |
We don't have support for that, but I wonder if we could somehow support something like |
We could extend Token stringification to have different encodings for different types... but the types would have to be known beforehand which we also don't have. With the type system that we have, not much we can do I think. |
I don't think we need a general-purpose solution, just support for string arrays. |
Hi,
I'm trying to import a VPC from an existing (non-cdk) stack, following the examples in:
https://gist.github.com/mipearson/aeaf303b0770c25f8b5f6e360594cfbf
#603
#506
I added exports in my existing stack for the VPC ID, CIDR block, availability zones, and subnets.
In order to call
VpcNetworkRef.import_
, I need to pass it VpcNetworkRefProps, and the builder for the props wants a list of strings for AZs.None of these type check as arguments to
VpcNetworkRefProps.builder().withVpcId(id).withAvailabilityZones
:new FnImportValue("other-stack-AZs")
whereother-stack-AZs
is a comma-separated export (Fn::Join
on the other stack's cloudformation template)new FnSplit(",", new FnImportValue("other-stack-AZs"))
[new FnImportValue("other-stack-AZ1"), new FnImportValue("other-stack-AZ2"), new FnImportValue("other-stack-AZ3")]
How can I import availability zones from another stack?
And more generally, how should we use FnImportValue where CDK wants a string or a list of strings?
The text was updated successfully, but these errors were encountered: