diff --git a/builds/delete-serverless-service-build-pack/Jenkinsfile b/builds/delete-serverless-service-build-pack/Jenkinsfile index e0a4f88e6d..65c6e03ca9 100644 --- a/builds/delete-serverless-service-build-pack/Jenkinsfile +++ b/builds/delete-serverless-service-build-pack/Jenkinsfile @@ -62,7 +62,7 @@ node { } - auth_token = setCredentials() + auth_token = getAuthToken() stage("Initialization") { @@ -847,9 +847,9 @@ def cleanupS3BucketPolicy(stage, assetInfo) { /** Reset credentials */ def resetCredentials(credsId) { - echo "resetting AWS credentials" + echo "resetting AWS credentials" sh "aws configure set profile.${credsId}.aws_access_key_id XXXXXXXXXXXXXXXXXXXXXXXXXX" - sh "aws configure set profile.${credsId}.aws_secret_access_key XXXXXXXXXXXXXXXXXXXXXX" + sh "aws configure set profile.${credsId}.aws_secret_access_key XXXXXXXXXXXXXXXXXXXXXX" } @NonCPS def updateBucketPolicy(policy_json, bucketName){ @@ -1091,32 +1091,28 @@ def removeEventResources() { * For getting token to access catalog APIs. * Must be a service account which has access to all services */ -def setCredentials() { - def url = g_base_url + '/jazz/login' +def getAuthToken() { withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: g_svc_admin_cred_ID, passwordVariable: 'PWD', usernameVariable: 'UNAME']]) { - echo "user name is $UNAME" - def login_json = [] - login_json = [ + def loginUrl = g_base_url + "/jazz/login" + def login_json = [ 'username': UNAME, 'password': PWD ] - def tokenJson_token = null def payload = JsonOutput.toJson(login_json) try { def token = sh(script: "curl --silent -X POST -k -v \ -H \"Content-Type: application/json\" \ - $url \ - -d \'${payload}\'", returnStdout: true).trim() + $loginUrl \ + -d \'${payload}\'", returnStdout:true).trim() def tokenJson = jsonParse(token) - tokenJson_token = tokenJson.data.token - - return tokenJson_token + return tokenJson.data.token } catch (e) { - echo "Failed to fetch authentication details." + error "Failed while getting auth token for user: $UNAME, error: " + e.getMessage() } } + } /** @@ -1160,7 +1156,7 @@ def send_status_email(build_status) { try { def sendMail = sh(script: "curl -X POST \ ${g_base_url}/jazz/email \ - -k -v -H \"Authorization: $g_login_token\" \ + -k -v -H \"Authorization: $auth_token\" \ -H \"Content-Type: application/json\" \ -d \'${body}\'", returnStdout: true).trim() def responseJSON = parseJsonMap(sendMail) diff --git a/builds/jazz-build-module/service-configuration-data-loader.groovy b/builds/jazz-build-module/service-configuration-data-loader.groovy index a35f275569..272474acfe 100644 --- a/builds/jazz-build-module/service-configuration-data-loader.groovy +++ b/builds/jazz-build-module/service-configuration-data-loader.groovy @@ -532,7 +532,7 @@ def setEventSourceMapping(eventSourceArn, config) { ).trim() echo "$event_source_list" if (event_source_list == "[]") { - sh "aws lambda create-event-source-mapping --event-source-arn ${eventSourceArn} --function-name arn:aws:lambda:$region:$role_id:function:$function_name --starting-position LATEST --region $region" + sh "aws lambda create-event-source-mapping --event-source-arn ${eventSourceArn} --function-name arn:aws:lambda:$region:$role_id:function:$function_name --enabled --starting-position LATEST --region $region" } } diff --git a/builds/jenkins-build-pack-api/Jenkinsfile b/builds/jenkins-build-pack-api/Jenkinsfile index 5082f97dad..3c81d99968 100644 --- a/builds/jenkins-build-pack-api/Jenkinsfile +++ b/builds/jenkins-build-pack-api/Jenkinsfile @@ -271,7 +271,7 @@ node() { endpointUrl = "https://${apiHostName}/${current_environment}/${environment_logical_id}/${config['domain']}/${config['service']}" } - def apiArns = getAPIGatewayResourceARNs(aws_api_id, environment_logical_id) + def apiArns = getAPIGatewayResourceARNs(aws_api_id, current_environment) if(apiArns) { for (arn in apiArns) { events.sendCompletedEvent('CREATE_ASSET', null, utilModule.generateAssetMap("aws", arn, "apigateway", config), environment_logical_id); @@ -480,17 +480,31 @@ def buildLambda(String runtime, String repo_name) { } else if (runtime.indexOf("java") > -1) { sh "mvn package" } else if (runtime.indexOf("python") > -1) { - // install requirements.txt in library folder, these python modules - // will be a part of deployment package - sh "pip install -r requirements.txt -t library" - - // create virtual environment and install dev-requirements - sh """ - pip install virtualenv - virtualenv venv - . venv/bin/activate - pip install pytest - """ + // install requirements.txt in library folder, these python modules will be a part of deployment package + sh "rm -rf library" + sh "mkdir library" + sh "touch library/__init__.py" + if (runtime == 'python3.6') { + //Installing dependencies + sh "pip3 install -r requirements.txt -t library" + // create virtual environment and install pytest + sh """ + python3 -m venv virtualenv + . virtualenv/bin/activate + pip3 install pytest + pytest test + """ + } else { + //Installing dependencies + sh "pip install -r requirements.txt -t library" + // create virtual environment and install pytest + sh """ + pip install virtualenv + virtualenv venv + . venv/bin/activate + pip install pytest + """ + } } else if (runtime.indexOf("go") > -1 ) { // Installing dependencies using dep ensure // golang build scripts @@ -503,7 +517,6 @@ def buildLambda(String runtime, String repo_name) { } } - /** Generate the swagger file specific to each environment */ @@ -586,7 +599,7 @@ def validateDeploymentConfigurations(def prop) { error "Wrong configuration. Value for Key 'providerRuntime' is missing in the configuration" } else { - def validRuntimes = ["nodejs4.3", "nodejs6.10", "nodejs8.10", "python2.7", "java8", "go1.x"] + def validRuntimes = ["nodejs4.3", "nodejs6.10", "nodejs8.10", "python2.7", "python3.6", "java8", "go1.x"] def flag = false for (int i = 0; i < validRuntimes.size(); i++) { if (_runtime == validRuntimes[i]) { diff --git a/builds/jenkins-build-pack-lambda/Jenkinsfile b/builds/jenkins-build-pack-lambda/Jenkinsfile index 41b7eb57fe..69881479d8 100644 --- a/builds/jenkins-build-pack-lambda/Jenkinsfile +++ b/builds/jenkins-build-pack-lambda/Jenkinsfile @@ -530,18 +530,32 @@ def buildLambda(String runtime, String repo_name) { } else if (runtime.indexOf("java") > -1) { sh "mvn package" } else if (runtime.indexOf("python") > -1) { - // install requirements.txt in library folder, these python modules will be a part of deployment package + // install requirements.txt in library folder, these python modules will be a part of deployment package sh "rm -rf library" sh "mkdir library" - sh "pip install -r requirements.txt -t library" sh "touch library/__init__.py" - // create virtual environment and install pytest - sh """ - pip install virtualenv - virtualenv venv - . venv/bin/activate - pip install pytest - """ + + if (runtime == 'python3.6'){ + // Installing dependencies + sh "pip3 install -r requirements.txt -t library" + // create virtual environment and install pytest + sh """ + python3 -m venv virtualenv + . virtualenv/bin/activate + pip3 install pytest + pytest test + """ + } else { + // Installing dependencies + sh "pip install -r requirements.txt -t library" + // create virtual environment and install pytest + sh """ + pip install virtualenv + virtualenv venv + . venv/bin/activate + pip install pytest + """ + } } else if (runtime.indexOf("go") > -1 ) { // Installing dependencies using dep ensure // golang build scripts @@ -578,7 +592,7 @@ def validateDeploymentConfigurations(def prop) { if (_runtime == "") { error "Wrong configuration. Value for Key 'providerRuntime' is missing in the configuration" } else { - def validRuntimes = ["nodejs4.3", "nodejs6.10", "nodejs8.10", "python2.7", "java8", "go1.x"] + def validRuntimes = ["nodejs4.3", "nodejs6.10", "nodejs8.10", "python2.7", "python3.6", "java8", "go1.x"] def flag = false for (int i = 0; i < validRuntimes.size(); i++) { diff --git a/builds/service-onboarding-build-pack/Jenkinsfile b/builds/service-onboarding-build-pack/Jenkinsfile index 71c7fd278c..19836e772f 100644 --- a/builds/service-onboarding-build-pack/Jenkinsfile +++ b/builds/service-onboarding-build-pack/Jenkinsfile @@ -66,35 +66,34 @@ node { events.sendStartedEvent("VALIDATE_INPUT", 'input validation starts', context_map) if (service_config['type'] == "api" || service_config['type'] == "function" || service_config['type'] == "website") { - if (service_config['runtime'] == "nodejs" || service_config['runtime'] == "python" || service_config['runtime'] == "java" || service_config['runtime'] == "go1.x" || service_config['runtime'] == "n/a") { - + if (service_config['runtime'].startsWith("nodejs") || service_config['runtime'].startsWith("python") || service_config['runtime'].startsWith("java") || service_config['runtime'].startsWith("go") || service_config['runtime'] == "n/a") { switch (service_config['type']) { case "api": - if (service_config['runtime'] == "nodejs") { + if (service_config['runtime'].startsWith("nodejs")) { service_template = "api-template-nodejs" } - else if (service_config['runtime'] == "python") { - service_template = 'api-template-python' + else if (service_config['runtime'].startsWith("python")){ + service_template = 'api-template-python' } - else if (service_config['runtime'] == "java") { + else if (service_config['runtime'].startsWith("java")) { service_template = 'api-template-java' } - else if (service_config['runtime'] == "go1.x") { + else if (service_config['runtime'].startsWith("go")) { service_template = 'api-template-go' } break case "function": - if (service_config['runtime'] == "nodejs") { + if (service_config['runtime'].startsWith("nodejs")) { service_template = "lambda-template-nodejs" } - else if (service_config['runtime'] == "python") { - service_template = 'lambda-template-python' + else if (service_config['runtime'].startsWith("python")){ + service_template = 'lambda-template-python' } - else if (service_config['runtime'] == "java") { + else if (service_config['runtime'].startsWith("java")) { service_template = 'lambda-template-java' } - else if (service_config['runtime'] == "go1.x") { + else if (service_config['runtime'].startsWith("go")) { service_template = 'lambda-template-go' } break @@ -102,15 +101,12 @@ node { case "website": service_template = 'static-website-template' break - } - } else { send_status_email("FAILED") events.sendFailureEvent('VALIDATE_INPUT', "Invalid runtime: ${service_config['runtime']}", context_map) error "Invalid runtime: ${service_config['runtime']}" } - } else { send_status_email("FAILED") events.sendFailureEvent('VALIDATE_INPUT', "Invalid service type", context_map) @@ -282,6 +278,7 @@ node { } } } + /** * For getting token to access catalog APIs. * Must be a service account which has access to all services @@ -291,15 +288,12 @@ def getAuthToken() { withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: g_svc_admin_cred_ID, passwordVariable: 'PWD', usernameVariable: 'UNAME']]) { def loginUrl = g_base_url + "/jazz/login" - def login_json = [] - - login_json = [ + def login_json = [ 'username': UNAME, 'password': PWD ] - def tokenJson_token = null def payload = JsonOutput.toJson(login_json) - + try { def token = sh(script: "curl --silent -X POST -k -v \ -H \"Content-Type: application/json\" \ @@ -307,12 +301,10 @@ def getAuthToken() { -d \'${payload}\'", returnStdout:true).trim() def tokenJson = jsonParse(token) - tokenJson_token = tokenJson.data.token - - return tokenJson_token + return tokenJson.data.token } catch (e) { - error "error occured: " + e.getMessage() + error "Failed while getting auth token for user: $UNAME, error: " + e.getMessage() } } @@ -395,7 +387,7 @@ def send_status_email (build_status) { try { def sendMail = sh(script: "curl -X POST \ ${g_base_url}/jazz/email \ - -k -v -H \"Authorization: $g_login_token\" \ + -k -v -H \"Authorization: $auth_token\" \ -H \"Content-Type: application/json\" \ -d \'${body}\'", returnStdout: true).trim() def responseJSON = parseJson(sendMail) diff --git a/core/jazz_create-serverless-service/index.js b/core/jazz_create-serverless-service/index.js index e588a4bb7c..f7f778634d 100644 --- a/core/jazz_create-serverless-service/index.js +++ b/core/jazz_create-serverless-service/index.js @@ -231,6 +231,11 @@ var getServiceData = (service_creation_data, authToken, configData) => { serviceMetadataObj.require_internal_access = service_creation_data.require_internal_access; } + //Adding providerRuntime key in service catalog + if (service_creation_data.service_type === "api" || service_creation_data.service_type === "function") { + serviceMetadataObj.providerRuntime = service_creation_data.runtime; + } + // Pass the flag to enable authentication on API if (service_creation_data.service_type === "api") { serviceMetadataObj.enable_api_security = service_creation_data.enable_api_security || false; @@ -244,6 +249,8 @@ var getServiceData = (service_creation_data, authToken, configData) => { } } + + // Disabling require_internal_access and enable_api_security when is_public_endpoint is true if (service_creation_data.service_type === "api" && service_creation_data.is_public_endpoint) { serviceMetadataObj.require_internal_access = false; diff --git a/core/jazz_create-serverless-service/swagger/swagger.json b/core/jazz_create-serverless-service/swagger/swagger.json index 727b665b18..bff325521e 100644 --- a/core/jazz_create-serverless-service/swagger/swagger.json +++ b/core/jazz_create-serverless-service/swagger/swagger.json @@ -281,9 +281,10 @@ "type": "string", "description": "The runtime framework for executing your code", "enum": [ - "nodejs", - "java", - "python", + "nodejs8.10", + "java8", + "python2.7", + "python3.6", "go1.x" ] }, @@ -302,7 +303,7 @@ }, "username": { "type": "string", - "description": "Username/NT ID for the service creator. This will be used for the bitbucket access" + "description": "Username of the service creator" }, "slack_channel": { "type": "string", diff --git a/core/jazz_metrics/components/utils.js b/core/jazz_metrics/components/utils.js index c7b12795cf..3ade07fa6e 100644 --- a/core/jazz_metrics/components/utils.js +++ b/core/jazz_metrics/components/utils.js @@ -205,6 +205,7 @@ function updateLambdaAsset(newAssetObj, relativeId, arnString) { } function updateApigatewayAsset(newAssetObj, relativeId, assetEnvironment) { + var parts = relativeId.split("/"); var apiId = parts[0]; @@ -216,10 +217,9 @@ function updateApigatewayAsset(newAssetObj, relativeId, assetEnvironment) { var methodValue = parts[2]; newAssetObj.asset_name.Method = methodValue; - var resourceValue = "/" + parts[3]; - if (parts[4]) { - resourceValue += "/" + parts[4]; - } + // rest of the parts belong to the actual resource + resourceValue = "/" + parts.slice(3, parts.length).join("/") + newAssetObj.asset_name.Resource = resourceValue; return newAssetObj; } diff --git a/core/jazz_services/config/global-config.json b/core/jazz_services/config/global-config.json index 6044334d7a..da4a008cd9 100644 --- a/core/jazz_services/config/global-config.json +++ b/core/jazz_services/config/global-config.json @@ -109,7 +109,7 @@ "active", "inactive" ], - "SERVICE_RUNTIMES": ["nodejs", "python", "java", "c#", "go1.x"], + "SERVICE_RUNTIMES": ["nodejs8.10", "python2.7", "python3.6", "java8", "go1.x"], "TYPE_FIELD_KEY": "type", "SERVICE_INTER_DEPENDENT_FIELDS_MAP": [ { diff --git a/core/jazz_services/test/test.js b/core/jazz_services/test/test.js index e2a155eb2a..4b5b4374cf 100644 --- a/core/jazz_services/test/test.js +++ b/core/jazz_services/test/test.js @@ -68,7 +68,7 @@ describe('platform_services', function() { "domain" : "k!ngd0m", "region" : "mewni", "type" : "api", - "runtime" : "nodejs", + "runtime" : "nodejs8.10", "created_by" : "g10$saryck", "status" : "active" }, diff --git a/core/jazz_ui/protractor.conf.js b/core/jazz_ui/protractor.conf.js index a6c7e752a9..2e1496b127 100644 --- a/core/jazz_ui/protractor.conf.js +++ b/core/jazz_ui/protractor.conf.js @@ -1,7 +1,7 @@ // Protractor configuration file, see link for more information // https://github.com/angular/protractor/blob/master/lib/config.ts -const SpecReporter = require('jasmine-spec-reporter'); +const SpecReporter = require('jasmine-spec-reporter').SpecReporter; var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter'); const JasmineConsoleReporter = require('jasmine-console-reporter'); const reporter = new JasmineConsoleReporter({ diff --git a/core/jazz_ui/src/app/secondary-components/create-service/oss/create-service.component.html b/core/jazz_ui/src/app/secondary-components/create-service/oss/create-service.component.html index ece9717daf..86d2292e01 100644 --- a/core/jazz_ui/src/app/secondary-components/create-service/oss/create-service.component.html +++ b/core/jazz_ui/src/app/secondary-components/create-service/oss/create-service.component.html @@ -74,32 +74,32 @@

- - + +
- - + +
- - + +
-
- - +
+ +
- - + +
diff --git a/core/jazz_ui/src/app/secondary-components/create-service/oss/create-service.component.ts b/core/jazz_ui/src/app/secondary-components/create-service/oss/create-service.component.ts index 2d8a7a12ef..01b511df7e 100644 --- a/core/jazz_ui/src/app/secondary-components/create-service/oss/create-service.component.ts +++ b/core/jazz_ui/src/app/secondary-components/create-service/oss/create-service.component.ts @@ -36,7 +36,7 @@ export class CreateServiceComponent implements OnInit { typeOfPlatform:string = "aws"; disablePlatform = true; selected:string = "Minutes"; - runtime:string = 'nodejs'; + runtime:string = Object.keys(env_oss.envLists)[0]; eventSchedule:string = 'fixedRate'; private slackSelected: boolean = false; private ttlSelected: boolean = false; @@ -91,6 +91,8 @@ export class CreateServiceComponent implements OnInit { invalidServiceName:boolean=false; invalidDomainName:boolean=false; invalidEventName:boolean = false; + runtimeKeys : any; + runtimeObject : any; constructor ( @@ -103,6 +105,8 @@ export class CreateServiceComponent implements OnInit { private authenticationservice: AuthenticationService ) { this.toastmessage = messageservice; + this.runtimeObject = env_oss.envLists; + this.runtimeKeys = Object.keys(this.runtimeObject); } public focusDynamo = new EventEmitter(); @@ -409,7 +413,7 @@ export class CreateServiceComponent implements OnInit { this.rateExpression.type = 'none'; this.rateExpression.duration = "5"; this.eventExpression.type = 'awsEventsNone'; - this.runtime = 'nodejs'; + this.runtime = this.runtimeKeys[0]; } // function to navigate from success or error screen to create service screen diff --git a/core/jazz_ui/src/config/configuration.ts b/core/jazz_ui/src/config/configuration.ts index b372b2a743..8ebf2cafbf 100644 --- a/core/jazz_ui/src/config/configuration.ts +++ b/core/jazz_ui/src/config/configuration.ts @@ -18,19 +18,17 @@ export const CONFIGURATIONS = { }, optional: { - - general: { - ACCESS_MANAGEMENT_PORTAL_URL: '', - e2e: { - EMAIL_ID: '', - USER_NAME: '', - PASSWORD: '', - REG_USER_NAME: '', - REG_PASS_WORD: '', - REG_CODE: '', - APPLN_URL: '' - - } + general: { + ACCESS_MANAGEMENT_PORTAL_URL: '', + e2e: { + EMAIL_ID: '{stack_email}', + USER_NAME: '{stack_username}', + PASSWORD: '{stack_password}', + REG_USER_NAME: '{stack_reg_username}', + REG_PASS_WORD: '{stack_reg_password}', + REG_CODE: '{stack_reg_code}', + APPLN_URL: '{stack_jazz_url}' + } } } }; diff --git a/core/jazz_ui/src/environments/environment.oss.ts b/core/jazz_ui/src/environments/environment.oss.ts index da2c2d929c..da14f06845 100644 --- a/core/jazz_ui/src/environments/environment.oss.ts +++ b/core/jazz_ui/src/environments/environment.oss.ts @@ -6,6 +6,7 @@ export const environment = { envName: "oss", multi_env: {multi_env}, slack_support: {slack_support}, + envLists: {"nodejs8.10": "Nodejs 8.10", "python2.7": "Python 2.7", "python3.6": "Python 3.6", "java8": "Java 8", "go1.x": "Go 1.x"}, serviceTabs: ["{overview}", "{access control}", "{metrics}", "{logs}", "{cost}"], environmentTabs: ["{env_overview}", "{deployments}", "{code quality}", "{metrics}", "{assets}", "{env_logs}"], charachterLimits:{ diff --git a/core/jazz_ui/src/tsconfig.json b/core/jazz_ui/src/tsconfig.json index 867a41b914..96b6a21b13 100644 --- a/core/jazz_ui/src/tsconfig.json +++ b/core/jazz_ui/src/tsconfig.json @@ -11,7 +11,6 @@ "outDir": "../dist/out-tsc", "sourceMap": true, "target": "es5", - "experimentalDecorators": true, "typeRoots": [ "../node_modules/@types" ] diff --git a/misc/wiki/images/security group for scenario 3.png b/misc/wiki/images/security group for scenario 3.png new file mode 100644 index 0000000000..3e44a67c4f Binary files /dev/null and b/misc/wiki/images/security group for scenario 3.png differ diff --git a/templates/api-template-python/README.md b/templates/api-template-python/README.md index b5f41516d5..6c4f2cb454 100644 --- a/templates/api-template-python/README.md +++ b/templates/api-template-python/README.md @@ -26,7 +26,6 @@ # run tests pytest test - ``` #### Python 2.7 (Windows) @@ -48,7 +47,30 @@ # install dev dependencies (includes pytest by default) pip install -r requirements-dev.txt + # run tests + pytest test +``` + +#### Python 3.6 + +```python + + # install requirements in library folder + mkdir library + pip3 install -r requirements.txt -t library + + # create __init__.py in library + touch library/__init__.py + + # create & activate virtual environment + python3 -m venv virtualenv + . virtualenv/bin/activate + + # install dev dependencies (includes pytest by default) + pip install -r requirements-dev.txt + # run tests pytest test ``` + diff --git a/templates/api-template-python/components/logger.py b/templates/api-template-python/components/logger.py index 85094ae5f7..79a18db61d 100644 --- a/templates/api-template-python/components/logger.py +++ b/templates/api-template-python/components/logger.py @@ -62,7 +62,7 @@ def set_context_details(self, label, value): self.config['context_details'] = '' def print_file(self, fil): - print self.get_linenumber() + print (self.get_linenumber()) def get_linenumber(self): """ diff --git a/templates/api-template-python/components/response.py b/templates/api-template-python/components/response.py index 8ce47c3b68..546a4fed32 100644 --- a/templates/api-template-python/components/response.py +++ b/templates/api-template-python/components/response.py @@ -7,7 +7,6 @@ def __init__(self, message, value): self.input = value def get_json(self): - print "#CustomResponse get_json", self.data, self.input obj = { 'data': self.data, 'input': self.input diff --git a/templates/api-template-python/deployment-env.yml b/templates/api-template-python/deployment-env.yml index ed53caf4da..263aefc743 100644 --- a/templates/api-template-python/deployment-env.yml +++ b/templates/api-template-python/deployment-env.yml @@ -1,3 +1,2 @@ -providerRuntime : python2.7 providerMemorySize : 256 providerTimeout : 160 diff --git a/templates/api-template-python/index.py b/templates/api-template-python/index.py index 82c245eb4f..aa599482b9 100644 --- a/templates/api-template-python/index.py +++ b/templates/api-template-python/index.py @@ -14,7 +14,6 @@ def handler(event, context): try: - # initialize logger module logger = Logger(event, context) diff --git a/templates/lambda-template-python/README.md b/templates/lambda-template-python/README.md index e4feed54f5..18a275a1b1 100644 --- a/templates/lambda-template-python/README.md +++ b/templates/lambda-template-python/README.md @@ -26,7 +26,6 @@ # run tests pytest test - ``` #### Python 2.7 (Windows) @@ -52,3 +51,26 @@ pytest test ``` + +#### Python 3.6 + +```python + # install requirements in library folder + mkdir library + pip3 install -r requirements.txt -t library + + # create __init__.py in library, to make Python treat the 'library' as a package + touch library/__init__.py + + # create & activate virtual environment + python3 -m venv virtualenv + . virtualenv/bin/activate + + # install dev dependencies (includes pytest by default) + pip install -r requirements-dev.txt + + # run tests + pytest test +``` + + diff --git a/templates/lambda-template-python/components/logger.py b/templates/lambda-template-python/components/logger.py index cb8b4b5f4a..dd26518a05 100644 --- a/templates/lambda-template-python/components/logger.py +++ b/templates/lambda-template-python/components/logger.py @@ -75,7 +75,7 @@ def set_context_details(self, label, value): self.config['context_details'] = '' def print_file(self, fil): - print self.get_linenumber() + print (self.get_linenumber()) def get_linenumber(self): """ diff --git a/templates/lambda-template-python/deployment-env.yml b/templates/lambda-template-python/deployment-env.yml index ed53caf4da..263aefc743 100644 --- a/templates/lambda-template-python/deployment-env.yml +++ b/templates/lambda-template-python/deployment-env.yml @@ -1,3 +1,2 @@ -providerRuntime : python2.7 providerMemorySize : 256 providerTimeout : 160 diff --git a/templates/lambda-template-python/requirements.txt b/templates/lambda-template-python/requirements.txt index 3cb65d1d9e..663bd1f6a2 100644 --- a/templates/lambda-template-python/requirements.txt +++ b/templates/lambda-template-python/requirements.txt @@ -1 +1 @@ -requests==2.20.0 \ No newline at end of file +requests \ No newline at end of file