question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use FnImportValue where CDK wants a string or list of string?

See original GitHub issue

Hi,

I’m trying to import a VPC from an existing (non-cdk) stack, following the examples in: https://gist.github.com/mipearson/aeaf303b0770c25f8b5f6e360594cfbf https://github.com/awslabs/aws-cdk/issues/603 https://github.com/awslabs/aws-cdk/issues/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") where other-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?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
eladbcommented, Sep 6, 2018

I don’t think we need a general-purpose solution, just support for string arrays.

0reactions
rix0rrrcommented, Sep 6, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fn::ImportValue - AWS CloudFormation
You can use the intrinsic function Fn::ImportValue to import only values that have been exported within the same region. For outputs, the value...
Read more >
How to export and import stack output values in CDK?
To import those values, we use the `Fn::ImportValue` function in the template for the other stacks. ... Construct, id: string, props?: cdk.
Read more >
Fn::ImportValue - Amazon CloudFormation - 亚马逊云科技
The intrinsic function Fn::ImportValue returns the value of an output exported by another stack. You typically use this function to create cross-stack ...
Read more >
Cross-stack reference - AWS CloudFormation p3.7 - YouTube
Welcome to part 3.7 of this tutorial series on AWS CloudFormation. In this tutorial, I have covered the intrinsic function Fn :: ImportValue...
Read more >
Import Stack Outputs in AWS CDK for Cross Stack References
In order to import a value that was exported from another stack, we have to use the `importValue` static method on the `Fn`...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found