Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Library for CDK Resource Type constant strings

Is there any library in CDK where we can reference resource type constants? For example, the strings AWS::CloudWatch::Alarm or AWS::Lambda::Function. I’m using these as inputs to CDK test functions like hasResourceProperties and preferably have this parameter with autocomplete suggestions rather than typing out the string every time.

The closest I found was ResourceType in the aws_config package but unfortunately I couldn’t find a way to convert these instances into strings.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You almost got it – it is indeed ResourceType. To access the actual CloudFormation resource type as a string, just use the complianceResourceType prop.

// 'AWS::EC2::Instance'
const resoureTypeStr = ResourceType.EC2_INSTANCE.complianceResourceType;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading