Skip to content

Initialise ICAv2 Data Copy Manager #788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ import {
getFastqSyncManagerStackProps,
getFastqSyncManagerTableStackProps,
} from './stacks/fastqSyncManager';
import {
getIcav2DataCopyManagerStackProps,
getIcav2DataCopyManagerTableStackProps,
} from './stacks/icav2DataCopyManager';

interface EnvironmentConfig {
name: string;
Expand Down Expand Up @@ -120,6 +124,7 @@ export const getEnvironmentConfig = (stage: AppStage): EnvironmentConfig | null
fastqManagerTableStackProps: getFastqManagerTableStackProps(stage),
fastqUnarchivingManagerTableStackProps: getFastqUnarchivingManagerTableStackProps(),
fastqSyncManagerTableStackProps: getFastqSyncManagerTableStackProps(),
icav2DataCopyTableStackProps: getIcav2DataCopyManagerTableStackProps(),
},
statelessConfig: {
metadataManagerStackProps: getMetadataManagerStackProps(stage),
Expand Down Expand Up @@ -153,6 +158,7 @@ export const getEnvironmentConfig = (stage: AppStage): EnvironmentConfig | null
fastqManagerStackProps: getFastqManagerStackProps(stage),
fastqUnarchivingManagerStackProps: getFastqUnarchivingManagerStackProps(stage),
fastqSyncManagerStackProps: getFastqSyncManagerStackProps(stage),
icav2DataCopyManagerStackProps: getIcav2DataCopyManagerStackProps(stage),
},
};

Expand Down
7 changes: 7 additions & 0 deletions config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,10 @@ export const fastqUnarchivingManagerEventSource = 'orcabus.fastqunarchivingmanag
Fastq sync service
*/
export const fastqSyncEventDetailType = 'fastqSync';

/*
ICAv2 ProjectData Copy Manager Stack
*/
export const icav2DataCopyManagerDynamodbTableName = 'icav2DataCopyManagerDynamoDBTable';
export const icav2DataCopyEventSource = 'orcabus.icav2datacopymanager';
export const icav2DataCopySyncDetailType = 'ICAv2DataCopySync';
53 changes: 53 additions & 0 deletions config/stacks/icav2DataCopyManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {
AppStage,
eventBusName,
icaEventPipeStackName,
icav2AccessTokenSecretName,
icav2DataCopyEventSource,
icav2DataCopyManagerDynamodbTableName,
icav2DataCopySyncDetailType,
} from '../constants';
import { Icav2DataCopyManagerTableConfig } from '../../lib/workload/stateful/stacks/icav2-data-copy-manager-dynamo-db/deploy';
import { Icav2DataCopyManagerConfig } from '../../lib/workload/stateless/stacks/icav2-data-copy-manager/deploy/interfaces';

/*
Internal constants
*/
const icav2DataCopyInternalDetailType = 'ICAv2DataCopyInternalSync';

// Stateful
export const getIcav2DataCopyManagerTableStackProps = (): Icav2DataCopyManagerTableConfig => {
return {
dynamodbTableName: icav2DataCopyManagerDynamodbTableName,
};
};

