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.

Unable to extract the values using cdk synth command for Fn.importValue

See original GitHub issue

General Issue

Fn.importValue unable to fetch the value and still returning Tokens

The Question

Hi Team,

I have an implementation where i need to fetch the existing ECS Cluster details. I have the import values from the VPC and Security Group of another base stack. However, While using the Fn.importValue i am getting an error :

All arguments to look up a security group must be concrete (no Tokens)

Here is my source code ecs.Cluster.fromClusterAttributes(this, 'existing', { clusterName: Fn.importValue(${propsBackend.clusterName}-ExistingClusterStackName), vpc: vpc, securityGroups: [ ec2.SecurityGroup.fromLookup( this, 'ECSInstanceSecurityGroup', Fn.importValue(${propsBackend.clusterName}-ExistingClusterSecurityGroup), ), ], }); Whenever i run the cdk synth or cdk deploy command : i am getting the above error Error: All arguments to look up a security group must be concrete (no Tokens)

Please suggest what needs to be done here.

CDK CLI Version

1.132.0

Framework Version

No response

Node.js Version

17.0.1

OS

Mac

Language

Typescript

Language Version

Typescript(4.2.4)

Other information

Hi Team,

I have an implementation where i need to fetch the existing ECS Cluster details. I have the import values from the VPC and Security Group of another base stack. However, While using the Fn.importValue i am getting an error :

All arguments to look up a security group must be concrete (no Tokens)

Here is my source code ecs.Cluster.fromClusterAttributes(this, 'existing', { clusterName: Fn.importValue(${propsBackend.clusterName}-ExistingClusterStackName), vpc: vpc, securityGroups: [ ec2.SecurityGroup.fromLookup( this, 'ECSInstanceSecurityGroup', Fn.importValue(${propsBackend.clusterName}-ExistingClusterSecurityGroup), ), ], });

Whenever i run the cdk synth or cdk deploy command : i am getting the above error Error: All arguments to look up a security group must be concrete (no Tokens)

Please suggest what needs to be done here.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ryparkercommented, Nov 19, 2021

You can use the aws-sdk-js-v3 which has first-class Typescript support.

I was wondering if there is any patterns already to configure this fix. Because i believe there will be many use cases where Cloudformation outputs needs to be configured and storing them in ID’s in SSM is an overhead according to me.

I don’t have any examples to reference but I can whip up some prototype projects for you. I’ll follow up with you in this thread.

⚠️ One thing to keep in mind is that you cannot await in Typescript class constructs.

Options:

  • Fetch the data before initializing any CDK constructs.
  • Add a custom method to the stack class that fetches the data, then add the remaining data-dependent resources to the stack.
1reaction
aritranagnordcloudcommented, Nov 23, 2021

Wow. This works like charm! You are awesome!

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 ... You can't modify or remove an output value that is referenced...
Read more >
awslabs/aws-cdk - Gitter
Hello! I am having an issue when trying to deploy an ElasticSearch domain in an account that already has one. Before you can...
Read more >
Deployment Issues with Cross Stack Dependencies and the ...
The problem is, that the CDK noticed, that the importing stack no longer needs the import value for the role arn of role_b...
Read more >
AWS CDK multiple Apps - Stack Overflow
Yes you can have multiple applications in a CDK project, but there are some serious caveats. A CDK process can only synth/deploy one...
Read more >
aws-cdk-lib - npm
The AWS CDK construct library provides APIs to define your CDK application and add CDK constructs to the application. Usage. Upgrade from CDK...
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