fargate-helper
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -5,2 +5,3 @@ const AWS = require("aws-sdk"); | ||
const ELBManager = require("./ELBManager"); | ||
const fs = require("fs"); | ||
const Util = require("./Util"); | ||
@@ -18,8 +19,21 @@ | ||
const key = keyString.slice(2); | ||
console.log(key + ": " + value); | ||
if (key == "env") { | ||
const keyValue = value.split("="); | ||
const envKey = keyValue[0]; | ||
console.log("EnvKey: " + keyValue); | ||
options.env[envKey] = keyValue[1]; | ||
} else if (key == "envFile") { | ||
// Read in an env file | ||
const fileString = fs.readFileSync(value, "UTF-8"); | ||
const lines = fileString.split("\n"); | ||
for (const line of lines) { | ||
if (line.trim().indexOf("=") === -1) { | ||
continue; | ||
} | ||
const keyValue = line.trim().split("="); | ||
const envKey = keyValue[0]; | ||
options.env[envKey] = keyValue[1]; | ||
console.log("ENVFILE " + envKey + ": " + keyValue[1]); | ||
} | ||
} else { | ||
@@ -89,4 +103,6 @@ options[key] = value; | ||
console.log("DELETE 1) Find Target Group for Service"); | ||
// We loop through the events on the service, to find a reference to: | ||
// "(service <NAME>) registered <X> targets in (<TARGET_GROUP_ARN>)" | ||
// "(service <NAME>) registered <X> targets in (target-group <TARGET_GROUP_ARN>)" | ||
// This is the only direct link we've found between ECS and ELB :-) | ||
@@ -108,2 +124,6 @@ const regex = /\(service .*\) registered [0-9]* targets in \(target-group (.*)\)/ | ||
console.log("DELETE 2) Find ELB Rule for Target Group"); | ||
// List the rules for our core listener | ||
// Find the one that refers to our target group from the previous step | ||
const rules = await ELBManager.describeRules(Config.str("listenerArn")); | ||
@@ -125,6 +145,6 @@ let ruleArn; | ||
// If we found the rule delete - this should always happen, but we do as an if statement for safety | ||
if (ruleArn) { | ||
console.log("DELETE 3) Delete Rule"); | ||
await ELBManager.deleteRule(ruleArn); | ||
console.log("RULE DELETED"); | ||
} | ||
@@ -135,3 +155,6 @@ | ||
console.log("DELETE 4) Delete Target Group"); | ||
await ELBManager.deleteTargetGroup(targetGroupArn); | ||
console.log("DELETE 5) Delete Service"); | ||
await ECSManager.deleteService(); | ||
@@ -138,0 +161,0 @@ } |
{ | ||
"name": "fargate-helper", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Helper scripts for deploying to Fargate", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -98,2 +98,4 @@ # How It Works | ||
Though not required, these are useful parameters for more advanced cases: | ||
* env: Key-value pair that is passed to the TaskDefition/container runtime | ||
* envFile: The relative path to a file that contains environment settings - set inside the TaskDefinition/container runtime | ||
* logGroup: The CloudWatch Log Group to use - defaults to `fargate-cluster` | ||
@@ -100,0 +102,0 @@ * passEnv: "true" or "false" - defaults to true. If set to false, will not automatically set pass thru environment variables in the build environment to the container environment |
27532
536
129
15