interface IRestApi don't have metricServerError method #26234
-
I'm trying to import a RestAPI created in another stack and use the metrics method.
Is it the correct specification that the Interface IRestAPI has no metricServerError methods? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@github-actions proposed-answer Try casting it as a 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. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
@github-actions proposed-answer Try casting it as a
RestApiBase
The following works for me
I've created an issue to track this so that you don't have to explicitly cast in the future.