Skip to content

Commit 474f9cf

Browse files
committed
fix shelcheck errors
1 parent 78f4438 commit 474f9cf

File tree

3 files changed

+51
-9
lines changed

3 files changed

+51
-9
lines changed

Examples/_MyFirstFunction/clean.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftAWSLambdaRuntime open source project
5+
##
6+
## Copyright (c) 2017-2024 Apple Inc. and the SwiftAWSLambdaRuntime project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
215

316
echo "This script deletes the Lambda function and the IAM role created in the previous step and deletes the project files."
4-
read -p "Are you you sure you want to delete everything that was created? [y/n] " continue
17+
read -r -p "Are you you sure you want to delete everything that was created? [y/n] " continue
518
if [[ ! $continue =~ ^[Yy]$ ]]; then
619
echo "OK, try again later when you feel ready"
720
exit 1

Examples/_MyFirstFunction/create_and_deploy_function.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftAWSLambdaRuntime open source project
5+
##
6+
## Copyright (c) 2017-2024 Apple Inc. and the SwiftAWSLambdaRuntime project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
215

316
# Stop the script execution if an error occurs
417
set -e -o pipefail
@@ -19,7 +32,7 @@ You must have an AWS account and know an AWS access key, secret access key, and
1932
These values are read from '~/.aws/credentials'.
2033
"
2134

22-
read -p "Are you ready to create your first Lambda function in Swift? [y/n] " continue
35+
read -r -p "Are you ready to create your first Lambda function in Swift? [y/n] " continue
2336
if [[ ! $continue =~ ^[Yy]$ ]]; then
2437
echo "OK, try again later when you feel ready"
2538
exit 1
@@ -84,7 +97,8 @@ echo "🚀 Deploy to AWS Lambda"
8497

8598
# retrieve your AWS Account ID
8699
echo "🔑 Retrieve your AWS Account ID"
87-
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
100+
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
101+
export AWS_ACCOUNT_ID
88102

89103
# Check if the role already exists
90104
echo "🔍 Check if a Lambda execution IAM role already exists"
@@ -97,8 +111,8 @@ aws lambda create-function \
97111
--zip-file fileb://.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/MyLambda/MyLambda.zip \
98112
--runtime provided.al2 \
99113
--handler provided \
100-
--architectures $(uname -m) \
101-
--role arn:aws:iam::${AWS_ACCOUNT_ID}:role/lambda_basic_execution > /dev/null 2>&1
114+
--architectures "$(uname -m)" \
115+
--role arn:aws:iam::"${AWS_ACCOUNT_ID}":role/lambda_basic_execution > /dev/null 2>&1
102116

103117
echo "⏰ Waiting 10 secs for the Lambda function to be ready..."
104118
sleep 10

Examples/_MyFirstFunction/create_iam_role.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftAWSLambdaRuntime open source project
5+
##
6+
## Copyright (c) 2017-2024 Apple Inc. and the SwiftAWSLambdaRuntime project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
116
#
217
# Create an IAM role for the Lambda function
318
#
@@ -23,14 +38,14 @@ EOF
2338
# Create the IAM role
2439
echo "🔐 Create the IAM role for the Lambda function"
2540
aws iam create-role \
26-
--role-name $role_name \
41+
--role-name "${role_name}" \
2742
--assume-role-policy-document file://trust-policy.json > /dev/null 2>&1
2843

2944
# Attach basic permissions to the role
3045
# The AWSLambdaBasicExecutionRole policy grants permissions to write logs to CloudWatch Logs
3146
echo "🔒 Attach basic permissions to the role"
3247
aws iam attach-role-policy \
33-
--role-name $role_name \
48+
--role-name "${role_name}" \
3449
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole > /dev/null 2>&1
3550

3651
echo "⏰ Waiting 10 secs for IAM role to propagate..."

0 commit comments

Comments
 (0)