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

175
Visualizações
How can I create a DependsOn relation between EC2 and RDS using aws-cdk

I am currently using the aws-cdk (TypeScript) to create a stack that consists of an EC2 instance and a RDS databaseInstance.

The RDS instance needs to be setup before the EC2 instance can be started and userdata will be executed.

The problem I have is, that I could not find a way to define the DepensOn (Cloudformation) attribute between the two resources.

The workaround is, that I am using netsted stacks.

The code looks something like this:

const instance = new ec2.Instance(this, 'Instance', {...})
const rdsInstance = new rds.DatabaseInstance(this, 'DbInstance', {...})

Now I would like to define something like instance.dependsOn(rdsInstance).

Did anybody run into the same issue?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

The solution here is to use addDependency() on the node, this will handle all the necessary CloudFormation DependsOn for you:

const instance = new ec2.Instance(this, 'Instance', {...});
const rdsInstance = new rds.DatabaseInstance(this, 'DbInstance', {...});

rdsInstance.node.addDependency(instance);

From the JSDoc of addDependency(): Add an ordering dependency on another Construct. All constructs in the dependency's scope will be deployed before any construct in this construct's scope.

over 4 years ago · Santiago Trujillo Relatório

0

Hope the following helps you.

const instance = new ec2.Instance(this, 'Instance', { /* ... */ }).getInstance();
const rdsInstance = new rds.DatabaseInstance(this, 'DbInstance', { /* ... */ }).getInstance();

instance.addDependsOn(rdsInstance);
over 4 years ago · Santiago Trujillo 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