fargate-helper
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -22,3 +22,8 @@ const AWS = require("aws-sdk"); | ||
} | ||
const hostname = Config.str("serviceName") + ".bespoken.io"; | ||
let hostname = Config.str("serviceName") + ".bespoken.io"; | ||
if (Config.has("hostname")) { | ||
hostname = Config.str("hostname"); | ||
} | ||
var params = { | ||
@@ -25,0 +30,0 @@ Actions: [ |
{ | ||
"name": "fargate-helper", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Helper scripts for deploying to Fargate", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -43,2 +43,13 @@ # How It Works | ||
For `service`, the script will: | ||
1) Create the service if it does not exist | ||
1A) Update the service if it already exists | ||
For `schedule`, the script will (TO BE IMPLEMENTED): | ||
1) Register a task definition | ||
2) Create a Cloud Watch Event with cron configuration | ||
3) Associate the CloudWatch Event with the task definition | ||
More information here: | ||
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduled_tasks_cli_tutorial.html | ||
# Setup | ||
@@ -53,4 +64,4 @@ Install the package: | ||
# Deployment Configuration | ||
The values for configuring the service will come from three places: | ||
# Build-Time Configuration | ||
The parameters for configuring the service come from three places: | ||
1) Command-line | ||
@@ -60,7 +71,25 @@ 2) Environment variables | ||
## Required Parameters | ||
These parameters must be manually configured for the deployment to run: | ||
* command: The command to run for the Docker service | ||
* containerPort: The port the service should run on | ||
* cpu: The CPU allocated for the service, where 1024 is equal to a full CPU | ||
* image: The DockerHub image to use for this service | ||
* memory: The amount of memory allocated for the service | ||
* name: The name of the service | ||
## Other Important Parameters | ||
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 | ||
* hostname: The fully-qualified hostname for the service - i.e., "service.bespoken.tools". When the default <SERVICE>.bespoken.io is not appropriate. | ||
* logGroup: The CloudWatch Log Group to use - defaults to `fargate-cluster` | ||
* 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 | ||
* taskDefinition: A file to use as the baseline for the taskDefinition - if not specified, just uses the default that is included in the code | ||
## Command-Line Configuration | ||
For the command-line, values are passed in with the format: | ||
For the command-line, parameters are passed in with the format: | ||
`--name value` | ||
For values with spaces, they should be passed in as so: | ||
For parameters with spaces, they should be passed in as so: | ||
`--name "my value"` | ||
@@ -72,7 +101,17 @@ | ||
## Environment Variables | ||
Values can also be set via environment variable | ||
Parameters can also be set via environment variable. If the parameter is not specified on the command-line, but is found in the environment, that will be used. | ||
For example: | ||
``` | ||
export cpu=1024 | ||
fargate create --name serviceName | ||
``` | ||
In this case, the `cpu` will be set to `1024` for the service. | ||
## AWS Secret Configuration | ||
We store certain key default values, such as DockerHub credentials, in defaults in our AWS Secrets. | ||
We store certain key default parameters, such as DockerHub credentials, in defaults in the AWS Secret Manager. | ||
These are values that are generally universal for the account - these should not need to changed or overridden. | ||
They can be found under the name "fargate-helper". Values we store there are: | ||
@@ -89,22 +128,3 @@ * accountId: The AWS account ID | ||
The AWS secret values are meant to be one universal defaults for the account | ||
# Required Values | ||
These values must be manually configured for the deployment to run: | ||
* command: The command to run for the Docker service | ||
* containerPort: The port the service should run on | ||
* cpu: The CPU allocated for the service, where 1024 is equal to a full CPU | ||
* image: The DockerHub image to use for this service | ||
* memory: The amount of memory allocated for the service | ||
* name: The name of the service | ||
# Other Important Values | ||
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` | ||
* 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 | ||
* taskDefinition: A file to use as the baseline for the taskDefinition - if not specified, just uses the default that is included in the code | ||
# Container Configuration | ||
# Runtime Configuration | ||
Environment variables can also be set inside the running container. | ||
@@ -115,7 +135,9 @@ | ||
Environment variables in the container can also be set by specifying on the command-line: | ||
`fargate --env KEY=VALUE` | ||
`fargate create --env KEY=VALUE` | ||
This will set the environment variable `key` to `value` inside the container. | ||
# ELB Configuration | ||
Additionally, the `--envFile` parameter can be used - this takes as an argument a relative path to a file in key value form. All values in this file will be set in the container (via the Environment section on the TaskDefinition). | ||
# Load Balancer Configuration | ||
By default, we create a target group with rules on our ELB when first creating the service. | ||
@@ -129,3 +151,10 @@ | ||
# Example | ||
# Examples | ||
## Delete | ||
``` | ||
fargate delete --name my-service | ||
``` | ||
## Real-world | ||
To see a sample project that uses this, check out the Utterance Tester: | ||
@@ -132,0 +161,0 @@ https://github.com/bespoken/UtteranceTester |
@@ -7,3 +7,3 @@ **TODO** | ||
- [X] Add delete service - remove rules, target group, and service | ||
- [ ] Add scheduler | ||
- [ ] Add scheduler https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduled_tasks_cli_tutorial.html | ||
@@ -10,0 +10,0 @@ **Maybe** |
28954
539
158