Skip to content

DatabaseCluster(aws-rds): Using grantDataApiAccess method on imported cluster using DatabaseCluster.fromDatabaseClusterAttributes fails with the error: Cannot grant Data API access when the Data API is disabled  #30676

@rahuldeverani

Description

@rahuldeverani

Describe the bug

If we want to add a Appsync dataSource and provide RDS DB cluster as serverlessCluster prop , it fails with the error: Cannot grant Data API access when the Data API is disabled

Expected Behavior

It should not fail during synth

Current Behavior

This seems to be occurring due to this: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-rds/lib/cluster.ts#L524 as imported cluster : https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-rds/lib/cluster.ts#L1065C16-L1065C39 will have enableDataApi set as false: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-rds/lib/cluster.ts#L983

Reproduction Steps

        const dbCluster = DatabaseCluster.fromDatabaseClusterAttributes(this, 'dbcluster', {
      clusterIdentifier: <identifier> ,
    });

    
    const rdsDataSource = new appsync.RdsDataSource(this, 'vehicledata-rds-datasource', {
      api,
      name: 'rdsDataSource',
      description: 'Vehicle Aurora serverless V2',
      secretStore: dbSecretCredentials,
      serverlessCluster: dbCluster,
      databaseName: '<>',
      serviceRole: dataSourceRole,
    });

This also fails with this snippet:

          const dbCluster = DatabaseCluster.fromDatabaseClusterAttributes(this, 'dbcluster', {
            clusterIdentifier: '<>',
          });
          
          const consoleReadOnlyRole = new iam.Role(this, 'ConsoleReadOnlyRole', {
            assumedBy: new iam.ArnPrincipal('arn_for_trusted_principal'),
          });


        // Grant the grantee access to the Data API
        dbCluster.grantDataApiAccess(consoleReadOnlyRole);

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.138.0

Framework Version

No response

Node.js Version

v20.8.1

OS

MacOs

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-rdsRelated to Amazon Relational DatabasebugThis issue is a bug.closed-for-stalenessThis issue was automatically closed because it hadn't received any attention in a while.response-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions