Skip to content

Redshift Serverless workgroup arn error

0

This recommendation was generated using AWS Generative AI capabilities. You are responsible for evaluating the recommendation in your specific context and implementing appropriate oversight and safeguards. Learn more This answer has not been reviewed by an expert When working with a Redshift Serverless workgroup in AWS CDK, you're encountering issues with referencing the workgroup ARN in an IAM policy. Based on the documentation, the correct attribute to use is attr_workgroup_arn, not attr_workgroup.

The CfnWorkgroup class does have a workgroup_arn attribute that you can reference. Here's how you should use it:

Correct way to reference the workgroup ARN

resources=[workgroup.attr_workgroup_arn] If you're still encountering type errors, you may need to convert the reference to a string. You can do this using the Fn.ref or by using string interpolation with the Stack.format_arn method:

Using Stack.format_arn

workgroup_arn = stack.format_arn( service="redshift-serverless", resource="workgroup", resource_name=workgroup.ref ) resources=[workgroup_arn] Alternatively, you can use the Token.as_string() method to ensure the reference is treated as a string:

from aws_cdk import core

resources=[core.Token.as_string(workgroup.attr_workgroup_arn)] The key issue appears to be that you're trying to use a CDK reference object directly in a place that expects a string or sequence of strings. The solutions above should help you properly reference the workgroup ARN in your IAM policy.

when used above iam shows arn:aws:redshift-serverless:region:account:workgroup/workgroup name there should be uuid after workgroup/, but shows workgroup/workgroup name should be workgroup/uuid it should refer arn same which gets created and shown in aws console

asked a year ago87 views

1 Answer
0

When working with Amazon Redshift Serverless workgroups in AWS CDK, the ARN format is important to get right. The correct format for a Redshift Serverless workgroup ARN follows this pattern:

arn:aws(-[a-z]+)*:redshift-serverless:[a-z]{2}(-gov|(-iso[a-z]?))?-[a-z]+-\d{1}:\d{12}:workgroup/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}

You're seeing workgroup/workgroup name instead of workgroup/uuid because you might be using a reference to the workgroup name rather than the actual ARN that gets generated when the resource is created.

The workgroup ARN should include a UUID after the "workgroup/" part, which is automatically generated when the workgroup is created. This UUID is part of the workgroup's unique identifier.

When using the AWS CDK, you should reference the workgroup's ARN using attr_workgroup_arn property, which will give you the complete ARN including the UUID. This property links to the actual ARN that gets created in AWS, matching what you would see in the AWS console.

Make sure you're using the workgroupArn property from the WorkgroupProperty interface or the attr_workgroup_arn attribute from a CfnWorkgroup instance to get the correct ARN format with the UUID.
Sources
interface WorkgroupProperty · AWS CDK
DescribeTable - Amazon Redshift Data API
BatchExecuteStatement - Amazon Redshift Data API
ExecuteStatement - Amazon Redshift Data API
ListTables - Amazon Redshift Data API

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.