Skip to content
Discussion options

You must be logged in to vote

@github-actions proposed-answer Try casting it as a RestApiBase

The following works for me

export class TestingStack extends cdk.Stack {
  public restApi: apigw.RestApiBase;
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    this.restApi = apigw.RestApi.fromRestApiId(this,"MyGatewayApi","restApiId") as apigw.RestApiBase;
    
    const api = new cw.Alarm(this, `api-error-alarm`, {
      alarmName: 'api-error-alarm',
      threshold: 5,
      evaluationPeriods: 1,
      metric: this.restApi.metricServerError()
    });
  }
}

I've created an issue to track this so that you don't have to explicitly cast in the future.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@github-actions
Comment options

Answer selected by peterwoodworth
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants