Skip to content
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

Fn.cidr should return a List. Currently returns a String in Java #2671

Closed
rgd11 opened this issue May 29, 2019 · 3 comments · Fixed by #2678 or MechanicalRock/tech-radar#14 · May be fixed by MechanicalRock/cdk-constructs#5, MechanicalRock/cdk-constructs#6 or MechanicalRock/cdk-constructs#7

Comments

@rgd11
Copy link

rgd11 commented May 29, 2019

Am expecting the following code:

CfnParameter pVpcCidr;

CfnSubnet subnet = new CfnSubnet(this, "MySubnet",
  CfnSubnetProps.builder()
  ...  
  .withCidrBlock(Fn.select(4, Fn.cidr(pVpcCidr.getRef(), 16, "8"))
  .build();

to evalute to:

CidrBlock: !Select [ 4, !Cidr [ !Ref pVpcCidr, 16, 8 ]]

However, this fails to compile since Fn.select expects a list and Fn.cidr returns a string

@eladb
Copy link
Contributor

eladb commented May 29, 2019

Fn.cidr should return a list and not a string. In the meantime, you could work around by wrapping it in a token:

Fn.select(4, new Token(() => Fn.cidr(pVpcCidr.getRef(), 16, '8')).toList());

EDIT: use a lazy token

@rgd11
Copy link
Author

rgd11 commented May 29, 2019

Tried:

Fn.select(4, new Token(Fn.cidr(this.pVpcCidr.getRef(), 16, "8")).toList())

and received:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project xxxxxx: An exception occured while executing the Java class. Got a literal Token value; only intrinsics can ever evaluate to lists.

@eladb
Copy link
Contributor

eladb commented May 29, 2019

Sorry, you will need to use a lazy token: Fn.select(4, new Token(() => Fn.cidr(pVpcCidr.getRef(), 16, '8')).toList());

eladb pushed a commit that referenced this issue May 29, 2019
CloudFormation's Fn::CIDR returns a list of CIDR blocks and not a string.
So we need to use a listified token instead of a string.

Fixes #2671
eladb pushed a commit that referenced this issue May 29, 2019
CloudFormation's Fn::CIDR returns a list of CIDR blocks and not a string.
So we need to use a listified token instead of a string.

Fixes #2671
This was referenced Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment