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

Dependencies Update && Support Samplesheet V2 #34

Merged
merged 6 commits into from
Dec 20, 2023
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# samplesheet-check-frontend

This is the front end code for UMCCR samplesheet check.
This is the frontend code for UMCCR samplesheet check.

The directories:
- *deploy* - It will contain the AWS cdk cloud infrastructrure.
Expand Down
2 changes: 1 addition & 1 deletion buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 0.2
phases:
install:
runtime-versions:
nodejs: 14
nodejs: 18
commands:
- npm i react-scripts
build:
Expand Down
15 changes: 4 additions & 11 deletions deploy/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# UMCCR client CDK for Samplesheet Check

This cdk will build an AWS cloud infrastructure for the UMCCR samplesheet check.

This cdk will build an AWS cloud infrastructure for the UMCCR samplesheet check.

The directories:
- *cdkpipeline* - Contain the stack for the pipeline.
Expand All @@ -17,18 +16,17 @@ The directories:
Setup DNS for the samplesheet check for cloudfront

# Setting up
It is recommended to create a virtual environment for the app.

It is recomended to create a virtual environment for the app.

To do so please follow the instruction below.
To do so please follow the instructions below.

Change your directory to the root of this readme file.
```
$ cd deploy
```
Create a virtual environment for the app.
```
$ python3 -m venv .venv
$ virtualenv .venv --python=python3.11
```

After the init process completes and the virtualenv is created, you can use the following
Expand All @@ -38,11 +36,6 @@ step to activate your virtualenv.
$ source .venv/bin/activate
```

If you are a Windows platform, you might try this:

```
% .venv\Scripts\activate.bat
```
Once the virtualenv is activated, you can install the required dependencies.

```
Expand Down
4 changes: 2 additions & 2 deletions deploy/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import os

from aws_cdk import core as cdk
from aws_cdk import App

# Import cdk pipeline stack
from stacks.pipeline_stack import PipelineStack
Expand Down Expand Up @@ -42,7 +42,7 @@
}
}

app = cdk.App(
app = App(
context={
"app_stage": app_stage,
"props": props
Expand Down
8 changes: 0 additions & 8 deletions deploy/cdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@
"app": "python3 app.py",
"context": {
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
"@aws-cdk/core:enableStackNameDuplicates": "true",
"aws-cdk:enableDiffNoFail": "true",
"@aws-cdk/core:stackRelativeExports": "true",
"@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true,
"@aws-cdk/aws-secretsmanager:parseOwnedSecretName": true,
"@aws-cdk/aws-kms:defaultKeyPolicies": true,
"@aws-cdk/aws-s3:grantWriteWithoutAcl": true,
"@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount": true,
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
"@aws-cdk/aws-efs:defaultEncryptionAtRest": true,
"@aws-cdk/aws-lambda:recognizeVersionProps": true,
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
"@aws-cdk/core:newStyleStackSynthesis": true
}
}
18 changes: 2 additions & 16 deletions deploy/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,2 @@
aws-cdk.core==1.122.0
aws-cdk.aws-lambda==1.122.0
aws-cdk.aws-apigateway==1.122.0
aws-cdk.aws-cognito==1.122.0
aws-cdk.aws-route53-targets==1.122.0
aws-cdk.pipelines==1.122.0
aws-cdk.aws-ssm==1.122.0
aws-cdk.aws-codepipeline==1.122.0
aws-cdk.aws-codepipeline_actions==1.122.0
aws-cdk.aws-codebuild==1.122.0
aws-cdk.aws-route53==1.122.0
aws-cdk.aws-certificatemanager==1.122.0
aws-cdk.aws-s3==1.122.0
aws-cdk.aws-iam==1.122.0
aws-cdk.aws-cloudfront==1.122.0
aws-cdk.aws-sns==1.122.0
aws-cdk-lib==2.114.1
constructs>=10.0.0
13 changes: 0 additions & 13 deletions deploy/source.bat

This file was deleted.

34 changes: 18 additions & 16 deletions deploy/stacks/pipeline_stack.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# importing modules
from constructs import Construct
import os
from aws_cdk import (
Stack,
Stage,
Duration,
RemovalPolicy,
aws_ssm as ssm,
pipelines,
core as cdk,
aws_codepipeline as codepipeline,
aws_s3 as s3,
aws_codepipeline_actions as codepipeline_actions,
Expand All @@ -15,8 +19,8 @@
from stacks.sscheck_front_end_stack import SampleSheetCheckFrontEndStack


class SampleSheetCheckFrontEndStage(cdk.Stage):
def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
class SampleSheetCheckFrontEndStage(Stage):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)

app_stage = self.node.try_get_context("app_stage")
Expand All @@ -39,9 +43,9 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
# Class for the CDK pipeline stack


class PipelineStack(cdk.Stack):
class PipelineStack(Stack):

def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)

# Defining app stage
Expand All @@ -61,7 +65,7 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
"sscheck-front-end-artifact-bucket",
bucket_name=props["pipeline_artifact_bucket_name"][app_stage],
auto_delete_objects=True,
removal_policy=cdk.RemovalPolicy.DESTROY,
removal_policy=RemovalPolicy.DESTROY,
block_public_access=s3.BlockPublicAccess.BLOCK_ALL
)

