How to use the @aws-cdk/core.Construct.isConstruct function in @aws-cdk/core

To help you get started, we’ve selected a few @aws-cdk/core 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 / @aws-cdk / aws-sns-subscriptions / lib / sqs.ts View on Github external
public bind(topic: sns.ITopic): sns.TopicSubscriptionConfig {
    // Create subscription under *consuming* construct to make sure it ends up
    // in the correct stack in cases of cross-stack subscriptions.
    if (!Construct.isConstruct(this.queue)) {
      throw new Error(`The supplied Queue object must be an instance of Construct`);
    }

    // add a statement to the queue resource policy which allows this topic
    // to send messages to the queue.
    this.queue.addToResourcePolicy(new iam.PolicyStatement({
      resources: [this.queue.queueArn],
      actions: ['sqs:SendMessage'],
      principals: [new iam.ServicePrincipal('sns.amazonaws.com')],
      conditions: {
        ArnEquals: { 'aws:SourceArn': topic.topicArn }
      }
    }));

    return {
      subscriberScope: this.queue,
github aws / aws-cdk / packages / @aws-cdk / aws-s3 / lib / bucket.ts View on Github external
private isGranteeFromAnotherAccount(grantee: iam.IGrantable): boolean {
    if (!(Construct.isConstruct(grantee))) {
      return false;
    }
    const bucketStack = Stack.of(this);
    const identityStack = Stack.of(grantee);
    return bucketStack.account !== identityStack.account;
  }
}
github aws / aws-cdk / packages / @aws-cdk / aws-ec2 / lib / vpc.ts View on Github external
public associateNetworkAcl(id: string, networkAcl: INetworkAcl) {
    this._networkAcl = networkAcl;

    const scope = Construct.isConstruct(networkAcl) ? networkAcl : this;
    const other = Construct.isConstruct(networkAcl) ? this : networkAcl;
    new SubnetNetworkAclAssociation(scope, id + other.node.uniqueId, {
      networkAcl,
      subnet: this,
    });
  }
}
github aws / aws-cdk / packages / @aws-cdk / aws-kms / lib / key.ts View on Github external
private granteeStackDependsOnKeyStack(grantee: iam.IGrantable): string | undefined {
    if (!(Construct.isConstruct(grantee))) {
      return undefined;
    }
    const keyStack = Stack.of(this);
    const granteeStack = Stack.of(grantee);
    if (keyStack === granteeStack) {
      return undefined;
    }
    return granteeStack.dependencies.includes(keyStack)
      ? granteeStack.account
      : undefined;
  }
github aws / aws-cdk / packages / @aws-cdk / aws-kms / lib / key.ts View on Github external
private isGranteeFromAnotherAccount(grantee: iam.IGrantable): boolean {
    if (!(Construct.isConstruct(grantee))) {
      return false;
    }
    const bucketStack = Stack.of(this);
    const identityStack = Stack.of(grantee);
    return bucketStack.account !== identityStack.account;
  }
}
github aws / aws-cdk / packages / @aws-cdk / aws-kms / lib / key.ts View on Github external
private isGranteeFromAnotherRegion(grantee: iam.IGrantable): boolean {
    if (!(Construct.isConstruct(grantee))) {
      return false;
    }
    const bucketStack = Stack.of(this);
    const identityStack = Stack.of(grantee);
    return bucketStack.region !== identityStack.region;
  }