From 6b22df02c0a20a8bd9877511fc00cd0d5058d6a8 Mon Sep 17 00:00:00 2001 From: Andrea Scuderi Date: Thu, 26 Sep 2019 19:55:12 +0100 Subject: [PATCH] FIX make create_lambda --- Examples/HelloWorld/Package.resolved | 16 ++++++++++++++++ Makefile | 11 +++-------- 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 Examples/HelloWorld/Package.resolved diff --git a/Examples/HelloWorld/Package.resolved b/Examples/HelloWorld/Package.resolved new file mode 100644 index 0000000..ca993a9 --- /dev/null +++ b/Examples/HelloWorld/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "LambdaSwiftSprinter", + "repositoryURL": "https://github.com/swift-sprinter/aws-lambda-swift-sprinter-core", + "state": { + "branch": null, + "revision": "eeec63084ff8bd00daf3234f398b0a862c19a90e", + "version": "1.0.0-alpha.1" + } + } + ] + }, + "version": 1 +} diff --git a/Makefile b/Makefile index 9c0a8c1..470526b 100644 --- a/Makefile +++ b/Makefile @@ -201,16 +201,11 @@ upload_lambda_layer: cat $(LAMBDA_BUILD_PATH)/$(SWIFT_LAMBDA_LIBRARY)-arn.txt create_role: - $(eval IAM_ROLE_ARN := $(shell aws iam list-roles --query "Roles[? RoleName == '$(IAM_ROLE_NAME)'].Arn" --profile $(AWS_PROFILE) --output text)) -ifeq ($(IAM_ROLE_ARN),"") - aws iam create-role --role-name $(IAM_ROLE_NAME) --description "Allows Lambda functions to call AWS services on your behalf." --assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["sts:AssumeRole"],"Principal":{"Service":["lambda.amazonaws.com"]}}]}' --profile $(AWS_PROFILE) - aws iam attach-role-policy --role-name $(IAM_ROLE_NAME) --policy-arn "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" --profile $(AWS_PROFILE) + aws iam create-role --role-name $(IAM_ROLE_NAME) --description "Allows Lambda functions to call AWS services on your behalf." --assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["sts:AssumeRole"],"Principal":{"Service":["lambda.amazonaws.com"]}}]}' --profile $(AWS_PROFILE) || true + aws iam attach-role-policy --role-name $(IAM_ROLE_NAME) --policy-arn "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" --profile $(AWS_PROFILE) || true $(eval IAM_ROLE_ARN := $(shell aws iam list-roles --query "Roles[? RoleName == '$(IAM_ROLE_NAME)'].Arn" --output text --profile $(AWS_PROFILE))) -else - $(info "The role $(IAM_ROLE_ARN) was already present") -endif -create_lambda: create_role +create_lambda: create_role package_lambda $(eval LAMBDA_LAYER_ARN := $(shell cat $(LAMBDA_BUILD_PATH)/$(SWIFT_LAMBDA_LIBRARY)-arn.txt)) $(info "$(LAMBDA_LAYER_ARN)") 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)