Does every policy installed must come from a package? (express-gateway) - express-gateway

I read the documentation and I wonder if the only way to install policies (under plugin) is from package?
I know that I can create a local package and install it as a file but I wonder if I missed a way to just create my specific policy (for example, under 'policies' folder, next to 'config') and install it at the gateway, without any NPM intervention.
So is there a way or I missed a point?

you can definitely load your plugins and policy directly without having to pass through NPM.
All you need to do is specify the package file location in the plugin definition, in system.config.yml file.
You can see an example of such technique here
I hope that clarifies!

Related

When does a MWAA environment update it's requirements, and is it an automatic or manual process?

Pretty much title.
Supose I edit the requirements.txt file to add a new package, or to change package versions. When will the environment apply these changes, and what manual steps do I have to take (if any) to make that happen?
The aws documentation on the procedure states that one must simply go through the 'Edit' settings, but in the case I didn't even change the filename is it necessary?
In the MWAA settings, you will change the version of requirements.txt (the name of the file will remain the same). You choose the latest version of the file and save it. As soon as you save it, the MWAA instance will restart automatically to update and install the packages mentioned in the "requirements.txt" file.

Is there any GCP managed service is available to store python whl files and use them in requirements.txt

I have one enterprise application built using python flask. There are several individual modules are there which I converted then to whl files and referring them in other modules inside requirements.txt.
Is there any GCP service available to store these whl files other than GCS so that I can directly refer them inside requirements.txt
There is an alpha feature in artifact registry that creates a private pipy for you. You should be able to store your wheel file and to get them, with pip, when you need it (and if you have the permission for).
I'm not a python expert and I didn't tested it, but the promise is here. I will be happy if you provide me feedbacks on this feature!

How to set up development environment for AWS Lambda?

I wish to implement the answer that is outlined here: https://stackoverflow.com/a/50397276/1980516
However, I find that I keep running into Unable to import module 'index' at exactly this line:
const _archiver = require('archiver');
So, I'm guessing that I cannot do this via the online console. Instead, I probably have to create a deployment package.
How do I go about this? I apparently need AWS CLI, Node.js, npm and I'm new to all of it. In the Amazon docs I can't find a practical list of how to set up my local development environment.
What tools do I install, which versions and in what order exactly?
Edit: Windows :)
My guess is that you need to npm install archiver and package the node_modules dependencies along with your index.js (handler file for your lambda entry point). You can zip up and deploy/upload it to your lambda.
Also have a look at https://github.com/serverless/serverless framework, that will do these type of things easier.
Have a look at AWS SAM, the Serverless Application Model. It provides a local development setup for things like Lambda functions and API Gateway endpoints, and a way to easily package and deploy things. The exact steps you need are:
Create an AWS account and an IAM user with admin privileges
Install node.js
Install the AWS CLI (and configure it with aws configure)
Install SAM CLI and Docker (the local instances run in docker containers)
Initialize a new SAM project with sam init --runtime nodejs (or other runtime version if need)
Run through the quickstart to get an idea of how to define a SAM template, build a SAM app, and deploy.
If you don't want to use the framework or local development environment and just want to create the source bundle, there are docs. The gist is:
Install nodejs (e.g. using homebrew or an installer)
npm install the modules you need
Zip up your code including the node_modules folder
Upload the zip via the AWS Console

Building a node module for aws lambda

I'm trying to use the Sharp library in AWS Lambda but it requires the module be compiled for the lambda environment. The instructions say to create an ec2 instance and compile it on there - but I noticed that there are a few tools to help with that but they are all at least a year old with no maintenance. Is there a package that comes with Serverless, or something that's considered the standard way now?
I've found these but they are all at least a year old since a commit
https://github.com/node-hocus-pocus/thaumaturgy
https://github.com/Max-Kolodezniy/aws-lambda-build
https://github.com/tomdale/lambda-packager
Maybe there is a directory somewhere where I can just download a precompiled Sharp library for AWS lambda?
I made it work using sharp-0.17.3-aws-linux-x64-node-6.10.1.tar.gz tarball, that was created on AWS EC2 instance running Nodejs 6.10.1. The tarball contains node_modules/ directory with sharp system binaries (libvips library) specific to the Lambda execution environment.
Project structure
To avoid conflicts between my local node_modules/ (Nodejs 7.5 on Mac) and node_modules/ inside the tarball (Nodejs 6.10 on Linux), I'm creating my Lambda service under a subdirectory.
Project structure looks as follows:
node_modules/
service/
node_modules/ <= sharp-0.17.3-aws-linux-x64-node-6.10.1.tar.gz
utils/
handler.js
package.json <= engines: node 6.10.1
serverless.yml
src/
jasmine.json
package.json
Most of the dependencies I need are for development and testing purpose. These are maintained inside root package.json file (also includes sharp, but compiled for my Nodejs 7.5 environment, offering to test image manipulations locally).
My service/handler.js and service/utils/ contains ES6 compatible source code with Lambda function handler – it is transpiled from src/ directory.
If I need other dependencies for production (besides sharp), I install them to services/package.json using --prefix option. But not aws-lambda, neither aws-sdk – they are globally installed within Lambda, meaning no need to include them in deployable .zip file.
npm i -S lodash --prefix services/
It ensures installation of lodash version compatible with Lambda environment, because service/package.json defines Nodejs version to rely on:
{
"private": true,
"engines": { "node" : "6.10.1" },
"dependencies": {
...
}
}
However, there's a nuance — other production dependencies doesn't have to be environment dependent. If so, they won't work, because you install them from your local machine, which isn't equal to Lambda's one.
Lambda function deployment
Since Lambda requires .zip archive, I compress contents of my service/ directory. And my Lambda functions works. Everything is ES6 compatible, sharp has Lambda environment binaries and my other production dependency versions correlates with Nodejs 6.10.1.
Additionally, I'd suggest to use Serverless ⚡️ (I use it too). It dramatically simplifies Lambda functions development and deployment.
Nik's answer definitely helped me to get to a working solution! One thing that I would add is that the people behind serverless-sharp-image updated their package so the tarball works with node v6.10 now so I don't see a reason to have two different node environments referenced. I do everything in v6.10.
https://github.com/adieuadieu/serverless-sharp-image/tree/master/lib
Had similar problem and managed to install binaries for Linux x64 platform by
npm install --arch=x64 --platform=linux --target=8.10.0 sharp
Then just upload Lambda as usual and it works just fine.
Above works on Mac as well as windows and details are in documentation at http://sharp.pixelplumbing.com/en/stable/install/#aws-lambda
For anyone stumbling upon this post now. I've accomplished this by copying my package.json file into an AWS Cloud9 IDE and simply running npm install. From there, just download the node_modules/ folder.

c:\ınetpub\wwwroot\mysite\website\sitecore\shell\override is invalid

I install sitecore 6.4 but after login i take this error
The directory name c:\ınetpub\wwwroot\mysite\website\sitecore\shell\override is invalid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
I uninstall sitecore and install again but result same. Someone can help me pls.
By default this folder is not created when you create a fresh install of Sitecore. Have had this many times, and essentially you must manually create the folder, and also ensure the app pool identity has write permissions to this folder. If you have your Visual Studio solution open, also close and reopen as the change will not be picked up if you are running webdev.
I ran into this problem as well. My problem was i had my project committed on Git and I was trying to pull files from GIT to my local to setup the project.
The problem with GIT is that it doesnt commit empty folders so \website\sitecore\shell\override was not committed to the repo, and when i pulled, the folder didnt existed on my local as well.
Creating the folder manually resolved the issue.
As mentioned by #pranav-shah, git doesn't support adding empty folders so if you are using git and you are doing clean builds it is likely you are running into this problem.
To get around it you can just create an empty file in the override folder. I recommend following the suggestion in this answer and call it .keep
Whenever I run into this, it's the app pool identity missing write permissions to the folder. Often applies to following folders too, under the sitecore directory:
* shell\controls\debug
* shell\applications\debug
(I think there's one more but too tired to remember right now).
If you run the installer it normally takes care of these issues. Also be sure to read the manual installation steps in the Sitecore documentation, available on the Sitecore Developer Network.