Skip to content

Commit

Permalink
feat(esm): terraform modules to esm (#314)
Browse files Browse the repository at this point in the history
* feat(esm): moving library config to esm

* feat(terraform-modules): moving tf modules to esm

* feat(terraform-modules): moving tf modules to esm
  • Loading branch information
bassrock authored Mar 18, 2024
1 parent ed84742 commit 3be7590
Show file tree
Hide file tree
Showing 46 changed files with 129 additions and 116 deletions.
5 changes: 4 additions & 1 deletion packages/terraform-modules/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module.exports = {
preset: 'ts-jest',
preset: 'ts-jest/presets/default-esm', // or other ESM presets
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
testEnvironment: 'node',
testMatch: ['**/?(*.)+(jest|spec).[jt]s?(x)'],
testPathIgnorePatterns: ['/dist/'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Testing } from 'cdktf';
import { TestResource } from '../testHelpers';
import { TestResource } from '../testHelpers.js'
import {
ApplicationAutoscaling,
ApplicationAutoscalingProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Testing } from 'cdktf';
import { ApplicationBackup } from './ApplicationBackups';
import { ApplicationBackup } from './ApplicationBackups.js'

describe('ApplicationBackup', () => {
it('renders vault with plans without tags', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Testing } from 'cdktf';
import { TestResource } from '../testHelpers';
import { ApplicationBaseDNS } from './ApplicationBaseDNS';
import { TestResource } from '../testHelpers.js'
import { ApplicationBaseDNS } from './ApplicationBaseDNS.js'

describe('ApplicationBaseDNS', () => {
const tags = {
Expand Down
2 changes: 1 addition & 1 deletion packages/terraform-modules/src/base/ApplicationBaseDNS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Route53Record } from '@cdktf/provider-aws/lib/route53-record';
import { Route53Zone } from '@cdktf/provider-aws/lib/route53-zone';
import { TerraformMetaArguments, TerraformProvider } from 'cdktf';
import { Construct } from 'constructs';
import { getRootDomain } from '../utilities';
import { getRootDomain } from '../utilities.js'

export interface RootDNSProps extends TerraformMetaArguments {
domain: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Testing, TerraformStack } from 'cdktf';
import { TestResource } from '../testHelpers';
import { ApplicationCertificate } from './ApplicationCertificate';
import { TestResource } from '../testHelpers.js'
import { ApplicationCertificate } from './ApplicationCertificate.js'

describe('ApplicationCertificate', () => {
const tags = {
Expand Down
2 changes: 1 addition & 1 deletion packages/terraform-modules/src/base/ApplicationECR.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Testing } from 'cdktf';
import { ApplicationECR } from './ApplicationECR';
import { ApplicationECR } from './ApplicationECR.js'

describe('ApplicationECR', () => {
it('renders an ECR without tags', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Testing } from 'cdktf';
import { ApplicationECSAlbCodeDeploy } from './ApplicationECSAlbCodeDeploy';
import { ApplicationECSAlbCodeDeploy } from './ApplicationECSAlbCodeDeploy.js'

describe('ApplicationECSAlbCodeDeploy', () => {
it('renders a CodeDeploy without a sns', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Testing } from 'cdktf';
import { ApplicationECSCluster } from './ApplicationECSCluster';
import { ApplicationECSCluster } from './ApplicationECSCluster.js'

describe('ApplicationECSCluster', () => {
it('renders an ECS cluster without tags', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Testing } from 'cdktf';
import { ApplicationECSIAM, ApplicationECSIAMProps } from './ApplicationECSIAM';
import { ApplicationECSIAM, ApplicationECSIAMProps } from './ApplicationECSIAM.js'

const BASE_CONFIG: ApplicationECSIAMProps = {
prefix: 'abides-dev',
Expand Down
15 changes: 9 additions & 6 deletions packages/terraform-modules/src/base/ApplicationECSService.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import { Resource } from '@cdktf/provider-null/lib/resource';
import { Sleep } from '@cdktf/provider-time/lib/sleep';
import { Construct } from 'constructs';
import { ApplicationECR, ECRProps } from './ApplicationECR';
import { ApplicationECSIAM, ApplicationECSIAMProps } from './ApplicationECSIAM';
import { ApplicationECR, ECRProps } from './ApplicationECR.js';
import {
ApplicationECSIAM,
ApplicationECSIAMProps,
} from './ApplicationECSIAM.js';
import {
ApplicationECSContainerDefinitionProps,
buildDefinitionJSON,
} from './ApplicationECSContainerDefinition';
import { ApplicationTargetGroup } from './ApplicationTargetGroup';
import { ApplicationECSAlbCodeDeploy } from './ApplicationECSAlbCodeDeploy';
} from './ApplicationECSContainerDefinition.js';
import { ApplicationTargetGroup } from './ApplicationTargetGroup.js';
import { ApplicationECSAlbCodeDeploy } from './ApplicationECSAlbCodeDeploy.js';
import {
TerraformResource,
TerraformIterator,
TerraformMetaArguments,
Fn,
} from 'cdktf';
import { truncateString } from '../utilities';
import { truncateString } from '../utilities.js';
import { File } from '@cdktf/provider-local/lib/file';
import { AlbListenerRule } from '@cdktf/provider-aws/lib/alb-listener-rule';
import { CloudwatchLogGroup } from '@cdktf/provider-aws/lib/cloudwatch-log-group';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DataAwsLambdaFunction } from '@cdktf/provider-aws/lib/data-aws-lambda-function';
import { Testing } from 'cdktf';
import { ApplicationLambdaSnsTopicSubscription } from './ApplicationLambdaSnsTopicSubscription';
import { ApplicationLambdaSnsTopicSubscription } from './ApplicationLambdaSnsTopicSubscription.js'

describe('ApplicationSqsSnsTopicSubscription', () => {
const getConfig = (stack) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Testing } from 'cdktf';
import { ApplicationLoadBalancer } from './ApplicationLoadBalancer';
import { ApplicationLoadBalancer } from './ApplicationLoadBalancer.js'

describe('ApplicationLoadBalancer', () => {
it('renders an ALB without tags', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Testing } from 'cdktf';
import { ApplicationElasticacheClusterProps } from './ApplicationElasticacheCluster';
import { ApplicationElasticacheClusterProps } from './ApplicationElasticacheCluster.js'

import { ApplicationMemcache } from './ApplicationMemcache';
import { ApplicationMemcache } from './ApplicationMemcache.js'

const BASE_CONFIG: ApplicationElasticacheClusterProps = {
allowedIngressSecurityGroupIds: [],
Expand Down
2 changes: 1 addition & 1 deletion packages/terraform-modules/src/base/ApplicationMemcache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ApplicationElasticacheCluster,
ApplicationElasticacheClusterProps,
ApplicationElasticacheEngine,
} from './ApplicationElasticacheCluster';
} from './ApplicationElasticacheCluster.js';
import { Construct } from 'constructs';
import { DataAwsVpc } from '@cdktf/provider-aws/lib/data-aws-vpc';
import { ElasticacheCluster } from '@cdktf/provider-aws/lib/elasticache-cluster';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Testing } from 'cdktf';
import { ApplicationRDSCluster } from './ApplicationRDSCluster';
import { ApplicationRDSCluster } from './ApplicationRDSCluster.js'

describe('ApplicationRDSCluster', () => {
it('renders a RDS cluster', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/terraform-modules/src/base/ApplicationRedis.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Testing } from 'cdktf';
import { ApplicationElasticacheClusterProps } from './ApplicationElasticacheCluster';
import { ApplicationElasticacheClusterProps } from './ApplicationElasticacheCluster.js'

import { ApplicationRedis } from './ApplicationRedis';
import { ApplicationRedis } from './ApplicationRedis.js'

const BASE_CONFIG: ApplicationElasticacheClusterProps = {
allowedIngressSecurityGroupIds: [],
Expand Down
2 changes: 1 addition & 1 deletion packages/terraform-modules/src/base/ApplicationRedis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ApplicationElasticacheCluster,
ApplicationElasticacheClusterProps,
ApplicationElasticacheEngine,
} from './ApplicationElasticacheCluster';
} from './ApplicationElasticacheCluster.js';
import { Construct } from 'constructs';
import { DataAwsVpc } from '@cdktf/provider-aws/lib/data-aws-vpc';
import { ElasticacheReplicationGroup } from '@cdktf/provider-aws/lib/elasticache-replication-group';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ApplicationElasticacheCluster,
ApplicationElasticacheClusterProps,
ApplicationElasticacheEngine,
} from './ApplicationElasticacheCluster';
} from './ApplicationElasticacheCluster.js';
import { Construct } from 'constructs';
import { Fn } from 'cdktf';
import { DataAwsVpc } from '@cdktf/provider-aws/lib/data-aws-vpc';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SqsQueue } from '@cdktf/provider-aws/lib/sqs-queue';
import { Testing } from 'cdktf';
import { ApplicationSqsSnsTopicSubscription } from './ApplicationSqsSnsTopicSubscription';
import { ApplicationSqsSnsTopicSubscription } from './ApplicationSqsSnsTopicSubscription.js'

describe('ApplicationSqsSnsTopicSubscription', () => {
const getConfig = (stack) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Testing } from 'cdktf';
import { ApplicationTargetGroup } from './ApplicationTargetGroup';
import { ApplicationTargetGroup } from './ApplicationTargetGroup.js'

describe('ApplicationTargetGroup', () => {
it('renders a Target Group without tags', () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/terraform-modules/src/example.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Construct } from 'constructs';
import { App, TerraformStack } from 'cdktf';
import { AwsProvider } from '@cdktf/provider-aws/lib/provider';
import { PocketALBApplication } from './pocket/PocketALBApplication';
import { ApplicationECSContainerDefinitionProps } from './base/ApplicationECSContainerDefinition';
import { PocketALBApplication } from './pocket/PocketALBApplication.js'
import { ApplicationECSContainerDefinitionProps } from './base/ApplicationECSContainerDefinition.js'
import { LocalProvider } from '@cdktf/provider-local/lib/provider';
import { NullProvider } from '@cdktf/provider-null/lib/provider';
import { TimeProvider } from '@cdktf/provider-time/lib/provider';
import { Wafv2WebAcl } from '@cdktf/provider-aws/lib/wafv2-web-acl';
import { PocketAwsSyntheticChecks } from './pocket/PocketCloudwatchSynthetics';
import { PocketVPC } from './pocket/PocketVPC';
import { PocketAwsSyntheticChecks } from './pocket/PocketCloudwatchSynthetics.js'
import { PocketVPC } from './pocket/PocketVPC.js'

class Example extends TerraformStack {
constructor(scope: Construct, name: string) {
Expand Down
74 changes: 37 additions & 37 deletions packages/terraform-modules/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
// this is the entry point for the npm package
// anything we want consumable (module, type, class, etc) should be exported here
export * from './pocket/PocketApiGatewayLambdaIntegration';
export * from './pocket/PocketALBApplication';
export * from './pocket/PocketCloudwatchSynthetics';
export * from './pocket/PocketECSApplication';
export * from './pocket/PocketECSCodePipeline';
export * from './pocket/PocketEventBridgeRuleWithMultipleTargets';
export * from './pocket/PocketEventBridgeWithLambdaTarget';
export * from './pocket/PocketPagerDuty';
export * from './pocket/PocketSQSWithLambdaTarget';
export * from './pocket/PocketVersionedLambda';
export * from './pocket/PocketVPC';
export * from './pocket/PocketSynthetics';
export * from './base/ApplicationAutoscaling';
export * from './base/ApplicationBaseDNS';
export * from './base/ApplicationCertificate';
export * from './base/ApplicationDynamoDBTable';
export * from './base/ApplicationECR';
export * from './base/ApplicationECSAlbCodeDeploy';
export * from './base/ApplicationECSCluster';
export * from './base/ApplicationECSContainerDefinition';
export * from './base/ApplicationECSIAM';
export * from './base/ApplicationECSService';
export * from './base/ApplicationElasticacheCluster';
export * from './base/ApplicationEventBridgeRule';
export * from './base/ApplicationEventBus';
export * from './base/ApplicationLambdaCodeDeploy';
export * from './base/ApplicationLoadBalancer';
export * from './base/ApplicationMemcache';
export * from './base/ApplicationRDSCluster';
export * from './base/ApplicationRedis';
export * from './base/ApplicationServerlessRedis';
export * from './base/ApplicationSQSQueue';
export * from './base/ApplicationSqsSnsTopicSubscription';
export * from './base/ApplicationTargetGroup';
export * from './base/ApplicationVersionedLambda';
export * from './base/ApplicationLambdaSnsTopicSubscription';
export * from './utilities';
export * from './pocket/PocketApiGatewayLambdaIntegration.js';
export * from './pocket/PocketALBApplication.js';
export * from './pocket/PocketCloudwatchSynthetics.js';
export * from './pocket/PocketECSApplication.js';
export * from './pocket/PocketECSCodePipeline.js';
export * from './pocket/PocketEventBridgeRuleWithMultipleTargets.js';
export * from './pocket/PocketEventBridgeWithLambdaTarget.js';
export * from './pocket/PocketPagerDuty.js';
export * from './pocket/PocketSQSWithLambdaTarget.js';
export * from './pocket/PocketVersionedLambda.js';
export * from './pocket/PocketVPC.js';
export * from './pocket/PocketSynthetics.js';
export * from './base/ApplicationAutoscaling.js';
export * from './base/ApplicationBaseDNS.js';
export * from './base/ApplicationCertificate.js';
export * from './base/ApplicationDynamoDBTable.js';
export * from './base/ApplicationECR.js';
export * from './base/ApplicationECSAlbCodeDeploy.js';
export * from './base/ApplicationECSCluster.js';
export * from './base/ApplicationECSContainerDefinition.js';
export * from './base/ApplicationECSIAM.js';
export * from './base/ApplicationECSService.js';
export * from './base/ApplicationElasticacheCluster.js';
export * from './base/ApplicationEventBridgeRule.js';
export * from './base/ApplicationEventBus.js';
export * from './base/ApplicationLambdaCodeDeploy.js';
export * from './base/ApplicationLoadBalancer.js';
export * from './base/ApplicationMemcache.js';
export * from './base/ApplicationRDSCluster.js';
export * from './base/ApplicationRedis.js';
export * from './base/ApplicationServerlessRedis.js';
export * from './base/ApplicationSQSQueue.js';
export * from './base/ApplicationSqsSnsTopicSubscription.js';
export * from './base/ApplicationTargetGroup.js';
export * from './base/ApplicationVersionedLambda.js';
export * from './base/ApplicationLambdaSnsTopicSubscription.js';
export * from './utilities.js';
4 changes: 2 additions & 2 deletions packages/terraform-modules/src/pocket/PocketALBApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {
ApplicationECSService,
ApplicationECSServiceProps,
ApplicationLoadBalancer,
} from '..';
import { PocketVPC } from './PocketVPC';
} from '../index.js';
import { PocketVPC } from './PocketVPC.js'

export interface PocketALBApplicationAlarmProps extends TerraformMetaArguments {
threshold?: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Testing } from 'cdktf';
import { LAMBDA_RUNTIMES } from '../base/ApplicationVersionedLambda';
import { LAMBDA_RUNTIMES } from '../base/ApplicationVersionedLambda.js'
import {
PocketApiGateway,
PocketApiGatewayProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
PocketVersionedLambdaProps,
ApplicationBaseDNS,
ApplicationCertificate,
} from '..';
} from '../index.js';
import { Fn, TerraformMetaArguments } from 'cdktf';
import { ApiGatewayBasePathMapping } from '@cdktf/provider-aws/lib/api-gateway-base-path-mapping';
import {
Expand Down
4 changes: 2 additions & 2 deletions packages/terraform-modules/src/pocket/PocketECSApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
ApplicationECSIAMProps,
ApplicationECSService,
ApplicationECSServiceProps,
} from '../';
import { PocketVPC } from './PocketVPC';
} from '../index.js';
import { PocketVPC } from './PocketVPC.js';

export type CreateECSServiceArgs = {
ecs: ApplicationECSService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
PocketVersionedLambda,
PocketVersionedLambdaProps,
} from './PocketVersionedLambda';
import { LAMBDA_RUNTIMES } from '../base/ApplicationVersionedLambda';
import { LAMBDA_RUNTIMES } from '../base/ApplicationVersionedLambda.js'
import { SqsQueue } from '@cdktf/provider-aws/lib/sqs-queue';

describe('PocketEventBridgeRuleWithMultipleTargets', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ApplicationEventBridgeRule,
ApplicationEventBridgeRuleProps,
Target,
} from '../base/ApplicationEventBridgeRule';
} from '../base/ApplicationEventBridgeRule.js';

export type PocketEventBridgeTargets = {
targetId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PocketEventBridgeWithLambdaTarget,
PocketEventBridgeWithLambdaTargetProps,
} from './PocketEventBridgeWithLambdaTarget';
import { LAMBDA_RUNTIMES } from '../base/ApplicationVersionedLambda';
import { LAMBDA_RUNTIMES } from '../base/ApplicationVersionedLambda.js'

const config: PocketEventBridgeWithLambdaTargetProps = {
name: 'test-event-bridge-lambda',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
ApplicationEventBridgeRule,
ApplicationEventBridgeRuleProps,
Target,
} from '../base/ApplicationEventBridgeRule';
import { ApplicationVersionedLambda } from '../base/ApplicationVersionedLambda';
} from '../base/ApplicationEventBridgeRule.js';
import { ApplicationVersionedLambda } from '../base/ApplicationVersionedLambda.js';
import {
PocketVersionedLambda,
PocketVersionedLambdaProps,
} from './PocketVersionedLambda';
} from './PocketVersionedLambda.js';

export interface PocketEventBridgeWithLambdaTargetProps
extends PocketVersionedLambdaProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Testing } from 'cdktf';
import { PocketPagerDuty, PocketPagerDutyProps } from './PocketPagerDuty';
import { PocketPagerDuty, PocketPagerDutyProps } from './PocketPagerDuty.js'

const config: PocketPagerDutyProps = {
prefix: 'Test-Env',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TerraformStack, Testing } from 'cdktf';
import { LAMBDA_RUNTIMES } from '../base/ApplicationVersionedLambda';
import { LAMBDA_RUNTIMES } from '../base/ApplicationVersionedLambda.js'
import {
PocketSQSWithLambdaTarget,
PocketSQSWithLambdaTargetProps,
Expand Down
Loading

0 comments on commit 3be7590

Please sign in to comment.