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

249
Vistas
How do I retrieve the apiId when creating a CfnDeployment via CDK?

I'm using aws-cdk-lib version 2 to create a CloudFormation stack. I define my API as follows:

const api = new apigatewayv2.CfnApi(this, 'MyApi', { body: YAML.parse(apiSpec), failOnWarnings: true });

This successfully creates my API on deploy. Now I'd like to automate creating a stage for this API. This is what I'm attempting:

new apigatewayv2.CfnStage(this, 'dev-stage', {
  stageName: 'dev',
  apiId: '???????', // <--- How do I find this value?
  autoDeploy: true,
});

As you can see, one of the required parameters when creating CfnStage is apiId, which doesn't seem available via the CfnApi object created earlier (there is a logicalId property, but it's not the value CfnStage is expecting).

I can find the correct value on the AWS console after the CDK script runs, but that doesn't do me much good if I'm trying to automate the creation of the stage via CDK all in a single deploy.

So: How do I determine the correct apiId when creating a CfnStage without having to have already deployed the API?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use Ref.

AWS::ApiGatewayV2::Api CloudFormation docs: Ref: When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the API ID, such as a1bcdef2gh.

// synth-time token, deploy-time string
const apiId = cdk.Fn.ref(api.logicalId);
about 4 years ago · Juan Pablo Isaza 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