New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fargate-helper

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fargate-helper - npm Package Compare versions

Comparing version

to
0.4.5

lib/EC2Manager.js

0

index.js

@@ -0,0 +0,0 @@ #!/usr/bin/env node

@@ -0,0 +0,0 @@ const AWS = require("aws-sdk");

@@ -0,0 +0,0 @@ const SecretsManager = require("./SecretsManager");

5

lib/ECSManager.js

@@ -15,4 +15,4 @@ const AWS = require("aws-sdk");

cluster: Config.str("cluster"),
desiredCount: Config.int("desiredCounted", 1),
launchType: "FARGATE",
desiredCount: Config.int("desiredCount", 1),
launchType: Config.str("launchType"),
loadBalancers: [

@@ -86,2 +86,3 @@ {

taskDefinitionString = Util.substitute(taskDefinitionString, "image", Config.str("image"));
taskDefinitionString = Util.substitute(taskDefinitionString, "launchType", Config.str("launchType"));
taskDefinitionString = Util.substitute(taskDefinitionString, "logGroup", Config.str("logGroup", "fargate-cluster"));

@@ -88,0 +89,0 @@ taskDefinitionString = Util.substitute(taskDefinitionString, "memory", Config.str("memory"));

@@ -0,0 +0,0 @@ const AWS = require("aws-sdk");

const AWS = require("aws-sdk");
const Config = require("./Config.js");
const ECSManager = require("./ECSManager");
const EC2Manager = require("./EC2Manager");
const ELBManager = require("./ELBManager");

@@ -11,5 +12,9 @@ const CloudWatchManager = require("./CloudWatchManager");

static async run() {
AWS.config.update({ region: process.env.AWS_DEFAULT_REGION });
AWS.config.update({
region: process.env.AWS_DEFAULT_REGION
});
const options = { env: {} };
const options = {
env: {}
};
const action = process.argv[2];

@@ -33,4 +38,3 @@ for (let i = 3; i < process.argv.length; i += 2) {

}
const keyValue = line.trim().split("=");
const keyValue = line.trim().split(/=(.+)/);
const envKey = keyValue[0];

@@ -61,2 +65,4 @@ options.env[envKey] = keyValue[1];

return FargateHelper._schedule();
} else if (action === "ec2-instance") {
return FargateHelper._instance();
}

@@ -199,4 +205,13 @@ }

}
// Creates a new EC2 instance
static async _instance() {
// Create a new EC2 instance
console.log("EC2 Instance 1) Launching");
const instance = await EC2Manager.launchInstance();
console.log(JSON.stringify(instance, null, 2));
return
}
}
module.exports = FargateHelper;
module.exports = FargateHelper;

@@ -0,0 +0,0 @@ const AWS = require("aws-sdk");

@@ -0,0 +0,0 @@ class Util {

{
"name": "fargate-helper",
"version": "0.4.4",
"version": "0.4.5",
"description": "Helper scripts for deploying to Fargate",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -11,3 +11,4 @@ # How It Works

* update: Updates a service
* schedule: Create a scheduled task
* schedule: Creates a scheduled task
* ec2-instance: Creates an EC2 instance to use inside an ECS cluster

@@ -28,13 +29,2 @@ The syntax for the script is:

```
Example (creates or updates the scheduled task `my-scheduled-task` with the specified parameters):
```
fargate schedule \
--command "node lib/service.js" \
--cpu 1024 \
--env key=value \
--image bespoken/my-service-image \
--memory 2048 \
--cron "cron(0 12 * * ? *)" \
--name my-scheduled-task
```

@@ -66,2 +56,5 @@ For `create`, the script will:

For `ec2-instance`, the script will:
1) Launch a new EC2 instance tied to the specified EC2 Cluster
More information here:

@@ -85,3 +78,3 @@ https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduled_tasks_cli_tutorial.html

## Required Parameters
## Required Parameters (fargate service)
These parameters must be manually configured for the deployment to run:

@@ -100,2 +93,3 @@ * command: The command to run for the Docker service

* hostname: The fully-qualified hostname for the service - i.e., "service.bespoken.tools". When the default <SERVICE>.bespoken.io is not appropriate.
* launchType: The launchType of the service and requiredCompatibilities of the task definition. Values can be EC2 | FARGATE. Defaults to FARGATE.
* logGroup: The CloudWatch Log Group to use - defaults to `fargate-cluster`

@@ -105,2 +99,5 @@ * 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

### EC2 Considerations
By changing the `launchType` parameter to 'EC2' we can leverage all the current functionality and deploy to EC2, provided that the EC2 instances already exist on the target ECS cluster. We can create EC2 instances by using the `ec2-instance`.
## Command-Line Configuration

@@ -135,3 +132,4 @@ For the command-line, parameters are passed in with the format:

* albArn: The ARN for the ALB being used for this account
* cluster: The fargate cluster name
* cluster: The short name or full Amazon Resource Name (ARN) of the cluster on which to run your service.
* clusterArn: Used for scheduled tasks, can only be an ARN. **TODO:** Unify with the cluster param.
* dockerHubSecretArn: The name of the AWS Secret that stores our docker credentials

@@ -144,2 +142,8 @@ * listenerArn: The ARN for the ALB listener being used for this account

For ec2, the following values were added:
* IAMInstanceProfile: An instance profile is a container for an IAM role that you can use to pass role information to an EC2 instance when the instance starts. Defaults to "ecsInstanceRole".
* imageId: An Amazon Machine Image (AMI) provides the information required to launch an instance. Defaults to "ami-09edd32d9b0990d49", which is a Linux machine with the ECS agent installed.
* instanceType: Instance types comprise varying combinations of CPU, memory, storage, and networking capacity. Default is "t3.micro".
* keyPair: Name of the key pair used for doing SSH to the EC2 instance. Defaults to "ecs-ec2-cluster".
# Runtime Configuration

@@ -166,5 +170,5 @@ Environment variables can also be set inside the running container.

# Examples
## Examples
## Delete
### Delete
```

@@ -174,2 +178,24 @@ fargate delete --name my-service

### Create a scheduled task
```
fargate schedule \
--command "node lib/service.js" \
--cpu 1024 \
--env key=value \
--image bespoken/my-service-image \
--memory 2048 \
--cron "cron(0 12 * * ? *)" \
--name my-scheduled-task
```
### Create an EC2 instance
```
fargate ec2-instance \
--cluster fargate-helper \
--IAMInstanceProfile ecsInstanceRole \
--imageId ami-09edd32d9b0990d49 \
--instanceType t3.micro \
--keyPair ecs-ec2-cluster \
```
## Real-world

@@ -176,0 +202,0 @@ To see a sample project that uses this, check out the Utterance Tester:

@@ -37,5 +37,5 @@ {

"requiresCompatibilities": [
"FARGATE"
"${launchType}"
],
"taskRoleArn": "${roleArn}"
}

@@ -0,0 +0,0 @@ **TODO**

Sorry, the diff of this file is not supported yet