-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "MIGRATIONS-1200 - Remove historical capture CDK stack"
This reverts commit 4c93092.
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
deployment/cdk/opensearch-service-migration/lib/historical-capture-stack.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {Stack, StackProps} from "aws-cdk-lib"; | ||
import {IVpc} from "aws-cdk-lib/aws-ec2"; | ||
import {Construct} from "constructs"; | ||
import {Cluster, ContainerImage, FargateService, FargateTaskDefinition, LogDrivers} from "aws-cdk-lib/aws-ecs"; | ||
import {DockerImageAsset} from "aws-cdk-lib/aws-ecr-assets"; | ||
import {join} from "path"; | ||
import { readFileSync } from "fs" | ||
|
||
export interface historicalCaptureStackProps extends StackProps { | ||
readonly vpc: IVpc, | ||
readonly logstashConfigFilePath: string, | ||
readonly sourceEndpoint?: string, | ||
readonly targetEndpoint: string | ||
} | ||
|
||
/** | ||
* This stack was a short exploratory task into having a deployable Logstash ECS cluster for historical data migration. | ||
* NOTE: It should only be used for development purposes in its current state | ||
*/ | ||
export class HistoricalCaptureStack extends Stack { | ||
|
||
constructor(scope: Construct, id: string, props: historicalCaptureStackProps) { | ||
super(scope, id, props); | ||
|
||
const ecsCluster = new Cluster(this, "ecsHistoricalCaptureCluster", { | ||
vpc: props.vpc | ||
}); | ||
|
||
const historicalCaptureFargateTask = new FargateTaskDefinition(this, "historicalCaptureFargateTask", { | ||
memoryLimitMiB: 2048, | ||
cpu: 512 | ||
}); | ||
|
||
let logstashConfigData: string = readFileSync(props.logstashConfigFilePath, 'utf8'); | ||
if (props.sourceEndpoint) { | ||
logstashConfigData = logstashConfigData.replace("<SOURCE_CLUSTER_HOST>", props.sourceEndpoint) | ||
} | ||
logstashConfigData = logstashConfigData.replace("<TARGET_CLUSTER_HOST>", props.targetEndpoint + ":80") | ||
// Temporary measure to allow multi-line env variable | ||
logstashConfigData = logstashConfigData.replace(/(\n)/g, "PUT_LINE") | ||
// Create Historical Capture Container | ||
const historicalCaptureImage = new DockerImageAsset(this, "historicalCaptureImage", { | ||
directory: join(__dirname, "../../..", "docker/logstash-setup") | ||
}); | ||
|
||
const historicalCaptureContainer = historicalCaptureFargateTask.addContainer("historicalCaptureContainer", { | ||
image: ContainerImage.fromDockerImageAsset(historicalCaptureImage), | ||
// Add in region and stage | ||
containerName: "logstash", | ||
environment: {"LOGSTASH_CONFIG": '' + logstashConfigData}, | ||
logging: LogDrivers.awsLogs({ streamPrefix: 'logstash-lg', logRetention: 30 }) | ||
}); | ||
|
||
// Create Fargate Service | ||
const historicalCaptureFargateService = new FargateService(this, "historicalCaptureFargateService", { | ||
cluster: ecsCluster, | ||
taskDefinition: historicalCaptureFargateTask, | ||
desiredCount: 1 | ||
}); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters