|
| 1 | +# Building Custom Resources |
| 2 | + |
| 3 | +This section describes how to build and upload templates and artifacts to use in a customized deployment. Once uploaded, the locations of the templates and artifacts are used when deploying the Nextflow on AWS Batch solution (see [Customized Deployment](custom-deploy.md)) |
| 4 | + |
| 5 | +## Building a Custom Distribution |
| 6 | + |
| 7 | +This step involves building a distribution of templates and artifacts from the solution's source code. |
| 8 | + |
| 9 | +First, create a local clone of the [Genomics Workflows on AWS](https://github.com/aws-samples/aws-genomics-workflows) source code. The code base contains several directories: |
| 10 | + |
| 11 | +* `_scripts/`: Shell scripts for building and uploading the customized distribution of templates and artifacts |
| 12 | +* `docs/`: Source code for the documentation, written in [MarkDown](https://markdownguide.org) for the [MkDocs](https://mkdocs.org) publishing platform. This documentation may be modified, expanded, and contributed in the same way as source code. |
| 13 | +* `src/`: Source code for the components of the solution: |
| 14 | + * `containers/`: CodeBuild buildspec files for building AWS-specific container images and pushing them to ECR |
| 15 | + * `_common/` |
| 16 | + * `build.sh`: A generic build script that first builds a base image for a container, then builds an AWS specific image |
| 17 | + * `entrypoint.aws.sh`: A generic entrypoint script that wraps a call to a binary tool in the container with handlers data staging from/to S3 |
| 18 | + * `nextflow/` |
| 19 | + * `Dockerfile` |
| 20 | + * `nextflow.aws.sh`: Docker entrypoint script to execute the Nextflow workflow on AWS Batch |
| 21 | + * `ebs-autoscale/` |
| 22 | + * `get-amazon-ebs-autoscale.sh`: Script to retrieve and install [Amazon EBS Autoscale](https://github.com/awslabs/amazon-ebs-autoscale) |
| 23 | + * `ecs-additions/`: Scripts to be installed on ECS host instances to support the distribution |
| 24 | + * `awscli-shim.sh`: Installed as `/opt/aws-cli/bin/aws` and mounted onto the container, allows container images without full glibc to use the AWS CLI v2 through supplied shared libraries (especially libz) and `LD_LIBRARY_PATH`. |
| 25 | + * `ecs-additions-common.sh`: Utility script to install `fetch_and_run.sh`, Nextflow and Cromwell shims, and swap space |
| 26 | + * `ecs-additions-cromwell-linux2-worker.sh`: |
| 27 | + * `ecs-additions-cromwell.sh`: |
| 28 | + * `ecs-additions-nextflow.sh`: |
| 29 | + * `ecs-additions-step-functions.sh`: |
| 30 | + * `fetch_and_run.sh`: Uses AWS CLI to download and run scripts and zip files from S3 |
| 31 | + * `provision.sh`: Appended to the userdata in the launch template created by [gwfcore-launch-template](custom-deploy.md): Starts SSM Agent, ECS Agent, Docker; runs `get-amazon-ebs-autoscale.sh`, `ecs-additions-common.sh` and orchestrator-specific `ecs-additions-` scripts. |
| 32 | + * `lambda/`: Lambda functions to create, modify or delete ECR registries or CodeBuild jobs |
| 33 | + * `templates/`: CloudFormation templates for the solution stack, as described in [Customized Deployment](custom-deploy.md) |
| 34 | + |
| 35 | +## Deploying a Custom Distribution |
| 36 | + |
| 37 | +The script `_scripts/deploy.sh` will create a custom distribution of artifacts and templates from files in the source tree, then upload this distribution to an S3 bucket. It will optionally also build and deploy a static documentation site from the Markdown documentation files. Its usage is: |
| 38 | + |
| 39 | +```sh |
| 40 | + deploy.sh [--site-bucket BUCKET] [--asset-bucket BUCKET] |
| 41 | + [--asset-profile PROFILE] [--deploy-region REGION] |
| 42 | + [--public] [--verbose] |
| 43 | + STAGE |
| 44 | + |
| 45 | + --site-bucket BUCKET Deploy documentation site to BUCKET |
| 46 | + --asset-bucket BUCKET Deploy assets to BUCKET |
| 47 | + --asset-profile PROFILE Use PROFILE for AWS CLI commands |
| 48 | + --deploy-region REGION Deploy in region REGION |
| 49 | + --public Deploy to public bucket with '--acl public-read' (Default false) |
| 50 | + --verbose Display more output |
| 51 | + STAGE 'test' or 'production' |
| 52 | +``` |
| 53 | + |
| 54 | +When running this script from the command line, use the value `test` for the stage. This will deploy the templates and artifacts into a directory `test` in your deployment bucket: |
| 55 | + |
| 56 | +``` |
| 57 | +$ aws s3 ls s3://my-deployment-bucket/test/ |
| 58 | + PRE artifacts/ |
| 59 | + PRE templates/ |
| 60 | +``` |
| 61 | + |
| 62 | +Use these values when deploying a customized installation, as described in [Customized Deployment](custom-deploy.md), sections 'Artifacts and Nested Stacks' and 'Nextflow'. In the example from above, the values to use would be: |
| 63 | + |
| 64 | +* Artifact S3 Bucket Name: `my-deployment-bucket` |
| 65 | +* Artifact S3 Prefix: `test/artifacts` |
| 66 | +* Template Root URL: `https://my-deployment-bucket.s3.amazonaws.com/test/templates` |
| 67 | + |
| 68 | +The use of `production` for stage is reserved for deployments from a Travis CI/CD environment; this usage will deploy into a subdirectory named after the current release tag. |
0 commit comments