Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
Migrar de apigateway a apigatewayv2

¿Cómo migrar de apigateway a apigatewayv2 usando AWS-CDK?

Específicamente: estoy usando LambdaRestApi y restApiId y deploymentStage de ese recurso.

 // old const apiGw = new apigateway.LambdaRestApi(this, 'MyAPI', { handler: lambdaFrontend, proxy: true, binaryMediaTypes: ['*/*'], }); // new const apiGw2 = new apigateway.CfnApi(this as any, 'MyAPIV2', { protocolType: "http", target: lambdaFrontend.functionArn, })

Estoy tratando de obtener OriginSource para CF así: const domainName = ${apiGw.restApiId}.execute-api.${this.region}.${this.urlSuffix};

Primera pregunta: ¿Cómo puedo recuperar el nombre de dominio con domainName ?

También necesito el nombre del escenario. Actualmente lo estoy recuperando así: const originPath = '/' + apiGw.deploymentStage.stageName;

Segunda pregunta: ¿Cómo puedo recuperar la ruta de origen con ApiGW2?

Alternativamente: ¿hay una mejor manera de conectar mi ApiGW2 con CF?

 const fecf = new cf.CloudFrontWebDistribution(this, "MyCF", { originConfigs: [{ customOriginSource: { domainName: `${apiGw.restApiId}.execute-api.${this.region}.${this.urlSuffix}`, }, originPath: '/' + apiGw.deploymentStage.stageName, ... }
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Esto ahora se puede resolver con bastante facilidad ya que ahora tenemos documentación oficial para esto. Si alguien quiere migrar a V2 ahora, esta es la forma:

 const httpApiIntegration = new apigatewayv2Integrations.LambdaProxyIntegration({ handler: fn, }); const httpApi = new apigatewayv2.HttpApi(this, "MyApiV2"); httpApi.addRoutes({ path: "/", methods: [HttpMethod.ANY], integration: httpApiIntegration, }); new cloudfront.CloudFrontWebDistribution(this, "MyCf", { defaultRootObject: "/", originConfigs: [ { customOriginSource: { domainName: `${httpApi.httpApiId}.execute-api.${this.region}.${this.urlSuffix}`, }, behaviors: [ { isDefaultBehavior: true, }, ], }, ], enableIpV6: true, });

https://docs.aws.amazon.com/cdk/api/latest/docs/aws-apigatewayv2-readme.html

Pasos:

  • crear una integración (por ejemplo, una función lambda), esto proviene de un paquete dedicado (apigatewayv2-integrations)
  • crear un HttpApi, no se necesitan opciones
  • Nuevo: a diferencia de APIGWv1, deberá agregar controladores de ruta para sus rutas (httpApi.addRoutes).
  • La configuración de Cloudfront es muy similar
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda