winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.06k stars 198 forks source link

Declare Dependencies between SDK and external resources #3225

Open skorfmann opened 1 year ago

skorfmann commented 1 year ago

Feature Spec

It's now possible to explicitly declare dependencies between SDK and non-SDK resources, which are otherwise not directly depending on each other. This is using the the depends_on meta argument of Terraform and hence only available within tf-* targets.

e.g.

// wait for 5 minutes
new nullProvider.provider.NullProvider();
let blocker = new nullProvider.resource.Resource(
  provisioners: [
    {
      type: "local-exec",
      command: "sleep 300"
    }
  ]
);

let bucket = new cloud.Bucket
bucket.dependsOn(blocker)

Use Cases

Implementation Notes

Might be worthwhile thinking about supporting provider and lifecycle

Component

SDK

Community Notes

eladb commented 1 year ago

We support construct dependencies:

class Foo {

}

let foo = new Foo() as "foo";
let bar = new Foo() as "bar";

foo.node.addDependency(bar);

@skorfmann does CDKTF honor construct dependencies? Maybe this is something we can add upstream?

skorfmann commented 1 year ago

@skorfmann does CDKTF honor construct dependencies?

no, not yet

Maybe this is something we can add upstream?

Looks like this is something which could be accepted https://github.com/hashicorp/terraform-cdk/issues/785

github-actions[bot] commented 8 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 5 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

so0k commented 2 months ago

for anyone using CDKTF and trying to create depends_on configurations between Contructs...

until support for .node.addDependency() is added in CDKTF upstream, another workaround is to push ITerraformDependable-s into the ITerraformResource.dependsOn array directly. Aside from using Aspects to handle this: https://github.com/hashicorp/terraform-cdk/issues/2727#issuecomment-1473321075