Expand Down Expand Up @@ -99,14 +103,10 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
input=code_pipeline_source,
commands=[
"cdk synth",
"mkdir ./cfnnag_output",
"for template in $(find ./cdk.out -type f -maxdepth 2 -name '*.template.json'); do cp $template ./cfnnag_output; done",
"cfn_nag_scan --input-path ./cfnnag_output"
],
install_commands=[
"cd deploy",
"npm install -g aws-cdk",
"gem install cfn-nag",
"pip install -r requirements.txt"
],
primary_output_directory="deploy/cdk.out"
Expand Down Expand Up @@ -137,7 +137,7 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
description="The project from codebuild to build react project.",
project_name="SSCheckFrontEndReactBuild",
environment=codebuild.BuildEnvironment(
build_image=codebuild.LinuxBuildImage.STANDARD_5_0
build_image=codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0
)
)

Expand All @@ -146,8 +146,10 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
actions=["ssm:GetParameter"],
effect=iam.Effect.ALLOW,
resources=[
"arn:aws:ssm:%s:%s:parameter/sscheck/*" % (self.region, self.account),
"arn:aws:ssm:%s:%s:parameter/data_portal/client/*" % (self.region, self.account)
"arn:aws:ssm:%s:%s:parameter/sscheck/*" % (
self.region, self.account),
"arn:aws:ssm:%s:%s:parameter/data_portal/client/*" % (
self.region, self.account)
]
)
)
Expand Down Expand Up @@ -229,7 +231,7 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
project_name="InvalidateSSCheckCDNCache",
check_secrets_in_plain_text_env_variables=False,
environment=codebuild.BuildEnvironment(
build_image=codebuild.LinuxBuildImage.STANDARD_5_0
build_image=codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0
),
build_spec=codebuild.BuildSpec.from_object({
"version": "0.2",
Expand All @@ -247,8 +249,8 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
}
}
}),
timeout=cdk.Duration.minutes(5),
queued_timeout=cdk.Duration.minutes(5)
timeout=Duration.minutes(5),
queued_timeout=Duration.minutes(5)
)

# Add invalidate CDN role
Expand Down
13 changes: 8 additions & 5 deletions deploy/stacks/sscheck_front_end_stack.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import os
from constructs import Construct
from aws_cdk import (
core as cdk,
Stack,
RemovalPolicy,
CfnOutput,
aws_s3 as s3,
aws_cloudfront as cloudfront,
aws_ssm as ssm,
Expand All @@ -12,9 +15,9 @@
)


class SampleSheetCheckFrontEndStack(cdk.Stack):
class SampleSheetCheckFrontEndStack(Stack):

def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)

# Defining app constants
Expand Down Expand Up @@ -64,7 +67,7 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
"umccr-samplesheet-script",
bucket_name=bucket_name,
auto_delete_objects=True,
removal_policy=cdk.RemovalPolicy.DESTROY,
removal_policy=RemovalPolicy.DESTROY,
website_index_document="index.html",
website_error_document="index.html",
block_public_access=s3.BlockPublicAccess.BLOCK_ALL
Expand Down Expand Up @@ -127,7 +130,7 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
)

# Cloudformation Distribution_id
cdk.CfnOutput(
CfnOutput(
self,
'CfnOutputCloudFrontDistributionId',
value=sscheck_cloudfront.distribution_id
Expand Down
3 changes: 1 addition & 2 deletions get_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ oauth_redirect_in=$(aws ssm get-parameter --name '/data_portal/client/oauth_redi
oauth_redirect_out=$(aws ssm get-parameter --name '/data_portal/client/oauth_redirect_out_local' | jq -r .Parameter.Value)

lambda_api_domain=$(aws ssm get-parameter --name '/sscheck/lambda-api-domain' | jq -r .Parameter.Value)
bucket_name=$(aws ssm get-parameter --name '/sscheck/bucket_name' | jq -r .Parameter.Value)

data_portal_api_domain=$(aws ssm get-parameter --name '/data_portal/backend/api_domain_name' | jq -r .Parameter.Value)

export REACT_APP_BUCKET_NAME=$bucket_name
export REACT_APP_BUCKET_NAME=org.umccr.dev.sscheck
export REACT_APP_LAMBDA_API_DOMAIN=$lambda_api_domain
export REACT_APP_REGION=ap-southeast-2

Expand Down
Loading