Skip to content

DevX: auto-register the Cloud-Init provider when L2 constructs require it #135

Description

@sakul-learning

Problem

Constructs such as AutoScalingGroup can create Cloud-Init data sources internally, but an AwsStack does not register a CloudinitProvider when those resources are needed. A consumer can therefore build an otherwise complete stack and encounter this only at synthesis:

Found resources without a matching provider construct. Please make sure to add provider constructs [...] for the following providers: cloudinit

This is inconsistent with the stack-managed singleton behavior consumers see for other supporting providers, and the required manual provider registration is not obvious from the L2 API.

Discovered while validating the PR-head package from #134 in an external example project. This is not a blocker for that PR.

Reproduction

  1. Create an aws.AwsStack.
  2. Add a VPC and aws.compute.autoscaling.AutoScalingGroup using the normal L2 API.
  3. Do not manually instantiate @cdktn/provider-cloudinit's CloudinitProvider.
  4. Run app.synth().

Synthesis fails with the missing-provider validation above. Adding this manually makes the same stack synthesize successfully:

new CloudinitProvider(stack, "CloudInit");

Expected developer experience

When a TerraConstructs L2 internally introduces resources from a supporting provider, the stack should register or expose a consistent singleton for that provider, rather than requiring consumers to discover the dependency from a synthesis error.

Possible direction

Add stack-managed singleton handling for CloudinitProvider, following the existing supporting-provider patterns where appropriate, and add a synthesis test proving an ASG that needs Cloud-Init does not require manual provider setup.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions