Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 57a924c

Browse files
author
CodingNagger
committed
Apply PR comments
1 parent 1ad5f2e commit 57a924c

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

LambdaDeployerPolicyExample.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@
5353
{
5454
"Sid": "VisualEditor4",
5555
"Effect": "Allow",
56-
"Action": [
57-
"s3:CreateBucket",
58-
"s3:ListBucket"
59-
],
60-
"Resource": "arn:aws:s3:::*"
56+
"Action": "s3:*",
57+
"Resource": "arn:aws:s3:::aws-lambda-swift-sprinter*"
6158
}
6259
]
6360
}

Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ package_layer: create_build_directory clean_layer
145145
cp -t $(SHARED_LIBS_FOLDER)/lib $(SHARED_LIBRARIES)
146146
zip -r $(LAYER_BUILD_PATH)/$(LAYER_ZIP) bootstrap $(SHARED_LIBS_FOLDER)
147147

148-
upload_build_to_s3: create_lambda_s3_key create_s3_bucket_if_not_existing
148+
upload_build_to_s3: create_lambda_s3_key
149149
aws s3 sync --acl public-read "$(LAMBDA_BUILD_PATH)" s3://$(AWS_BUCKET)/$(LAMBDA_S3_UPLOAD_PATH) --profile $(AWS_PROFILE)
150150

151151
create_layer_s3_key:
152152
$(eval LAYER_S3_UPLOAD_PATH := layers/$(SWIFT_LAMBDA_LIBRARY))
153153

154-
upload_lambda_layer_with_s3: create_s3_bucket_if_not_existing create_layer_s3_key
154+
upload_lambda_layer_with_s3: create_layer_s3_key
155155
aws s3 sync --acl public-read "$(LAYER_BUILD_PATH)" s3://$(AWS_BUCKET)/$(LAYER_S3_UPLOAD_PATH) --profile $(AWS_PROFILE)
156156
aws lambda publish-layer-version --layer-name $(SWIFT_LAMBDA_LIBRARY) --description "AWS Custom Runtime Swift Shared Libraries with NIO" --content "S3Bucket=$(AWS_BUCKET),S3Key=$(LAYER_S3_UPLOAD_PATH)/$(LAYER_ZIP)" --output text --query LayerVersionArn --profile $(AWS_PROFILE) > $(TMP_BUILD_PATH)/$(SWIFT_LAMBDA_LIBRARY)-arn.txt
157157
cat $(TMP_BUILD_PATH)/$(SWIFT_LAMBDA_LIBRARY)-arn.txt
@@ -168,15 +168,15 @@ create_role:
168168
create_lambda: create_role package_lambda
169169
$(eval LAMBDA_LAYER_ARN := $(shell cat $(TMP_BUILD_PATH)/$(SWIFT_LAMBDA_LIBRARY)-arn.txt))
170170
$(info "$(LAMBDA_LAYER_ARN)")
171-
aws lambda create-function --function-name $(LAMBDA_FUNCTION_NAME) --runtime provided --handler $(LAMBDA_HANDLER) --role "$(IAM_ROLE_ARN)" --zip-file fileb://$(LAMBDA_BUILD_PATH)/$(LAMBDA_ZIP) --layers $(LAMBDA_LAYER_ARN) --profile $(AWS_PROFILE)
171+
aws lambda create-function --function-name $(LAMBDA_FUNCTION_NAME) --runtime provided --handler $(LAMBDA_HANDLER) --role "$(IAM_ROLE_ARN)" --zip-file fileb://$(LAMBDA_BUILD_PATH)/$(LAMBDA_ZIP) --layers "$(LAMBDA_LAYER_ARN)" --profile $(AWS_PROFILE)
172172

173173
create_lambda_s3_key:
174174
$(eval LAMBDA_S3_UPLOAD_PATH := lambdas/$(LAMBDA_FUNCTION_NAME)/$(DATETIME))
175175

176176
create_lambda_with_s3: create_role package_lambda upload_build_to_s3
177177
$(eval LAMBDA_LAYER_ARN := $(shell cat $(TMP_BUILD_PATH)/$(SWIFT_LAMBDA_LIBRARY)-arn.txt))
178178
$(info "$(LAMBDA_LAYER_ARN)")
179-
aws lambda create-function --function-name $(LAMBDA_FUNCTION_NAME) --runtime provided --handler $(LAMBDA_HANDLER) --role "$(IAM_ROLE_ARN)" --code "S3Bucket=$(AWS_BUCKET),S3Key=$(LAMBDA_S3_UPLOAD_PATH)/$(LAMBDA_ZIP)" --layers $(LAMBDA_LAYER_ARN) --profile $(AWS_PROFILE)
179+
aws lambda create-function --function-name $(LAMBDA_FUNCTION_NAME) --runtime provided --handler $(LAMBDA_HANDLER) --role "$(IAM_ROLE_ARN)" --code "S3Bucket=$(AWS_BUCKET),S3Key=$(LAMBDA_S3_UPLOAD_PATH)/$(LAMBDA_ZIP)" --layers "$(LAMBDA_LAYER_ARN)"--profile $(AWS_PROFILE)
180180

181181
update_lambda: package_lambda
182182
aws lambda update-function-code --function-name $(LAMBDA_FUNCTION_NAME) --zip-file fileb://$(LAMBDA_BUILD_PATH)/$(LAMBDA_ZIP) --profile $(AWS_PROFILE)
@@ -187,8 +187,8 @@ update_lambda_with_s3: package_lambda upload_build_to_s3
187187
invoke_lambda:
188188
aws lambda invoke --function-name $(LAMBDA_FUNCTION_NAME) --profile $(AWS_PROFILE) --payload "fileb://$(SWIFT_PROJECT_PATH)/event.json" $(TMP_BUILD_PATH)/outfile && echo "\nResult:" && cat $(TMP_BUILD_PATH)/outfile && echo "\n"
189189

190-
create_s3_bucket_if_not_existing:
191-
aws s3 ls "s3://$(AWS_BUCKET)" || aws s3 mb "s3://$(AWS_BUCKET)"
190+
create_s3_bucket:
191+
aws s3 mb "s3://$(AWS_BUCKET)" --profile $(AWS_PROFILE)
192192

193193
#quick commands - no clean
194194
quick_build_lambda: build_lambda create_build_directory

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ The lambda is created with the following parameters:
267267
- HelloWorld.helloWorld
268268
- role: `"$(IAM_ROLE_ARN)"`
269269
- a new role will be created with the name: `lambda_sprinter_basic_execution`
270-
- zip-file: $(LAMBDA_BUILD_PATH)/$(LAMBDA_ZIP) --> `./build/lambda.zip`
270+
- zip-file: $(LAMBDA_BUILD_PATH)/$(LAMBDA_ZIP) --> `./build/lambda/lambda.zip`
271271
- layers: `$(LAMBDA_LAYER_ARN)`
272272
- it will use the arn contained in the file generated by the `make upload_lambda_layer`
273273

@@ -313,6 +313,14 @@ make update_lambda
313313
make update_lambda_with_s3
314314
```
315315

316+
#### 6) Create bucket
317+
318+
You may create a bucket if you wish to use the S3 options to upload lambdas and layers using the command below:
319+
320+
```console
321+
make create_s3_bucket
322+
```
323+
316324
# Contributions
317325

318326
Contributions are more than welcome! Follow [this guide](https://github.com/swift-sprinter/aws-lambda-swift-sprinter/blob/master/CONTRIBUTING.md) to contribute.

0 commit comments

Comments
 (0)