Add IAM Role to Redshift Cluster in AWS CDK

1 week ago 7
ARTICLE AD BOX

I am trying to add an IAM role to a Redshift cluster which is already created. I am using the below approach and facing errors.

from aws_cdk import ( Duration, Stack, aws_redshift_alpha as redshift ) redshift_cluster = redshift.Cluster.from_cluster_attributes( self, "RedshiftCluster", cluster_name=self.config["redshift_cluster"], cluster_endpoint_address=self.config["redshift_cluster_endpoint_address"], cluster_endpoint_port=self.config["redshift_cluster_endpoint_port"] ) redshift_cluster.add_iam_role(redshift_lambda_iam_role)

The error I am getting is:

AttributeError: '<class 'aws_cdk.Resource'>+<class 'aws_cdk.aws_redshift_alpha._IClusterProxy'>' object has no attribute 'add_iam_role'

Please note that I am not creating Redshift cluster in this stack and want to just reference an already created cluster to just add a new IAM role to it. Any suggestions on how to achieve this? Thanks!

Read Entire Article