Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· openaiHugging Face Suzhen/CodeChat

Where in AWS CDK v2 Template class with add_resource method? Core unavaiable because in…

  1. User

    Where in AWS CDK v2 Template class with add_resource method? Core unavaiable because in AWS CDK v2 aws-cdk-lib was deprecated and required incompatible versions of libraries.

  2. Assistant

    In AWS CDK v2, the add_resource method is not available in the Template class as it was in AWS CDK v1. Instead, you can create resources directly using the aws-cdk-lib library.

    For example, to create an S3 bucket resource, you can use the following code:

    import * as s3 from 'aws-cdk-lib/aws-s3';
    
    const bucket = new s3.Bucket(this, 'MyBucket');
    

    The add_resource method was deprecated in AWS CDK v1 and is not recommended to use. It generated CloudFormation templates that were not always optimal and often required manual tweaking. Instead, it is recommended to create resources using dedicated classes provided by the AWS CDK.