Skip to content

Commit

Permalink
Commons improvements (#1)
Browse files Browse the repository at this point in the history
* Update action.yaml

* Update action.yaml

* Update action.yaml

* Bump README.md

* Update README.md

* Fixing README
  • Loading branch information
LeoDiazL authored Nov 9, 2023
1 parent 8df0c2c commit 5b8b3a4
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 19 deletions.
89 changes: 71 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,96 @@ You can **get help or ask questions** on our:

Or, you can hire us for training, consulting, or development. [Set up a free consultation](https://www.bitovi.com/services/devops-consulting).

# Basic Use

# Example usage
For basic usage, create `.github/workflows/deploy.yaml` with the following to build on push.

## Basic Use - One container only
One container, exposed in the port 8000, mapped to container port 80. Will return the load balancer URL.
```yaml
name: Deploy ECS
name: Deploy ECS Cluster
on:
push:
branches: [ main ]
jobs:
deploy-ecs:
runs-on: ubuntu-latest
- name: Create Nginx example
uses: bitovi/[email protected]
id: ecs
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_default_region: us-east-1

#tf_stack_destroy: true # This is to destroy the stack
tf_state_bucket_destroy: true # Will only destroy the bucket if tf_stack_destroy is true

aws_ecs_task_cpu: 256
aws_ecs_task_mem: 512
aws_ecs_app_image: nginx:latest
aws_ecs_assign_public_ip: true

aws_ecs_container_port: 80
aws_ecs_lb_port: 8000
```
## Advanced Use - 3 Containers, different paths
The example below will create a cluster with 3 tasks, with cloudwatch enabled and DNS usage.
You'll end up with the following URL -> https://subdomain.your-domain.com
Mapping the 2nd and 3rd container to https://subdomain.your-domain.com/apache/ and https://subdomain.your-domain.com/unit/ (Usefull for FE/BE and something extra)
(Keep in mind the apache container will print a 404 as that path doesn't exist in it.)
```yaml
name: Deploy ECS Cluster Advanced
on:
push:
branches: [ main ]
jobs:
deploy-ecs:
runs-on: ubuntu-latest
environment:
name: full-stack
url: ${{ steps.ecs.outputs.ecs_dns_record }}
steps:
- name: Create an ECS-Fargate deploy
uses: bitovi/[email protected]
- name: Create Nginx example
uses: bitovi/[email protected]
id: ecs
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID_SANDBOX }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SANDBOX }}
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_default_region: us-east-1

aws_ecs_enable: true
aws_ecs_task_cpu: 1024,2048
aws_ecs_task_mem: 2048,6144
aws_ecs_app_image: some.dkr.ecr.us-east-1.amazonaws.com/repo:fe,some.dkr.ecr.us-east-1.amazonaws.com/repo:be
#tf_stack_destroy: true
tf_state_bucket_destroy: true

# Each comma separated value is for each consecutive container
aws_ecs_task_cpu: 256,512,512
aws_ecs_task_mem: 512,1024,1024
aws_ecs_app_image: nginx:latest,httpd:latest,public.ecr.aws/nginx/unit
aws_ecs_assign_public_ip: true
aws_ecs_container_port: 3000,3001

aws_ecs_container_port: 80,80,80
aws_ecs_lb_port: 8000,8001,8082
aws_ecs_lb_redirect_enable: true
aws_ecs_lb_container_path: 'api'
aws_ecs_cloudwatch_enable: true
aws_ecs_cloudwatch_retention_days: 7
aws_ecs_lb_container_path: 'apache,unit' # Fisrt container will be the URL root path

aws_ecs_additional_tags: '{\"key\":\"value\",\"key2\":\"value2\"}'

aws_ecs_cloudwatch_enable: true
aws_ecs_cloudwatch_lg_name: nginx-leo
aws_ecs_cloudwatch_skip_destroy: false
aws_ecs_cloudwatch_retention_days: 1

aws_r53_enable: true
aws_r53_domain_name: bitovi.com
aws_r53_sub_domain_name: ecs-test
aws_r53_domain_name: your-domain.com
aws_r53_sub_domain_name: sub-domain.com
aws_r53_enable_cert: true
```
## Extra advanced usage
If you know what you are doing, you can play around defining a JSON file for the Task definition. That allows you more granular control of it.
# Inputs
The following inputs can be used as `step.with` keys
Expand Down Expand Up @@ -226,4 +279,4 @@ The scripts and documentation in this project are released under the [MIT Licens
[Bitovi](https://www.bitovi.com/) is a proud supporter of Open Source software.
# We want to hear from you.
Come chat with us about open source in our Bitovi community [Discord](https://discord.gg/J7ejFsZnJ4Z!
Come chat with us about open source in our Bitovi community [Discord](https://discord.gg/J7ejFsZnJ4Z)!
11 changes: 10 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,21 @@ inputs:
description: 'A JSON object of additional tags that will be included on created resources. Example: `{"key1": "value1", "key2": "value2"}`'
required: false

outputs:
# ECS
ecs_load_balancer_dns:
description: "ECS ALB DNS Record"
value: ${{ steps.deploy.outputs.ecs_load_balancer_dns }}
ecs_dns_record:
description: "ECS DNS URL"
value: ${{ steps.deploy.outputs.ecs_dns_record }}

runs:
using: 'composite'
steps:
- name: Deploy with BitOps
id: deploy
uses: bitovi/[email protected].7
uses: bitovi/[email protected].9
with:
# Current repo vars
gh_action_repo: ${{ github.action_path }}
Expand Down

0 comments on commit 5b8b3a4

Please sign in to comment.