Skip to content

S3 bucket name must be updated before deploying #97

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

Merged
merged 5 commits into from
Jun 7, 2020
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
6 changes: 5 additions & 1 deletion Examples/LambdaFunctions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ Steps to deploy this sample to AWS Lambda using the AWS CLI:
./scripts/deploy.sh
```

Note: This script assumes you have AWS CLI installed and credentials setup in `~/.aws/credentials`.
Notes:
- This script assumes you have AWS CLI installed and credentials setup in `~/.aws/credentials`.
- The default lambda function name is `SwiftSample`. You can specify a different one updating `lambda_name` in `deploy.sh`
- Update `s3_bucket=swift-lambda-test` in `deploy.sh` before running (AWS S3 buckets require a unique global name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is helpful. we may want to point out both the bucket and function names in the deploy script

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion the S3 bucket selection should be in the script, not just in the README.md.
The issue is that the S3 name must be globally unique so a predefined one works only for the owner of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Andrea-Scuderi, that is a valid point, but I think outside of the scope of this PR.

I think there are two topics to cover:

  1. Help new users, unfamiliar with Lambda, get started quickly with these examples. This was the goal for this PR. Maybe documentation within the script would be helpful too.

  2. Make deployment script(s) more robust, so it's easy to deploy one or more lambdas within a package with one command. This could be a separate PR, maybe even a separate repo (would be nice to have swift cli tool included to do this).

Focusing on the first point, I'll update the PR to indicate how to update both bucket and lambda function name before deploying.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to track any future ideas as illustrated ^^ in GitHub issues so we dont loose track of them

- Both lambda function and S3 bucket must exist before deploying for the first time.

### Deployment instructions using AWS SAM (Serverless Application Model)

Expand Down
4 changes: 4 additions & 0 deletions Examples/LambdaFunctions/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@

set -eu

# Lambda Function name (must exist in AWS Lambda)
lambda_name=SwiftSample

# S3 bucket name to upload zip file (must exist in AWS S3)
s3_bucket=swift-lambda-test

executables=( $(swift package dump-package | sed -e 's|: null|: ""|g' | jq '.products[] | (select(.type.executable)) | .name' | sed -e 's|"||g') )

if [[ ${#executables[@]} = 0 ]]; then
Expand Down