Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

awsass

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awsass - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

72

awsass.js

@@ -1,27 +0,30 @@

const GetOpt = require("node-getopt");
const { program } = require("commander");
const AWS = require("aws-sdk");
const Lib = require(__dirname + "/src/lib.js");
const parsedArgs = GetOpt.create([
["h", "help", "shows help"],
["p", "profile=PROFILE", "aws profile"],
["r", "region=REGION", "aws region"],
["", "ecs-create-new-revision-for-container", "create a new ecs revision, updating a container"],
["", "ecr-login", "login to ecr"],
["", "ecr-tag-push", "tag and push to ecr"],
["", "ecr-ecs-push-new-revision", "tags image, pushes, and creates a new revision"],
//["", "lambda-kill-warm-instances", "kill warm lambda instances by doing a silent redeployment"],
["", "task-definition=TASKDEFINITION", "ecs task definition"],
["", "container-name=CONTAINERNAME", "container name"],
["", "image-name=IMAGENAME", "image name"],
["", "local-image-name=IMAGENAME", "local-image name"],
["", "lambda-function=LAMBDAFUNCTION", "lambda function name"]
]).bindHelp().parseSystem();
program
.option("-p, --profile <profile>", "aws profile")
.option("-r, --region <region>", "aws region")
.option("--ecs-create-new-revision-for-container", "create a new ecs revision, updating a container")
.option("--ecr-login", "login to ecr")
.option("--ecr-tag-push", "tag and push to ecr")
.option("--ecr-ecs-push-new-revision", "tags image, pushes, and creates a new revision")
.option("--edge-lambda-kill-warm-instances", "kill warm edge lambda instances by doing a silent redeployment")
.option("--task-definition <task-definition>", "ecs task definition")
.option("--container-name <container-name>", "container name")
.option("--image-name <image-name>", "image name")
.option("--local-image-name <local-image-name>", "local image name")
.option("--lambda-function <lambda-function>", "lambda function")
.option("--lambda-edge-type <lambda-edge-type>", "lambda edge type")
.option("--cloudfront-id <cloudfront-id>", "cloudfront id");
if (parsedArgs.options.region)
AWS.config.update({region: parsedArgs.options.region});
program.parse(process.argv);
const options = program.opts();
if (parsedArgs.options.profile)
AWS.config.update({credentials: new AWS.SharedIniFileCredentials({profile: parsedArgs.options.profile})});
if (options.region)
AWS.config.update({region: options.region});
if (options.profile)
AWS.config.update({credentials: new AWS.SharedIniFileCredentials({profile: options.profile})});
const resultFunc = function (err, data) {

@@ -32,20 +35,21 @@ console.log(err ? err : data);

if (parsedArgs.options["ecs-create-new-revision-for-container"])
Lib.ecsCreateNewRevisionForContainer(parsedArgs.options["task-definition"], parsedArgs.options["container-name"], parsedArgs.options["image-name"], resultFunc);
if (options["ecsCreateNewRevisionForContainer"])
Lib.ecsCreateNewRevisionForContainer(options["taskDefinition"], options["containerName"], options["imageName"], resultFunc);
if (parsedArgs.options["ecr-login"])
if (options["ecrLogin"])
Lib.ecrLogin(resultFunc);
if (parsedArgs.options["ecr-tag-push"])
Lib.ecrTagPush(parsedArgs.options["local-image-name"], parsedArgs.options["image-name"], resultFunc);
if (options["ecrTagPush"])
Lib.ecrTagPush(options["localImageName"], options["imageName"], resultFunc);
if (parsedArgs.options["ecr-ecs-push-new-revision"])
Lib.ecrEcsPushNewRevision(parsedArgs.options["task-definition"], parsedArgs.options["container-name"], parsedArgs.options["local-image-name"], parsedArgs.options["image-name"], resultFunc);
/*
if (parsedArgs.options["lambda-kill-warm-instances"])
Lib.lambdaKillWarmInstances(parsedArgs.options["lambda-function"], resultFunc);
*/
// TODO: lambda version based routing
if (options["ecrEcsPushNewRevision"])
Lib.ecrEcsPushNewRevision(options["taskDefinition"], options["containerName"], options["localImageName"], options["imageName"], resultFunc);
if (options["edgeLambdaKillWarmInstances"])
Lib.edgeLambdaKillWarmInstances(options["lambdaFunction"], options["cloudfrontId"], options["lambdaEdgeType"], resultFunc);
// TODO: lambda version based routing deploy
// TODO: run temporarily on fargate
// TODO: lambda flush cache
// TODO: run task on aws/fargate
// TODO: lambda flush cache normal lambda
// TODO: run task on aws/fargate
{
"name": "awsass",
"description": "AWSASS is an assistant to AWS, mostly for running better scripts.",
"version": "0.0.6",
"version": "0.0.7",
"author": "Jsonize",

@@ -17,3 +17,3 @@ "repository": "https://github.com/jsonize/awsass",

"aws-sdk": "",
"node-getopt": "git+https://git@github.com/tuxpoldo/node-getopt"
"commander": "^8.3.0"
},

@@ -20,0 +20,0 @@ "files": [

@@ -95,10 +95,52 @@ const AWS = require("aws-sdk");

});
}/*,
},
lambdaKillWarmInstances: function (lambdaFunction, callback) {
edgeLambdaKillWarmInstances: function (lambdaFunction, cloudfrontId, lambdaEdgeType, callback) {
const lambda = new AWS.Lambda({apiVersion: '2015-03-31'});
const cloudfront = new AWS.CloudFront({apiVersion: '2020-05-31'});
lambda.updateFunctionConfiguration({
FunctionName: lambdaFunction,
Description: "AWSASS:" + (new Date()).getTime()
}, function (err) {
if (err) {
callback(err);
return;
}
setTimeout(function () {
lambda.publishVersion({
FunctionName: lambdaFunction
}, function (err, publishResult) {
if (err) {
callback(err);
return;
}
cloudfront.getDistributionConfig({
Id: cloudfrontId
}, function (err, distributionConfig) {
if (err) {
callback(err);
return;
}
const lambdaItems = distributionConfig.DistributionConfig.DefaultCacheBehavior.LambdaFunctionAssociations.Items;
let lambdaItem = null;
lambdaItems.forEach(function (candidate) {
if (candidate.EventType === lambdaEdgeType)
lambdaItem = candidate;
});
let s = lambdaItem.LambdaFunctionARN.split(":");
s[s.length - 1] = publishResult.Version;
lambdaItem.LambdaFunctionARN = s.join(":");
cloudfront.updateDistribution({
Id: cloudfrontId,
IfMatch: distributionConfig.ETag,
DistributionConfig: distributionConfig.DistributionConfig
}, callback);
});
});
}, 5000);
});
}
}*/
};
module.exports = Module;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc