'API Gateway with DNS record in another account

In our environment there is a dedicated AWS account that contains registered domain as well as hosting zone in Route53. Also an IAM role is created that allows specific set of other accounts to create records in that hosted zone.

Using AWS CDK (v2) is there a way to create API Gateway in one account with DNS record (A Record?) created for it in that dedicated one?

This is an example of setup:

export class CdkRoute53ExampleStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const backend = new lambda.Function(this, 'HelloHandler', {
      runtime: lambda.Runtime.NODEJS_14_X,
      code: lambda.Code.fromAsset('src'),
      handler: 'hello.handler'
    });

    const restApi = new apigw.LambdaRestApi(this, 'Endpoint', {
      handler: backend,
      domainName: {
        domainName: `cdk53.${Config.domainName}`,
        certificate: acm.Certificate.fromCertificateArn(
          this,
          "my-cert",
          Config.certificateARN
        ),
      },
      endpointTypes: [apigw.EndpointType.REGIONAL]
    });

    new route53.ARecord(this, "apiDNS", {
      zone: route53.HostedZone.fromLookup(this, "baseZone", {
        domainName: Config.domainName,
      }),
      recordName: "cdk53",
      target: route53.RecordTarget.fromAlias(
        new route53targets.ApiGateway(restApi)
      ),
    });


  }
}

Basically I need that last ARecord construct to be created under credentials from assumed role in another account.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source