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.
>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;