Skip to content
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

fix(filemanager): presigned URL access #499

Merged
merged 2 commits into from
Aug 19, 2024
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
1 change: 1 addition & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ services:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-access_key_id}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-secret_access_key}
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-ap-southeast-2}
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN:-session_token}
ports:
- '8400:8000'
build:
Expand Down
2 changes: 1 addition & 1 deletion lib/workload/stateless/stacks/filemanager/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ docker-run: docker-build
docker compose -p "$(DOCKER_PROJECT_NAME)" run -d --service-ports postgres | xargs -I {} docker port {} 4321
docker-find:
# Find a running filemanager docker container.
@docker ps --filter name=$(DOCKER_PROJECT_NAME) --latest --format "{{.ID}}" | xargs -I {} docker port {} 4321
@docker ps --filter name=$(DOCKER_PROJECT_NAME)-postgres --latest --format "{{.ID}}" | xargs -I {} docker port {} | tail -n 1 | awk '{print $$NF}'
docker-api: docker-postgres
# Run the local API server in a docker container.
@docker compose -p "$(DOCKER_PROJECT_NAME)" up api
Expand Down
1 change: 1 addition & 0 deletions lib/workload/stateless/stacks/filemanager/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-access_key_id}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-secret_access_key}
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-ap-southeast-2}
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN:-session_token}
ports:
- "8000:8000"
depends_on:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Construct } from 'constructs';
import * as fn from './function';
import { DatabaseProps } from './function';
import { BucketProps } from './ingest';

/**
* Props for the API function.
*/
export type ApiFunctionProps = fn.FunctionPropsNoPackage & DatabaseProps;
export type ApiFunctionProps = fn.FunctionPropsNoPackage & DatabaseProps & BucketProps;

/**
* A construct for the Lambda API function.
Expand All @@ -22,5 +23,7 @@ export class ApiFunction extends fn.Function {
},
...props,
});

this.addPoliciesForBuckets(props.buckets);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ import { SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources';
import { DatabaseProps } from './function';

/**
* Props related to the filemanager event source.
* Props for controlling access to buckets.
*/
export type EventSourceProps = {
/**
* The SQS queue URL to receive events from.
*/
readonly eventSources: IQueue[];
export type BucketProps = {
/**
* The buckets that the filemanager is expected to process. This will add policies to access the buckets via
* 's3:List*' and 's3:Get*'.
*/
readonly buckets: string[];
};

/**
* Props related to the filemanager event source.
*/
export type EventSourceProps = {
/**
* The SQS queue URL to receive events from.
*/
readonly eventSources: IQueue[];
} & BucketProps;

/**
* Props for the ingest function.
*/
Expand Down
1 change: 1 addition & 0 deletions lib/workload/stateless/stacks/filemanager/deploy/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export class Filemanager extends Stack {
vpc: this.vpc,
host: this.host,
securityGroup: this.securityGroup,
buckets: [...props.eventSourceBuckets, ...props.inventorySourceBuckets],
...props,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ impl Client {
self.inner
.get_object()
.response_content_disposition(response_content_disposition)
.checksum_mode(Enabled)
.key(key)
.bucket(bucket)
.presigned(
Expand Down