Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

250
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda