Skip to content

Commit c6520d7

Browse files
authored
Merge pull request #76 from aws-samples/packaging-script-readme
packaging script README
2 parents cac62c3 + a4b45e3 commit c6520d7

File tree

1 file changed

+43
-0
lines changed
  • aws_sra_examples/utils/packaging_scripts

1 file changed

+43
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Packaging Scripts
2+
3+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: CC-BY-SA-4.0
4+
5+
---
6+
7+
## package-lambda.sh
8+
9+
- Script to package solution Lambda code and stage it within an AWS S3 bucket
10+
- Inputs
11+
- `--file_name` [required] Lambda zip file
12+
- `--src_dir` [required] Lambda source directory
13+
- `--bucket` [optional] S3 bucket name for lambda source
14+
- Logic
15+
- Creates a new folder `dist-xxxx` within the calling directory to hold the Lambda zip file, if the S3 bucket is not provide or the script cannot access it
16+
- Creates a new temporary folder `tmp-sra-lambda-src-XXXX` within the $HOME directory to stage the files and libraries for packaging
17+
- Copies of the files within the provided Lambda source folder (e.g. `app.py` and `requirements.txt`) to the temporary folder `tmp-sra-lambda-src-XXXX`
18+
- Downloads the libraries within the `requirements.txt` file using pip3 to the temporary folder `tmp-sra-lambda-src-XXXX`
19+
- Creates a zip file with the contents of the temporary folder `tmp-sra-lambda-src-XXXX` and saves it to the `dist-xxxx` folder
20+
- Removes the temporary folder `tmp-sra-lambda-src-XXXX` after the zip file is created
21+
- If an AWS S3 bucket is provided, the zip file is uploaded to the S3 bucket
22+
- The `dist-xxxx` folder is removed, if the upload to S3 is successful
23+
24+
## stage_solution.sh
25+
26+
- Script to package solution Lambda code, stage the Lambda zip, and stage the CloudFormation templates to an AWS S3 staging bucket
27+
- Inputs
28+
- `--staging_bucket_name` [required] Staging S3 bucket name
29+
- `--solution_directory` [required] SRA solution directory path
30+
- Logic
31+
- Creates a new folder `sra_staging_manual_upload` within the code repository root directory to store all files uploaded to the S3 bucket
32+
- Copies the solution template files to `sra_staging_manual_upload/solution-name/templates` folder
33+
- Determines the number of Lambda code folders
34+
- For each Lambda code folder within the solution directory
35+
- Creates a new temporary folder `tmp-sra-lambda-src-XXXX` within the $HOME directory to stage the files and libraries for packaging
36+
- Copies of the files within the provided Lambda source folder (e.g. `app.py` and `requirements.txt`) to the temporary folder `tmp-sra-lambda-src-XXXX`
37+
- Downloads the libraries within the `requirements.txt` file using pip3 to the temporary folder `tmp-sra-lambda-src-XXXX`
38+
- Creates a zip file with the contents of the temporary folder `tmp-sra-lambda-src-XXXX` and saves it to the `sra_staging_manual_upload/solution-name/lambda_code` folder
39+
- Removes the temporary folder `tmp-sra-lambda-src-XXXX` after the zip file is created
40+
- If there is one Lambda code folder, the Lambda zip file name will only include the solution name (e.g. `solution-name.zip`)
41+
- If there is more than one Lambda code folder, each Lambda zip file name will be the solution name and the Lambda code folder (e.g. `solution-name-lambda-folder.zip`)
42+
- Uploads the templates and Lambda code from the `sra_staging_manual_upload/solution-name' folder to the staging S3 bucket
43+
- Update each Lambda function with the new code, if the Lambda function already exists within the `management account`

0 commit comments

Comments
 (0)