Skip to content

Commit 5b8b3a4

Browse files
authored
Commons improvements (#1)
* Update action.yaml * Update action.yaml * Update action.yaml * Bump README.md * Update README.md * Fixing README
1 parent 8df0c2c commit 5b8b3a4

File tree

2 files changed

+81
-19
lines changed

2 files changed

+81
-19
lines changed

README.md

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,96 @@ You can **get help or ask questions** on our:
2727

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

30-
# Basic Use
31-
30+
# Example usage
3231
For basic usage, create `.github/workflows/deploy.yaml` with the following to build on push.
32+
33+
## Basic Use - One container only
34+
One container, exposed in the port 8000, mapped to container port 80. Will return the load balancer URL.
3335
```yaml
34-
name: Deploy ECS
36+
name: Deploy ECS Cluster
3537
on:
3638
push:
3739
branches: [ main ]
40+
jobs:
41+
deploy-ecs:
42+
runs-on: ubuntu-latest
43+
- name: Create Nginx example
44+
uses: bitovi/[email protected]
45+
id: ecs
46+
with:
47+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
48+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
49+
aws_default_region: us-east-1
50+
51+
#tf_stack_destroy: true # This is to destroy the stack
52+
tf_state_bucket_destroy: true # Will only destroy the bucket if tf_stack_destroy is true
53+
54+
aws_ecs_task_cpu: 256
55+
aws_ecs_task_mem: 512
56+
aws_ecs_app_image: nginx:latest
57+
aws_ecs_assign_public_ip: true
58+
59+
aws_ecs_container_port: 80
60+
aws_ecs_lb_port: 8000
61+
```
62+
63+
## Advanced Use - 3 Containers, different paths
3864
65+
The example below will create a cluster with 3 tasks, with cloudwatch enabled and DNS usage.
66+
You'll end up with the following URL -> https://subdomain.your-domain.com
67+
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)
68+
(Keep in mind the apache container will print a 404 as that path doesn't exist in it.)
69+
70+
```yaml
71+
name: Deploy ECS Cluster Advanced
72+
on:
73+
push:
74+
branches: [ main ]
3975
jobs:
4076
deploy-ecs:
4177
runs-on: ubuntu-latest
78+
environment:
79+
name: full-stack
80+
url: ${{ steps.ecs.outputs.ecs_dns_record }}
4281
steps:
43-
- name: Create an ECS-Fargate deploy
44-
uses: bitovi/[email protected]
82+
- name: Create Nginx example
83+
uses: bitovi/[email protected]
84+
id: ecs
4585
with:
46-
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID_SANDBOX }}
47-
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SANDBOX }}
86+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
87+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
4888
aws_default_region: us-east-1
4989

50-
aws_ecs_enable: true
51-
aws_ecs_task_cpu: 1024,2048
52-
aws_ecs_task_mem: 2048,6144
53-
aws_ecs_app_image: some.dkr.ecr.us-east-1.amazonaws.com/repo:fe,some.dkr.ecr.us-east-1.amazonaws.com/repo:be
90+
#tf_stack_destroy: true
91+
tf_state_bucket_destroy: true
92+
93+
# Each comma separated value is for each consecutive container
94+
aws_ecs_task_cpu: 256,512,512
95+
aws_ecs_task_mem: 512,1024,1024
96+
aws_ecs_app_image: nginx:latest,httpd:latest,public.ecr.aws/nginx/unit
5497
aws_ecs_assign_public_ip: true
55-
aws_ecs_container_port: 3000,3001
98+
99+
aws_ecs_container_port: 80,80,80
100+
aws_ecs_lb_port: 8000,8001,8082
56101
aws_ecs_lb_redirect_enable: true
57-
aws_ecs_lb_container_path: 'api'
58-
aws_ecs_cloudwatch_enable: true
59-
aws_ecs_cloudwatch_retention_days: 7
102+
aws_ecs_lb_container_path: 'apache,unit' # Fisrt container will be the URL root path
103+
60104
aws_ecs_additional_tags: '{\"key\":\"value\",\"key2\":\"value2\"}'
61105

106+
aws_ecs_cloudwatch_enable: true
107+
aws_ecs_cloudwatch_lg_name: nginx-leo
108+
aws_ecs_cloudwatch_skip_destroy: false
109+
aws_ecs_cloudwatch_retention_days: 1
110+
62111
aws_r53_enable: true
63-
aws_r53_domain_name: bitovi.com
64-
aws_r53_sub_domain_name: ecs-test
112+
aws_r53_domain_name: your-domain.com
113+
aws_r53_sub_domain_name: sub-domain.com
114+
aws_r53_enable_cert: true
65115
```
66116
117+
## Extra advanced usage
118+
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.
119+
67120
# Inputs
68121
69122
The following inputs can be used as `step.with` keys
@@ -226,4 +279,4 @@ The scripts and documentation in this project are released under the [MIT Licens
226279
[Bitovi](https://www.bitovi.com/) is a proud supporter of Open Source software.
227280
228281
# We want to hear from you.
229-
Come chat with us about open source in our Bitovi community [Discord](https://discord.gg/J7ejFsZnJ4Z!
282+
Come chat with us about open source in our Bitovi community [Discord](https://discord.gg/J7ejFsZnJ4Z)!

action.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,21 @@ inputs:
219219
description: 'A JSON object of additional tags that will be included on created resources. Example: `{"key1": "value1", "key2": "value2"}`'
220220
required: false
221221

222+
outputs:
223+
# ECS
224+
ecs_load_balancer_dns:
225+
description: "ECS ALB DNS Record"
226+
value: ${{ steps.deploy.outputs.ecs_load_balancer_dns }}
227+
ecs_dns_record:
228+
description: "ECS DNS URL"
229+
value: ${{ steps.deploy.outputs.ecs_dns_record }}
230+
222231
runs:
223232
using: 'composite'
224233
steps:
225234
- name: Deploy with BitOps
226235
id: deploy
227-
uses: bitovi/[email protected].7
236+
uses: bitovi/[email protected].9
228237
with:
229238
# Current repo vars
230239
gh_action_repo: ${{ github.action_path }}

0 commit comments

Comments
 (0)