7
7
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
8
8
# limitations under the License.
9
9
10
- usage=" $( basename " $0 " ) [-h] --s3-bucket bucket-name --region aws-region [--stack-name name] [--enable-iam-admin true|false] [--create-api-user true|false]) "
10
+ usage=" $( basename " $0 " ) [-h] --s3-bucket bucket-name --region aws-region [--stack-name name] [--enable-iam-admin true|false] [--create-api-user true|false] [--lambda-layer abs_path] "
11
11
12
12
SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd ) "
13
13
14
14
S3_BUCKET=
15
15
STACK_NAME=" ParallelClusterApi"
16
16
ENABLE_IAM_ADMIN=" true"
17
17
CREATE_API_USER=" false"
18
+ LAMBDA_LAYER=
18
19
while [[ $# -gt 0 ]]
19
20
do
20
21
key=" $1 "
@@ -59,6 +60,11 @@ case $key in
59
60
shift # past argument
60
61
shift # past value
61
62
;;
63
+ --lambda-layer)
64
+ export LAMBDA_LAYER=$2
65
+ shift # past argument
66
+ shift # past value
67
+ ;;
62
68
* ) # unknown option
63
69
echo " $usage " >&2
64
70
exit 1
@@ -71,6 +77,8 @@ if [ -z "${S3_BUCKET}" ] || [ -z "${AWS_DEFAULT_REGION}" ] ; then
71
77
exit 1
72
78
fi
73
79
80
+ PC_VERSION=$( yq " .Mappings.ParallelCluster.Constants.Version" " ${SCRIPT_DIR} /parallelcluster-api.yaml" )
81
+
74
82
S3_UPLOAD_URI=" s3://${S3_BUCKET} /api/ParallelCluster.openapi.yaml"
75
83
POLICIES_S3_URI=" s3://${S3_BUCKET} /stacks/parallelcluster-policies.yaml"
76
84
POLICIES_TEMPLATE_URI=" http://${S3_BUCKET} .s3.${AWS_DEFAULT_REGION} .amazonaws.com/stacks/parallelcluster-policies.yaml"
@@ -81,6 +89,12 @@ aws s3 cp "${SCRIPT_DIR}/../spec/openapi/ParallelCluster.openapi.yaml" "${S3_UPL
81
89
echo " Publishing policies CloudFormation stack to S3"
82
90
aws s3 cp " ${SCRIPT_DIR} /../../cloudformation/policies/parallelcluster-policies.yaml" " ${POLICIES_S3_URI} "
83
91
92
+ if [ -n " ${LAMBDA_LAYER} " ]; then
93
+ LAMBDA_LAYER_S3_URI=" s3://${S3_BUCKET} /parallelcluster/${PC_VERSION} /layers/aws-parallelcluster/lambda-layer.zip"
94
+ echo " Publishing Lambda Layer for version ${PC_VERSION} to S3"
95
+ aws s3 cp " ${LAMBDA_LAYER} " " ${LAMBDA_LAYER_S3_URI} "
96
+ fi
97
+
84
98
echo " Deploying API template"
85
99
aws cloudformation deploy \
86
100
--stack-name " ${STACK_NAME} " \
@@ -90,4 +104,5 @@ aws cloudformation deploy \
90
104
--parameter-overrides ApiDefinitionS3Uri=" ${S3_UPLOAD_URI} " \
91
105
PoliciesTemplateUri=" ${POLICIES_TEMPLATE_URI} " \
92
106
EnableIamAdminAccess=" ${ENABLE_IAM_ADMIN} " CreateApiUserRole=" ${CREATE_API_USER} " \
107
+ " $( [[ -n " ${LAMBDA_LAYER} " ]] && echo " CustomBucket=${S3_BUCKET} " || echo " " ) " \
93
108
--capabilities CAPABILITY_NAMED_IAM
0 commit comments