Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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,
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;
}
}
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,
});
}
}
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;
}
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;
}
}
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;
}