连接 Route53 到 HTTP API 网关 CDK

问题描述 投票:0回答:0

我想将流量从像 api.mydomain 这样的子域路由到我的 API 网关。

我有一个 Route53 构造定义为:

const myHostedZone = PublicHostedZone.fromPublicHostedZoneAttributes(
    this,
    'myHostedZone',
    {
       zoneName: 'myDomainName',
       hostedZoneId: 'hostedZoneID#',
    }
);

const certificate = new DnsValidatedCertificate(
    this,
    'CrossRegionCertificate',
       {
         hostedZone: hostedZone,
         domainName: 'beta.myDomainName',
         region: 'us',
       }
);

const api2 = new apigw.HttpApi(this, 'myAPI', 
   {
      apiName: 'My API',
      description: 'This is my API',
      corsPreflight: {
          allowOrigins: ['https://localhost:8080', 'myDomainName'],
          allowMethods: [apigw.CorsHttpMethod.GET, apigw.CorsHttpMethod.POST],
          allowCredentials: true,
          allowHeaders: ['authorization', 'accepts', 'content-type']
      },
      defaultAuthorizer: myAuthorizer
   }
);

//I have an A record that points to my distribution: 
new ARecord(this, 'AliasRecord', {
    zone: myHostedZone,
    recordName: 'beta.myDomain',
    target: RecordTarget.fromAlias(new CloudFrontTarget(distribution)),
});

我有一个 HTTP API,但不确定如何将子域 api.myDomainName 连接到我的 HTTP API 构造。

typescript aws-api-gateway aws-cdk amazon-route53
© www.soinside.com 2019 - 2024. All rights reserved.