How to use the jsii-reflect.TypeReference function in jsii-reflect

To help you get started, we’ve selected a few jsii-reflect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-cdk / packages / decdk / lib / declarative-stack.ts View on Github external
throw new ValidationError('Schema validation errors:\n  ' + result.errors.map(e => `"${e.property}" ${e.message}`).join('\n  '));
    }

    // Replace every resource that starts with CDK::
    for (const [logicalId, resourceProps] of Object.entries(template.Resources || {})) {
      const rprops: any = resourceProps;
      if (!rprops.Type) {
        throw new Error('Resource is missing type: ' + JSON.stringify(resourceProps));
      }

      if (isCfnResourceType(rprops.Type)) {
        continue;
      }

      const typeInfo = typeSystem.findFqn(rprops.Type + 'Props');
      const typeRef = new reflect.TypeReference(typeSystem, typeInfo);
      const Ctor = resolveType(rprops.Type);

      // Changing working directory if needed, such that relative paths in the template are resolved relative to the
      // template's location, and not to the current process' CWD.
      _cwd(props.workingDirectory, () =>
        new Ctor(this, logicalId, deserializeValue(this, typeRef, true, 'Properties', rprops.Properties)));

      delete template.Resources[logicalId];
    }

    delete template.$schema;

    // Add an Include construct with what's left of the template
    new cdk.CfnInclude(this, 'Include', { template });

    // replace all "Fn::GetAtt" with tokens that resolve correctly both for