// Stateless
export const getIcav2DataCopyManagerStackProps = (stage: AppStage): Icav2DataCopyManagerConfig => {
return {
/*
Tables
*/
dynamodbTableName: icav2DataCopyManagerDynamodbTableName,

/*
Event handling
*/
eventBusName: eventBusName,
icaEventPipeName: icaEventPipeStackName,
eventSource: icav2DataCopyEventSource,
eventExternalDetailType: icav2DataCopySyncDetailType,
eventInternalDetailType: icav2DataCopyInternalDetailType,

/*
Names for things
*/
stateMachinePrefix: 'icav2-data-copy',
ruleNamePrefix: 'icav2-data-copy',

/*
Secrets
*/
icav2AccessTokenSecretId: icav2AccessTokenSecretName[stage], // "/icav2/umccr-prod/service-production-jwt-token-secret-arn"
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { DynamodbPartitionedPipelineConstruct } from '../../../../components/dynamodb-partitioned-table';

export interface Icav2DataCopyManagerTableConfig {
dynamodbTableName: string;
}

export type Icav2DataCopyManagerTableStackProps = Icav2DataCopyManagerTableConfig & cdk.StackProps;

export class Icav2DataCopyManagerTable extends cdk.Stack {
constructor(scope: Construct, id: string, props: Icav2DataCopyManagerTableStackProps) {
super(scope, id, props);

/*
Initialise dynamodb table with id and sort keys
*/
new DynamodbPartitionedPipelineConstruct(this, props.dynamodbTableName, {
tableName: props.dynamodbTableName,
});
}
}
14 changes: 14 additions & 0 deletions lib/workload/stateful/statefulStackCollectionClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ import {
FastqSyncManagerTable,
FastqSyncManagerTableStackProps,
} from './stacks/fastq-sync-dynamodb/deploy/stack';
import {
Icav2DataCopyManagerTable,
Icav2DataCopyManagerTableStackProps,
} from './stacks/icav2-data-copy-manager-dynamo-db/deploy';

export interface StatefulStackCollectionProps {
dataBucketStackProps: DataBucketStackProps;
Expand All @@ -103,6 +107,7 @@ export interface StatefulStackCollectionProps {
fastqManagerTableStackProps: FastqManagerTableStackProps;
fastqUnarchivingManagerTableStackProps: FastqUnarchivingManagerTableStackProps;
fastqSyncManagerTableStackProps: FastqSyncManagerTableStackProps;
icav2DataCopyTableStackProps: Icav2DataCopyManagerTableStackProps;
}

export class StatefulStackCollection {
Expand Down Expand Up @@ -131,6 +136,7 @@ export class StatefulStackCollection {
readonly fastqManagerTableStack: Stack;
readonly fastqUnarchivingManagerTableStack: Stack;
readonly fastqSyncManagerTableStack: Stack;
readonly icav2DataCopyTableStack: Stack;

constructor(
scope: Construct,
Expand Down Expand Up @@ -307,6 +313,14 @@ export class StatefulStackCollection {
...statefulConfiguration.fastqSyncManagerTableStackProps,
}
);
this.icav2DataCopyTableStack = new Icav2DataCopyManagerTable(
scope,
'Icav2DataCopyManagerTableStack',
{
...this.createTemplateProps(env, 'Icav2DataCopyManagerTableStack'),
...statefulConfiguration.icav2DataCopyTableStackProps,
}
);
}

/**
Expand Down
50 changes: 50 additions & 0 deletions lib/workload/stateless/stacks/icav2-data-copy-manager/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ICAv2 Data Copy Manager

Service for copying data from one location to another.

Supports a TaskToken object that can be used to allow step functions to hang until the copy is complete for other services
that may call this service.

## Usage

Given a list of source uris, and a destination uri, the service will copy the data from the source to the destination.

The destination uri does not need to exist prior to the copy, but the source uris must exist.

**If the source uri is a folder, it will be a subfolder in the destination.**

If a file size is a single-part-upload, we will use the `requests` library to download the file and upload it to the destination,
since single-part uploads often fail when the source object is tagged.

AWS S3 URIs in the sourceUriList and destinationUri are also supported.

The Task Token is optional and can be used to allow the calling service to wait for the copy to complete.

## Event Example

```json
{
"EventBusName": "OrcaBusMain",
"Source": "Whatever",
"DetailType": "ICAv2DataCopySync",
"Detail": {
"payload": {
"sourceUriList": [
"icav2://project-id-or-name/path-to-data.txt",
"icav2://project-id-or-name/path-to-folder/"
],
"destinationUri": "icav2://project-id-or-name/path-to-destination/"
},
"taskToken": "your-task-token"
}
}
```

## Recursive Copy

This service will recursively copy all files and folders from the source to the destination.
For each subfolder, it will generate its own copy event and send it to the event bus, which is picked up by itself.

This allows for a single event to be sent to the service, and it will handle the rest.

Be very careful with this, recursive events should be used with caution, as they can cause infinite loops if not handled properly.
Loading
Loading