Deploy/Publish multiple lambda serverless project in one go - asp.net-core

I have VS solution file and multiple lambda project in it. To deploy/publish my lambda to AWS, I have to go individual project and need to right click and then need to click on "Publish to AWS Lambda". I'm having 10+ lambda project in my solution and need to do this exercise repeatedly.
Is there any solution to deploy all this lambda function on single click?

You should be able to use the AWS PowerShell tools to create a quick script to publish your functions in one run
These two functions Publish and Update should suffice.
Here is a sample script PowerShell script to publish a single lambda
$zipFile = "E:\my-awesome-function\release.zip"
$zipFileItem = Get-Item -Path $zipFile
$fileStream = $zipFileItem.OpenRead()
$memoryStream = New-Object System.IO.MemoryStream
$fileStream.CopyTo($memoryStream)
//Check if function exists
$cmdOutput = Get-LMFunction -FunctionName my-awesome-function;
try{
if($?) {
"Function exists update the code"
Update-LMFunctionCode -FunctionName my-awesome-function -ZipFile $memoryStream -Publish 1
} else {
"Publish new function"
Publish-LMFunction -FunctionName my-awesome-function -FunctionZip $zipFilePath -Handler exports.handler -Role arn:aws:iam::0000000:role/my-extract -Region us-east-1 --Runtime python3.6
}
}
finally {
$fileStream.Close()
}

Related

Can gradle tasks be created that subset the tests in a project?

I am using the gradle tooling api to kick off tests based on receiving a webhook.
I don't see a way to pass parameters to the tooling API. I can run tests with something like:
String workingDir = System.getProperty("user.dir");
ProjectConnection connection = GradleConnector.newConnector()
.forProjectDirectory(new File(workingDir))
.connect();
try {
connection.newBuild().forTasks("test").run();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
connection.close();
}
But I don't see a way to run something like "gradle test --tests=xxx" so I was hoping I could make gradle tasks that were subsets of tests like "gradle dev_tests", "gradle int_tests".
Does anyone know if this is possible and if so, how to do it?
Per the gradle docs, newBuild() functions, conveniently ,as a builder pattern.
You can set several parameters before calling run() on it .
//select tasks to run:
build.forTasks( "test");
//include some build arguments:
build.withArguments("--tests=xxx");
...
build.run();
Source:
https://docs.gradle.org/current/javadoc/org/gradle/tooling/BuildLauncher.html

How to run a script task from a bamboo plugin?

I have a task that runs in a bamboo plugin as a external process. I cannot run any commands like 'echo $PATH' , as it throws the error 'executable not found'. I need to run a script task with the external process to do the above. The requirement is to run a script command from a bamboo plugin in a custom task type plugin.
public ExternalProcess Exec(List<String> pLArg, List<String> pLOpt, String sPwd,
String projectUserId, Map<String, String> variables)
{
TaskContext pContext = GetContext();
List<String> pLCmd = new LinkedList<String>();
pLCmd.add("echo $PATH ");
return Exec(pLCmd, sPwd);
}

PDO Works for all but not in Cron Yii2

I am working on Yii2 advanced app and I have created cron job for my need but same code inside cron works in application but not works in console cron controller.
It gives error like 'Class PDO not found'.
namespace console\controllers;
use yii\console\Controller;
class CronsController extends Controller {
public function actionIndex($id = null) {
if(isset($id)){
$command = \Yii::$app->db->createCommand("INSERT INTO table (user) VALUES (:user)");
foreach($gets as $row){
$command->bindValue(':user', $row['user']);
$command->execute();
}
}
}
first step command run
php -m | grep PDO
To see if it exists,if not exists PDO, you need install PDO extension
http://php.net/manual/en/pdo.installation.php

How to add new Yii webapp arguments?

Using Yii 1.1.14
For those who have customised the webapp (ie, mywebapp) command, have you, or do you know, any way on how to add more parameters to that command?
We already have the git param for example, we wish to add some interactive prompts to the user too, for example: setup the config/main.php files.
Any clue about this subject?
This is a snippet of the run() function:
public function run($args) {
$vcs = false;
if (isset($args[1])) {
if ($args[1] != 'git' && $args[1] != 'hg')
$this->usageError('Unsupported VCS specified. Currently only git and hg supported.');
$vcs = $args[1];
}
// ...
Just like you see, $args[1] must be always the VCS you use.
By logic you need to change/develop the body of run() to be adapted to the new arguments you want.
A probably call would be:
webapp ../test git setconfig
or
webapp ../test git true
The third argument will be available as $args[2].

GitLab new project setup webhook

I have GitLab setup on a server. Every time I create a new project under my user, I have to manually add a Web Hook by navigating to Project -> Settings -> Web Hooks -> Add Web Hook
Since many users will be creating projects on the hosted GitLab it will be difficult to setup Web Hooks for each project individually.
Is there a way, so that when a new project is created, it automatically (as default) sets up a Web Hook as part of the new project?
Any help is much appreciated.
You could probably find a way to automate this via the System Hooks API. Listen for the project_create hook event, then make a call to the project hook endpoint to add the one you want.
It's webhooks all the way down!
I found this script what do all you need:
recive the hook and execute the query insert of web hook
Run with php -S 0.0.0.0:8080
<?php
$allowed_host = "ip_of_your_gitlab_server";
$sql_host = "localhost_or_ip_of_your_mysql_server";
$sql_user = "..";
$sql_password = "..";
$database = "gitlabhq_production";
if ($_SERVER['REMOTE_ADDR'] == $allowed_host) { // ofc you could increase security with some kind of API key or w/e
$sql = mysqli_connect($sql_host, $sql_user, $sql_password, $database);
if (mysqli_connect_errno()) {
exit;
}
$file = fopen("/tmp/sql_error", "a"); // you can use this as debug log too ;)
$input = json_decode(file_get_contents('php://input'), true);
$pid = $input['project_id'];
if ($input['event_name'] == "project_create") {
$url = 'url_of_your_project_hook';
// this creates a project hook, specify it for your needs..
$q = mysqli_query($sql, "INSERT INTO gitlabhq_production.web_hooks (url, project_id) VALUES('$url', '$pid')");
if (!$q) fwrite($file, $sql->error);
} elseif ($input['event_name'] == "project_destroy")
$q = mysqli_query($sql, "DELETE FROM gitlabhq_production.web_hooks WHERE project_id='$pid'");
mysqli_close($sql);
} else {
// redirect?
exit;
}