Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(parent, id, providingStack) {
super(parent, id);
new sns.Topic(this, 'BogusTopic'); // Some filler
new cdk.Output(this, 'IConsumedSomething', { value: providingStack.stackName });
}
}
constructor(parent, id) {
super(parent, id);
new sns.Topic(this, 'BogusTopic'); // Some filler
}
}
environment: {
DATA_BUCKET: `${bucket.bucketName}`,
MAIL_NAME: `${mailName}`,
MAIL_USER: `${mailUser}`,
MAIL_PASS: `${mailPass}`,
MAIL_HOST: `${mailHost}`,
MAIL_PORT: `${mailPort}`,
MAIL_REPLY_TO: `${mailReplyTo}`,
DROPBOX_TOKEN: `${dropboxToken}`,
SNS_TOPIC_ARN: `${snsTopicArn}`,
SENTRY_DSN: `${sentryDsn}`
}
});
bucket.grantReadWrite(lambdaFn);
const snsTopic = Topic.fromTopicArn(
this,
'SendThatInvoice',
`${snsTopicArn}`
);
snsTopic.grantPublish(lambdaFn);
// Run every day at 6PM UTC
// See https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html
const rule = new events.Rule(this, 'send-that-invoice-cron-rule', {
schedule: events.Schedule.expression('rate(4 hours)')
});
rule.addTarget(new targets.LambdaFunction(lambdaFn));
} else {
console.error(
'It seems you haven\'t set one of your ENV vars correctly, please check below'
? iam.Role.fromRoleArn(this, "SfnRole", props.sfnRoleARN, {
mutable: false,
})
: undefined;
this.cacheTable = new dynamodb.Table(this, "cacheTable", {
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
partitionKey: { name: "pk", type: dynamodb.AttributeType.STRING },
sortKey: { name: "sk", type: dynamodb.AttributeType.STRING },
timeToLiveAttribute: "expires_at",
});
// ----------------------------------------------------------------
// Messaging Channels
this.alertTopic = new sns.Topic(this, "alertTopic");
this.taskTopic = new sns.Topic(this, "taskTopic");
this.contentTopic = new sns.Topic(this, "contentTopic");
this.attributeTopic = new sns.Topic(this, "attributeTopic");
this.reportTopic = new sns.Topic(this, "reportTopic");
const alertQueueTimeout = cdk.Duration.seconds(30);
this.alertQueue = new sqs.Queue(this, "alertQueue", {
visibilityTimeout: alertQueueTimeout,
});
this.alertTopic.addSubscription(new SqsSubscription(this.alertQueue));
const contentQueueTimeout = cdk.Duration.seconds(30);
this.contentQueue = new sqs.Queue(this, "contentQueue", {
visibilityTimeout: contentQueueTimeout,
});
const attributeQueueTimeout = cdk.Duration.seconds(30);
})
: undefined;
this.cacheTable = new dynamodb.Table(this, "cacheTable", {
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
partitionKey: { name: "pk", type: dynamodb.AttributeType.STRING },
sortKey: { name: "sk", type: dynamodb.AttributeType.STRING },
timeToLiveAttribute: "expires_at",
});
// ----------------------------------------------------------------
// Messaging Channels
this.alertTopic = new sns.Topic(this, "alertTopic");
this.taskTopic = new sns.Topic(this, "taskTopic");
this.contentTopic = new sns.Topic(this, "contentTopic");
this.attributeTopic = new sns.Topic(this, "attributeTopic");
this.reportTopic = new sns.Topic(this, "reportTopic");
const alertQueueTimeout = cdk.Duration.seconds(30);
this.alertQueue = new sqs.Queue(this, "alertQueue", {
visibilityTimeout: alertQueueTimeout,
});
this.alertTopic.addSubscription(new SqsSubscription(this.alertQueue));
const contentQueueTimeout = cdk.Duration.seconds(30);
this.contentQueue = new sqs.Queue(this, "contentQueue", {
visibilityTimeout: contentQueueTimeout,
});
const attributeQueueTimeout = cdk.Duration.seconds(30);
this.attributeQueue = new sqs.Queue(this, "attributeQueue", {
visibilityTimeout: attributeQueueTimeout,
const sfnRole = props.sfnRoleARN
? iam.Role.fromRoleArn(this, "SfnRole", props.sfnRoleARN, {
mutable: false,
})
: undefined;
this.cacheTable = new dynamodb.Table(this, "cacheTable", {
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
partitionKey: { name: "pk", type: dynamodb.AttributeType.STRING },
sortKey: { name: "sk", type: dynamodb.AttributeType.STRING },
timeToLiveAttribute: "expires_at",
});
// ----------------------------------------------------------------
// Messaging Channels
this.alertTopic = new sns.Topic(this, "alertTopic");
this.taskTopic = new sns.Topic(this, "taskTopic");
this.contentTopic = new sns.Topic(this, "contentTopic");
this.attributeTopic = new sns.Topic(this, "attributeTopic");
this.reportTopic = new sns.Topic(this, "reportTopic");
const alertQueueTimeout = cdk.Duration.seconds(30);
this.alertQueue = new sqs.Queue(this, "alertQueue", {
visibilityTimeout: alertQueueTimeout,
});
this.alertTopic.addSubscription(new SqsSubscription(this.alertQueue));
const contentQueueTimeout = cdk.Duration.seconds(30);
this.contentQueue = new sqs.Queue(this, "contentQueue", {
visibilityTimeout: contentQueueTimeout,
});
const apiBucket = new s3.Bucket(this, 'api-bucket', {
publicReadAccess: true,
websiteIndexDocument: 'index.json'
});
// An S3 bucket which holds the static content
const staticBucket = new s3.Bucket(this, 'static-bucket', {
publicReadAccess: true,
websiteIndexDocument: 'index.html'
});
// Create an ECS cluster
const cluster = new ecs.Cluster(this, 'Cluster', { vpc });
// An SNS topic to which we can publish to trigger the crawl of a changelog
const toCrawlTopic = new sns.Topic(this, 'to-crawl', {
displayName: 'Changelog to crawl'
});
const redisCluster = new redis.Cluster(this, 'redis', { vpc });
this.vpc = vpc;
this.changelogsTable = changelogsTable;
this.feedsTable = feedsTable;
this.searchIndexTable = searchIndexTable;
this.webBucket = webBucket;
this.apiBucket = apiBucket;
this.staticBucket = staticBucket;
this.toCrawlTopic = toCrawlTopic;
this.cluster = cluster;
this.redis = redisCluster;
}
constructor(private readonly url: string, private readonly props: UrlSubscriptionProps = {}) {
this.unresolvedUrl = Token.isUnresolved(url);
if (!this.unresolvedUrl && !url.startsWith('http://') && !url.startsWith('https://')) {
throw new Error('URL must start with either http:// or https://');
}
if (this.unresolvedUrl && props.protocol === undefined) {
throw new Error('Must provide protocol if url is unresolved');
}
if (this.unresolvedUrl) {
this.protocol = props.protocol!;
} else {
this.protocol = this.url.startsWith('https:') ? sns.SubscriptionProtocol.HTTPS : sns.SubscriptionProtocol.HTTP;
}
}
// 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.fn)) {
throw new Error(`The supplied lambda Function object must be an instance of Construct`);
}
this.fn.addPermission(`AllowInvoke:${topic.node.uniqueId}`, {
sourceArn: topic.topicArn,
principal: new iam.ServicePrincipal('sns.amazonaws.com'),
});
return {
subscriberScope: this.fn,
subscriberId: topic.node.id,
endpoint: this.fn.functionArn,
protocol: sns.SubscriptionProtocol.LAMBDA,
filterPolicy: this.props.filterPolicy,
};
}
}
constructor(parent, id) {
super(parent, id);
new sns.Topic(this, 'topic1');
new sns.Topic(this, 'topic2');
}
}