Skip to content

(aws-route53-targets): Cannot use SpecRestApi to create ApiGateway target for ARecord #16227

@AlexStasko

Description

@AlexStasko

I'm trying to use the SpecRestApi to create API Gateway based on the OpenAPI document. To have the ability to use Custom Domain Name I need to create ARecord, but RecordTarget.fromAlias(new ApiGateway(apiGW)) accepts only RestApi class.

image

Reproduction Steps

Code snipet:

    const apiGW = new SpecRestApi(this, 'RestApi', {
      apiDefinition: ApiDefinition.fromAsset('open-api.yaml'),
    });
    const record = new ARecord(this, 'Record', {
      zone: HostedZone.fromHostedZoneAttributes(this, 'Route53HostedZone', {
        zoneName: dnsZoneName,
        hostedZoneId: dnsHostedZoneId,
      }),
      target: RecordTarget.fromAlias(new ApiGateway(apiGW)),
    });

What did you expect to happen?

I'm able to create ARecord with SpecRestApi

What actually happened?

The compiler shows me error Argument of type 'SpecRestApi' is not assignable to parameter of type 'RestApi'.

Environment

  • CDK CLI Version : 1.119.0
  • Framework Version: 1.119.0
  • Node.js Version: 14.17.0
  • OS : Ubuntu
  • Language (Version): TypeScript (4.3.5)

Other

Suggestion for fix:
on this line need to change apig.RestApi to apig.RestApiBase


This is 🐛 Bug Report

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions