Skip to content

Commit

Permalink
fix(imports): updating all cdktf imports to use the right syntax (#319)
Browse files Browse the repository at this point in the history
* fix(imports): updating imports for account-delete-monitor

* fix(imports): making all terraform modules import from the main module

* fix(imports): updating all cdktf imports

---------

Co-authored-by: Kat Schelonka <[email protected]>
  • Loading branch information
bassrock and kschelonka authored Mar 19, 2024
1 parent 06b7abc commit 7590ef0
Show file tree
Hide file tree
Showing 98 changed files with 3,118 additions and 2,562 deletions.
28 changes: 15 additions & 13 deletions infrastructure/account-data-deleter/src/dataDeleterApp.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { config } from './config';

import { CloudwatchLogGroup } from '@cdktf/provider-aws/lib/cloudwatch-log-group';
import { DataAwsCallerIdentity } from '@cdktf/provider-aws/lib/data-aws-caller-identity';
import { DataAwsKmsAlias } from '@cdktf/provider-aws/lib/data-aws-kms-alias';
import { DataAwsRegion } from '@cdktf/provider-aws/lib/data-aws-region';
import { DataAwsSnsTopic } from '@cdktf/provider-aws/lib/data-aws-sns-topic';
import { SqsQueue } from '@cdktf/provider-aws/lib/sqs-queue';
import {
cloudwatchLogGroup,
dataAwsCallerIdentity,
dataAwsKmsAlias,
dataAwsRegion,
sqsQueue,
dataAwsSnsTopic,
} from '@cdktf/provider-aws';

import {
PocketALBApplication,
Expand All @@ -16,12 +18,12 @@ import { Construct } from 'constructs';

export type DataDeleterAppConfig = {
pagerDuty: PocketPagerDuty;
region: DataAwsRegion;
caller: DataAwsCallerIdentity;
secretsManagerKmsAlias: DataAwsKmsAlias;
snsTopic: DataAwsSnsTopic;
batchDeleteQueue: SqsQueue;
batchDeleteDLQ: SqsQueue;
region: dataAwsRegion.DataAwsRegion;
caller: dataAwsCallerIdentity.DataAwsCallerIdentity;
secretsManagerKmsAlias: dataAwsKmsAlias.DataAwsKmsAlias;
snsTopic: dataAwsSnsTopic.DataAwsSnsTopic;
batchDeleteQueue: sqsQueue.SqsQueue;
batchDeleteDLQ: sqsQueue.SqsQueue;
};

export class DataDeleterApp extends Construct {
Expand Down Expand Up @@ -243,7 +245,7 @@ export class DataDeleterApp extends Construct {
* @private
*/
private createCustomLogGroup(containerName: string) {
const logGroup = new CloudwatchLogGroup(
const logGroup = new cloudwatchLogGroup.CloudwatchLogGroup(
this,
`${containerName}-log-group`,
{
Expand Down
34 changes: 22 additions & 12 deletions infrastructure/account-data-deleter/src/lambda/base/sqsLambda.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { config as stackConfig } from '../../config';

import { DataAwsSsmParameter } from '@cdktf/provider-aws/lib/data-aws-ssm-parameter';
import { LAMBDA_RUNTIMES } from '@pocket-tools/terraform-modules';
import { PocketPagerDuty } from '@pocket-tools/terraform-modules';
import { PocketSQSWithLambdaTarget } from '@pocket-tools/terraform-modules';
import { PocketVersionedLambdaProps } from '@pocket-tools/terraform-modules';
import { PocketVPC } from '@pocket-tools/terraform-modules';
import { dataAwsSsmParameter } from '@cdktf/provider-aws';
import {
LAMBDA_RUNTIMES,
PocketPagerDuty,
PocketSQSWithLambdaTarget,
PocketVersionedLambdaProps,
PocketVPC,
} from '@pocket-tools/terraform-modules';

import { Construct } from 'constructs';

Expand Down Expand Up @@ -67,13 +69,21 @@ export class SqsLambda extends Construct {
}

private getEnvVariableValues() {
const sentryDsn = new DataAwsSsmParameter(this, 'sentry-dsn', {
name: `/${stackConfig.name}/${stackConfig.environment}/SENTRY_DSN`,
});
const sentryDsn = new dataAwsSsmParameter.DataAwsSsmParameter(
this,
'sentry-dsn',
{
name: `/${stackConfig.name}/${stackConfig.environment}/SENTRY_DSN`,
},
);

const serviceHash = new DataAwsSsmParameter(this, 'service-hash', {
name: `${stackConfig.circleCIPrefix}/SERVICE_HASH`,
});
const serviceHash = new dataAwsSsmParameter.DataAwsSsmParameter(
this,
'service-hash',
{
name: `${stackConfig.circleCIPrefix}/SERVICE_HASH`,
},
);

return { sentryDsn: sentryDsn.value, gitSha: serviceHash.value };
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { config, config as stackConfig } from '../config';

import { DataAwsSsmParameter } from '@cdktf/provider-aws/lib/data-aws-ssm-parameter';
import { DataAwsIamPolicyDocument } from '@cdktf/provider-aws/lib/data-aws-iam-policy-document';
import { DynamodbTable } from '@cdktf/provider-aws/lib/dynamodb-table';
import { IamPolicy } from '@cdktf/provider-aws/lib/iam-policy';
import { IamRolePolicyAttachment } from '@cdktf/provider-aws/lib/iam-role-policy-attachment';
import { IamRole } from '@cdktf/provider-aws/lib/iam-role';
import { LambdaPermission } from '@cdktf/provider-aws/lib/lambda-permission';
import {
dataAwsSsmParameter,
dataAwsIamPolicyDocument,
dynamodbTable,
iamPolicy,
iamRolePolicyAttachment,
iamRole,
lambdaPermission,
} from '@cdktf/provider-aws';
import {
ApplicationDynamoDBTable,
ApplicationDynamoDBTableCapacityMode,
Expand Down Expand Up @@ -117,7 +119,7 @@ export class BatchDeleteLambdaResources extends Construct {
);

//permission for scheduledEvent to invoke the batchDeleteLambda
new LambdaPermission(this, `${config.prefix}-batchLambda-permission`, {
new lambdaPermission.LambdaPermission(this, `${config.prefix}-batchLambda-permission`, {
principal: 'events.amazonaws.com',
action: 'lambda:InvokeFunction',
functionName: this.batchDeleteLambda.lambda.defaultLambda.arn,
Expand All @@ -126,11 +128,11 @@ export class BatchDeleteLambdaResources extends Construct {
}

private getEnvVariableValues() {
const sentryDsn = new DataAwsSsmParameter(this, 'sentry-dsn', {
const sentryDsn = new dataAwsSsmParameter.DataAwsSsmParameter(this, 'sentry-dsn', {
name: `/${stackConfig.name}/${stackConfig.environment}/SENTRY_DSN`,
});

const serviceHash = new DataAwsSsmParameter(this, 'service-hash', {
const serviceHash = new dataAwsSsmParameter.DataAwsSsmParameter(this, 'service-hash', {
name: `${stackConfig.circleCIPrefix}/SERVICE_HASH`,
});

Expand Down Expand Up @@ -199,14 +201,14 @@ export class BatchDeleteLambdaResources extends Construct {
*/
private addDynamoPermissions(
name: string,
lambdaExecutionRole: IamRole,
dynamoTables: DynamodbTable[],
lambdaExecutionRole: iamRole.IamRole,
dynamoTables: dynamodbTable.DynamodbTable[],
actions: string[],
) {
const resources = dynamoTables.map((_) => _.arn);
const policy = new IamPolicy(this, `${name}-lambda-dynamo-policy`, {
const policy = new iamPolicy.IamPolicy(this, `${name}-lambda-dynamo-policy`, {
name: `${this.name}-${name}-DynamoLambdaPolicy`,
policy: new DataAwsIamPolicyDocument(
policy: new dataAwsIamPolicyDocument.DataAwsIamPolicyDocument(
this,
`${name}-lambda-dynamo-policy-doc`,
{
Expand All @@ -221,7 +223,7 @@ export class BatchDeleteLambdaResources extends Construct {
).json,
dependsOn: [lambdaExecutionRole],
});
return new IamRolePolicyAttachment(
return new iamRolePolicyAttachment.IamRolePolicyAttachment(
this,
`${name}-execution-role-policy-attachment`,
{
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/account-data-deleter/src/lambda/eventLambda.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SqsLambda, SqsLambdaProps } from './base/sqsLambda';
import { config as stackConfig } from '../config';

import { SqsQueue } from '@cdktf/provider-aws/lib/sqs-queue';
import { sqsQueue } from '@cdktf/provider-aws';
import { ApplicationSqsSnsTopicSubscription } from '@pocket-tools/terraform-modules/';

import { Construct } from 'constructs';
Expand All @@ -28,7 +28,7 @@ export class EventLambda extends Construct {
snsTopicArn: `arn:aws:sns:${config.vpc.region}:${config.vpc.accountId}:${stackConfig.lambda.snsTopicName.userEvents}`,
sqsQueue: lambda.sqsQueueResource,
tags: stackConfig.tags,
dependsOn: [lambda.sqsQueueResource as SqsQueue],
dependsOn: [lambda.sqsQueueResource as sqsQueue.SqsQueue],
},
);
}
Expand Down
43 changes: 25 additions & 18 deletions infrastructure/account-data-deleter/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import { DataDeleterApp, DataDeleterAppConfig } from './dataDeleterApp';
import { BatchDeleteLambdaResources } from './lambda/batchDeleteLambdaResources';
import { EventLambda } from './lambda/eventLambda';

import { ArchiveProvider } from '@cdktf/provider-archive/lib/provider';
import { AwsProvider } from '@cdktf/provider-aws/lib/provider';
import { DataAwsCallerIdentity } from '@cdktf/provider-aws/lib/data-aws-caller-identity';
import { DataAwsKmsAlias } from '@cdktf/provider-aws/lib/data-aws-kms-alias';
import { DataAwsRegion } from '@cdktf/provider-aws/lib/data-aws-region';
import { DataAwsSnsTopic } from '@cdktf/provider-aws/lib/data-aws-sns-topic';
import { LocalProvider } from '@cdktf/provider-local/lib/provider';
import { NullProvider } from '@cdktf/provider-null/lib/provider';
import { PagerdutyProvider } from '@cdktf/provider-pagerduty/lib/provider';
import { provider as archiveProvider } from '@cdktf/provider-archive';
import {
provider as awsProvider,
dataAwsCallerIdentity,
dataAwsKmsAlias,
dataAwsRegion,
dataAwsSnsTopic,
} from '@cdktf/provider-aws';
import { provider as localProvider } from '@cdktf/provider-local';
import { provider as nullProvider } from '@cdktf/provider-null';
import { provider as pagerdutyProvider } from '@cdktf/provider-pagerduty';
import {
ApplicationSQSQueue,
PocketPagerDuty,
Expand All @@ -30,11 +32,13 @@ class AccountDataDeleter extends TerraformStack {
constructor(scope: Construct, name: string) {
super(scope, name);

new ArchiveProvider(this, 'archive-provider');
new AwsProvider(this, 'aws', { region: 'us-east-1' });
new LocalProvider(this, 'local-provider');
new NullProvider(this, 'null-provider');
new PagerdutyProvider(this, 'pagerduty-provider', { token: undefined });
new archiveProvider.ArchiveProvider(this, 'archive-provider');
new awsProvider.AwsProvider(this, 'aws', { region: 'us-east-1' });
new localProvider.LocalProvider(this, 'local-provider');
new nullProvider.NullProvider(this, 'null-provider');
new pagerdutyProvider.PagerdutyProvider(this, 'pagerduty-provider', {
token: undefined,
});

new S3Backend(this, {
bucket: `mozilla-pocket-team-${config.environment.toLowerCase()}-terraform-state`,
Expand All @@ -43,8 +47,11 @@ class AccountDataDeleter extends TerraformStack {
region: 'us-east-1',
});

const caller = new DataAwsCallerIdentity(this, 'caller');
const region = new DataAwsRegion(this, 'region');
const caller = new dataAwsCallerIdentity.DataAwsCallerIdentity(
this,
'caller',
);
const region = new dataAwsRegion.DataAwsRegion(this, 'region');
const pagerDuty = this.createPagerDuty();
const pocketVpc = new PocketVPC(this, 'pocket-vpc');

Expand Down Expand Up @@ -84,7 +91,7 @@ class AccountDataDeleter extends TerraformStack {
* @private
*/
private getSecretsManagerKmsAlias() {
return new DataAwsKmsAlias(this, 'kms_alias', {
return new dataAwsKmsAlias.DataAwsKmsAlias(this, 'kms_alias', {
name: 'alias/aws/secretsmanager',
});
}
Expand All @@ -94,7 +101,7 @@ class AccountDataDeleter extends TerraformStack {
* @private
*/
private getCodeDeploySnsTopic() {
return new DataAwsSnsTopic(this, 'backend_notifications', {
return new dataAwsSnsTopic.DataAwsSnsTopic(this, 'backend_notifications', {
name: `Backend-${config.environment}-ChatBot`,
});
}
Expand Down
Loading

0 comments on commit 7590ef0

Please sign in to comment.