-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom-resources: RedshiftData API call fails to find endpoint #30536
Comments
+1 |
1 similar comment
+1 |
Reproducible. CloudFormation deployment gives the below error:
|
I didn't see how you created your provisioned redshift cluster or redshift serverless so it is very likely your custom resource just can't connect to it correctly. I just figured out a working sample with redshift serverless FYR: export class CustomResourceTestAppStack extends Stack {
readonly wg: redshiftserverless.CfnWorkgroup;
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const customResourceRole = new iam.Role(this, 'CrRole', {
assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonRedshiftDataFullAccess')],
});
customResourceRole.addToPolicy(new iam.PolicyStatement({
actions: ['redshift-serverless:*'],
resources: ['*'],
}));
// create a redshift serverless namespace
const ns = new redshiftserverless.CfnNamespace(this, 'NS', {
namespaceName: `${Stack.of(this).stackName}-ns`,
dbName: 'MyRedshiftDatabase',
});
// create a redshift serverless workgroup
this.wg = new redshiftserverless.CfnWorkgroup(this, 'WG', {
workgroupName: `${Stack.of(this).stackName}-wg`,
publiclyAccessible: true,
namespaceName: ns.namespaceName,
});
new CfnOutput(this, 'WorkGroupName', { value: this.wg.attrWorkgroupWorkgroupName });
this.wg.addDependency(ns);
const testCR = new cr.AwsCustomResource(this, 'redshiftExecuteStmt', {
resourceType: 'Custom::RedshiftExecuteStmt',
onCreate: this.executeStmt(),
onUpdate: this.executeStmt(),
onDelete: this.executeStmt(),
role: customResourceRole,
timeout: Duration.minutes(5),
});
// only execute the statement after wg is created
testCR.node.addDependency(this.wg);
const dbUser = testCR.getResponseField('DbUser');
const database = testCR.getResponseField('Database');
new CfnOutput(this, 'DbUser', { value: dbUser });
new CfnOutput(this, 'Database', { value: database });
}
private executeStmt(): cr.AwsSdkCall {
return {
service: 'RedshiftData',
action: 'executeStatement',
parameters: {
WorkgroupName: this.wg.workgroupName,
Database: "MyRedshiftDatabase",
Sql: "SHOW TABLES;",
},
physicalResourceId: cr.PhysicalResourceId.of("physicalResource"),
};
}
}
verify using CLI
Verified! Tips:
Let me know if it works for you. |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Hi Pahud, Thanks for your quick reply. The suggested solution worked! Closing this issue. Best, |
|
Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one. |
Describe the bug
I have a custom resource which calls the RedshiftData API
executeStatement
method. However, the lambda implementing the custom resource fails with the messageRedshift endpoint doesn't exist in this region.
Expected Behavior
The RedshiftData API is actually called and executes the given SQL.
Current Behavior
We see this error upon deployment of the stack:
Reproduction Steps
Possible Solution
I think the cause of this bug is this change in the AWS JavaScript SDKv3: aws/aws-sdk-js-v3#5933
Additional Information/Context
No response
CDK CLI Version
2.145.0 (build fdf53ba)
Framework Version
No response
Node.js Version
v21.7.0
OS
macOS
Language
TypeScript
Language Version
Version 5.4.5
Other information
No response
The text was updated successfully, but these errors were encountered: