Skip to content

Commit 79e9d3e

Browse files
committed
Create infrastructure_cdk for test infrastructure
1 parent bafcb57 commit 79e9d3e

14 files changed

Lines changed: 5534 additions & 0 deletions

Cargo.lock

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hydro_test/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ bytes = "1.1.0"
3333
# https://github.com/GitoxideLabs/cargo-smart-release/issues/36
3434
example_test = { path = "../example_test", version = "^0.0.0", optional = true }
3535
hydro_build_utils = { path = "../hydro_build_utils", version = "^0.0.1", optional = true }
36+
rdkafka = "0.39.0"
3637

3738
[build-dependencies]
3839
stageleft_tool.workspace = true

hydro_test/examples/kafka.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn main() {
2+
// [Leader]
3+
// If it already exists, delete the "financial_transactions" topic
4+
// Create a new topic named "financial_transactions" with 10 partitions.
5+
6+
// Produce 1 million transactions into the financial_transactions topic, spread evenly
7+
// across the 10 partitions
8+
9+
// [Consumers]
10+
// Once the cluster of consumers receives the go-ahead from the leader stream, it may then
11+
// begin to consume the financial transactions and compute the balance of each bank account
12+
}

infrastructure_cdk/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.js
2+
!jest.config.js
3+
*.d.ts
4+
node_modules
5+
6+
# CDK asset staging directory
7+
.cdk.staging
8+
cdk.out

infrastructure_cdk/.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.ts
2+
!*.d.ts
3+
4+
# CDK asset staging directory
5+
.cdk.staging
6+
cdk.out

infrastructure_cdk/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Welcome to your CDK TypeScript project
2+
3+
This is a blank project for CDK development with TypeScript.
4+
5+
The `cdk.json` file tells the CDK Toolkit how to execute your app.
6+
7+
## Useful commands
8+
9+
* `npm run build` compile typescript to js
10+
* `npm run watch` watch for changes and compile
11+
* `npm run test` perform the jest unit tests
12+
* `npx cdk deploy` deploy this stack to your default AWS account/region
13+
* `npx cdk diff` compare deployed stack with current state
14+
* `npx cdk synth` emits the synthesized CloudFormation template
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env node
2+
import * as cdk from 'aws-cdk-lib/core';
3+
import { InfrastructureStack } from '../lib/infrastructure_stack';
4+
5+
const app = new cdk.App();
6+
7+
new InfrastructureStack(app, 'HydroInfrastructureStack', {
8+
description: "Misc. testing infrastructure for Hydro programs",
9+
stackName: "HydroTestInfrastructure"
10+
});

infrastructure_cdk/cdk.json

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"app": "npx ts-node --prefer-ts-exts bin/infrastructure_cdk.ts",
3+
"watch": {
4+
"include": [
5+
"**"
6+
],
7+
"exclude": [
8+
"README.md",
9+
"cdk*.json",
10+
"**/*.d.ts",
11+
"**/*.js",
12+
"tsconfig.json",
13+
"package*.json",
14+
"yarn.lock",
15+
"node_modules",
16+
"test"
17+
]
18+
},
19+
"context": {
20+
"@aws-cdk/aws-signer:signingProfileNamePassedToCfn": true,
21+
"@aws-cdk/aws-ecs-patterns:secGroupsDisablesImplicitOpenListener": true,
22+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
23+
"@aws-cdk/core:checkSecretUsage": true,
24+
"@aws-cdk/core:target-partitions": [
25+
"aws",
26+
"aws-cn"
27+
],
28+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
29+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
30+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
31+
"@aws-cdk/aws-iam:minimizePolicies": true,
32+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
33+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
34+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
35+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
36+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
37+
"@aws-cdk/core:enablePartitionLiterals": true,
38+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
39+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
40+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
41+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
42+
"@aws-cdk/aws-route53-patters:useCertificate": true,
43+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
44+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
45+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
46+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
47+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
48+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
49+
"@aws-cdk/aws-redshift:columnId": true,
50+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
51+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
52+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
53+
"@aws-cdk/aws-kms:aliasNameRef": true,
54+
"@aws-cdk/aws-kms:applyImportedAliasPermissionsToPrincipal": true,
55+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
56+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
57+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
58+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
59+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
60+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
61+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
62+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
63+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
64+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
65+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
66+
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
67+
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
68+
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
69+
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
70+
"@aws-cdk/aws-eks:useNativeOidcProvider": true,
71+
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
72+
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
73+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
74+
"@aws-cdk/aws-s3:keepNotificationInImportedBucket": false,
75+
"@aws-cdk/core:explicitStackTags": true,
76+
"@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true,
77+
"@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": true,
78+
"@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true,
79+
"@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": true,
80+
"@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": true,
81+
"@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": true,
82+
"@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": true,
83+
"@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": true,
84+
"@aws-cdk/aws-ec2:bastionHostUseAmazonLinux2023ByDefault": true,
85+
"@aws-cdk/aws-route53-targets:userPoolDomainNameMethodWithoutCustomResource": true,
86+
"@aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault": true,
87+
"@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections": true,
88+
"@aws-cdk/core:enableAdditionalMetadataCollection": true,
89+
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": false,
90+
"@aws-cdk/aws-s3:setUniqueReplicationRoleName": true,
91+
"@aws-cdk/aws-events:requireEventBusPolicySid": true,
92+
"@aws-cdk/core:aspectPrioritiesMutating": true,
93+
"@aws-cdk/aws-dynamodb:retainTableReplica": true,
94+
"@aws-cdk/aws-stepfunctions:useDistributedMapResultWriterV2": true,
95+
"@aws-cdk/s3-notifications:addS3TrustKeyPolicyForSnsSubscriptions": true,
96+
"@aws-cdk/aws-ec2:requirePrivateSubnetsForEgressOnlyInternetGateway": true,
97+
"@aws-cdk/aws-s3:publicAccessBlockedByDefault": true,
98+
"@aws-cdk/aws-lambda:useCdkManagedLogGroup": true,
99+
"@aws-cdk/aws-elasticloadbalancingv2:networkLoadBalancerWithSecurityGroupByDefault": true,
100+
"@aws-cdk/aws-ecs-patterns:uniqueTargetGroupId": true,
101+
"@aws-cdk/aws-route53-patterns:useDistribution": true,
102+
"@aws-cdk/aws-cloudfront:defaultFunctionRuntimeV2_0": true,
103+
"@aws-cdk/aws-elasticloadbalancingv2:usePostQuantumTlsPolicy": true
104+
}
105+
}

infrastructure_cdk/jest.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
testEnvironment: 'node',
3+
roots: ['<rootDir>/test'],
4+
testMatch: ['**/*.test.ts'],
5+
transform: {
6+
'^.+\\.tsx?$': 'ts-jest'
7+
},
8+
setupFilesAfterEnv: ['aws-cdk-lib/testhelpers/jest-autoclean'],
9+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as cdk from 'aws-cdk-lib/core';
2+
import { Construct } from 'constructs';
3+
import { CfnCluster } from "aws-cdk-lib/aws-msk";
4+
import { Vpc } from 'aws-cdk-lib/aws-ec2';
5+
6+
export class InfrastructureStack extends cdk.Stack {
7+
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
8+
super(scope, id, props);
9+
10+
const hydroAppVpc = new Vpc(this, 'HydroVpc', {
11+
});
12+
13+
new CfnCluster(this, 'KafkaCluster', {
14+
clusterName: `${this.stackName}-Hydro`,
15+
kafkaVersion: '3.9.x.kraft',
16+
brokerNodeGroupInfo: {
17+
clientSubnets: hydroAppVpc.privateSubnets.map(subnet => subnet.subnetId),
18+
instanceType: 'kafka.m7g.large',
19+
},
20+
numberOfBrokerNodes: 2,
21+
});
22+
}
23+
}

0 commit comments

Comments
 (0)