Skip to content

Commit 34b7048

Browse files
authored
Migrate to commons usage (#54)
* Changing action.yaml to use commons * Typo * Fixing input name * Adding default for aws_no_cert * Fix input path * Adding debug to clone-ansible * Fixing dir * Removing breaking line * Changing inventory.yaml relative to fixed location * Adding a default in action * Adding missing Ansible toggle * Adding extra-vars-file option * Testing with extra vars * Testing * Debug * Debug2 * Chaging var in action * Changing way of env_bitops * Cleanup action * Escaping chars * Removing some ' * debug * Escaping vars * -e * Escaping chars * Testing short var * Echoing ST2 packs to extra_env_file * Typo * Fixing path * Debug * Changing paths * Masking secrets * Fixing file * Movin pass * Code cleanup * Adjusting vars * Changing commons version * Var name fix * Removing wait for inventory * Changing to a testing branch * Bumping inventory.yaml details * Cleanup script * Bumping output limit * Cosmetics * move to main * Update action.yaml to use commons tagged version * Update action.yaml * Update action.yaml * Update action.yaml * Update action.yaml * Update action.yaml * Bump action and readme * Update README.md
1 parent d46c435 commit 34b7048

39 files changed

+208
-1755
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ local.sh
2121

2222
# Github Action
2323
00_create_*
24-
00_generated_*
24+
00_generated_*
25+
26+
.vscode

README.md

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
1-
# Github Action: Deploy StackStorm (βeta)
1+
# Github Action: Deploy StackStorm
22

33
[![LICENSE](https://img.shields.io/badge/license-MIT-green)](LICENSE.md)
44
[![Latest Release](https://img.shields.io/github/v/release/bitovi/github-actions-deploy-stackstorm)](https://github.com/bitovi/github-actions-deploy-stackstorm/releases)
55
![GitHub closed issues](https://img.shields.io/github/issues-closed/bitovi/github-actions-deploy-stackstorm)
66
![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/bitovi/github-actions-deploy-stackstorm)
7-
[![Join our Slack](https://img.shields.io/badge/slack-join%20chat-611f69.svg?logo=slack)](https://www.bitovi.com/community/slack?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7+
[![Discrod Community](https://img.shields.io/discord/1007137664606150746?logo=discord&label=Discord)](https://discord.gg/J7ejFsZnJ4Z)
88

99

10-
GitHub action to deploy [StackStorm](https://stackstorm.com/) to an AWS VM (EC2) with [Terraform](operations/deployment/terraform/modules) and [Ansible](https://github.com/stackstorm/ansible-st2).
10+
## You are here
11+
This action deploys a Stackstorm instance to an AWS VM (EC2) with [Terraform](operations/deployment/terraform/modules) and [Ansible](https://github.com/stackstorm/ansible-st2).
12+
13+
If you would like to deploy a backend app/service, check out our other actions:
14+
| Action | Purpose |
15+
| ------ | ------- |
16+
| [Deploy Docker to EC2](https://github.com/bitovi/github-actions-deploy-docker-to-ec2) | Deploys a repo with a Dockerized application to a virtual machine (EC2) on AWS |
17+
| [Deploy static site to AWS (S3/CDN/R53)](https://github.com/marketplace/actions/deploy-static-site-to-aws-s3-cdn-r53) | Hosts a static site in AWS S3 with CloudFront |
18+
19+
# Need help or have questions?
20+
This project is supported by [Bitovi, A DevOps consultancy](https://www.bitovi.com/services/devops-consulting).
21+
22+
You can **get help or ask questions** on our:
23+
24+
- [Discord Community](https://discord.gg/J7ejFsZnJ4Z)
25+
26+
Or, you can hire us for training, consulting, or development. [Set up a free consultation](https://www.bitovi.com/services/devops-consulting).
1127

1228
## Prerequisites
1329
- An [AWS account](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/) and [Access Keys](https://docs.aws.amazon.com/powershell/latest/userguide/pstools-appendix-sign-up.html)
@@ -17,7 +33,6 @@ GitHub action to deploy [StackStorm](https://stackstorm.com/) to an AWS VM (EC2)
1733
- `ST2_AUTH_USERNAME`
1834
- `ST2_AUTH_PASSWORD`
1935

20-
2136
## Example usage
2237

2338
Create a Github Action Workflow `.github/workflow/deploy-st2.yaml` with the following to build on push to the `main` branch.
@@ -38,7 +53,7 @@ jobs:
3853
name: Deploy StackStorm
3954
# NOTE: we recommend pinning to the latest numeric version
4055
# See: https://github.com/bitovi/github-actions-deploy-stackstorm/releases
41-
uses: bitovi/github-actions-deploy-stackstorm@main
56+
uses: bitovi/github-actions-deploy-stackstorm@v0.4.0
4257
with:
4358
aws_default_region: us-east-1
4459
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID}}
@@ -53,7 +68,7 @@ This will create the following resources in AWS:
5368
- Route53 records
5469
- A load balancer
5570
- Security groups (ports `80`, `443`, `22`)
56-
- Optionally, a VPC with subnets (see `aws_create_vpc`)
71+
- Optionally, use an existing or define a new VPC with subnets (see `aws_create_vpc`)
5772

5873
> For more details about what is created, see [operations/deployment/terraform/modules](operations/deployment/terraform/modules/)
5974

@@ -71,12 +86,26 @@ The following inputs can be used as `steps.with` keys:
7186
| `aws_secret_access_key` | string | | AWS secret access key (Required) |
7287
| `aws_session_token` | string | | AWS session token, if you're using temporary credentials |
7388
| `aws_default_region` | string | `us-east-1` | AWS default region (Required) |
74-
| `aws_ec2_instance_type` | string | `t2.medium` | The AWS EC2 instance type. |
75-
| `aws_ec2_instance_profile` | string | | [The AWS IAM instance profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html) to use for the EC2 instance. Use if you want to pass an AWS role with specific permissions granted to the instance |
7689
| `aws_resource_identifier` | string | `${org}-${repo}-${branch}` | Auto-generated by default so it's unique for org/repo/branch. Set to override with custom naming the unique AWS resource identifier for the deployment. |
77-
| `aws_create_vpc` | bool | `false` | Whether an AWS VPC should be created in the action. Otherwise, the existing default VPC will be used. |
7890
| `aws_extra_tags` | json | | A list of additional tags that will be included on created resources. Example: `{"key1": "value1", "key2": "value2"}`. |
91+
| **EC2 Instance config** |
92+
| `aws_ec2_instance_type` | string | `t2.medium` | The AWS EC2 instance type. |
93+
| `aws_ec2_instance_profile` | string | | [The AWS IAM instance profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html) to use for the EC2 instance. Use if you want to pass an AWS role with specific permissions granted to the instance |
94+
| `aws_ec2_create_keypair_sm` | bool | | Generates and manage a secret manager entry that contains the public and private keys created for the ec2 instance. |
95+
| `aws_ec2_instance_vol_size` | string | 8 | Define the volume size (in GiB) for the root volume on the AWS Instance. |
96+
| `aws_ec2_additional_tags` | string | | Add additional tags to the terraform [default tags](https://www.hashicorp.com/blog/default-tags-in-the-terraform-aws-provider), any tags put here will be added to ec2 provisioned resources.|
7997
| `infrastructure_only` | bool | `false` | Set to true to provision infrastructure (with Terraform) but skip the app deployment (with ansible) |
98+
| **StackStorm configuration** |
99+
| `st2_auth_username` | string | | Username used by StackStorm standalone authentication. Set as a secret in GH Actions. |
100+
| `st2_auth_password` | string | | Password used by StackStorm standalone authentication. Set as a secret in GH Actions. |
101+
| `st2_packs` | string |`"st2"` | Comma separated list of packs to install. If you modify this option, be sure to also include `st2` in the list. |
102+
| `st2_ansible_extra_vars_file` | string | | Relative path from project root to Ansible vars file. If you'd like to adjust more advanced configuration; st2 version, st2.conf, RBAC, chatops, auth, etc. See https://github.com/stackStorm/ansible-st2#variables for the full list of settings. The Ansible vars will take higher precedence over the GHA inputs. |
103+
| **Stack Management** |
104+
| `tf_stack_destroy` | bool | `false` | Set to `true` to Destroy the created AWS infrastructure for this instance |
105+
| `tf_state_file_name` | string | `tf-state-aws` | Change this to be anything you want to. Carefull to be consistent here. A missing file could trigger recreation, or stepping over destruction of non-defined objects. |
106+
| `tf_state_file_name_append` | string | | Appends a string to the tf-state-file name. Setting this to `unique` will generate `tf-state-aws-unique`. (Can co-exist with `tf_state_file_name`) |
107+
| `tf_state_bucket` | string | `${aws_resource_identifier}-tf-state` | AWS S3 bucket to use for Terraform state. By default, a new deployment will be created for each unique branch. Hardcode if you want to keep a shared resource state between the several branches. |
108+
| `tf_state_bucket_destroy` | bool | `false` | Force purge and deletion of `tf_state_bucket` defined. Any file contained there will be destroyed. `tf_stack_destroy` must also be `true` |
80109
| **Domain and certificates configuration** |
81110
| `aws_domain_name` | string | | Define the root domain name for the application. e.g. bitovi.com'. If empty, ELB URL will be provided. |
82111
| `aws_sub_domain` | string | `${org}-${repo}-${branch}` | Define the sub-domain part of the URL. |
@@ -85,16 +114,16 @@ The following inputs can be used as `steps.with` keys:
85114
| `aws_create_root_cert` | bool | `false`| Generates and manage the root certificate for the application to be used in the ELB. **See note**.|
86115
| `aws_create_sub_cert` | bool | `false` | Generates and manage the sub-domain certificate for the application to be used in the ELB. **See note**.|
87116
| `aws_no_cert` | bool | `false` | Set this to true if you want not to use a certificate in the ELB. **See note**. |
88-
| **Teraform configuration** |
89-
| `tf_state_bucket` | string | `${org}-${repo}-${branch}-tf-state` | AWS S3 bucket to use for Terraform state. By default, a new deployment will be created for each unique branch. Hardcode if you want to keep a shared resource state between the several branches. |
90-
| **StackStorm configuration** |
91-
| `st2_auth_username` | string | | Username used by StackStorm standalone authentication. Set as a secret in GH Actions. |
92-
| `st2_auth_password` | string | | Password used by StackStorm standalone authentication. Set as a secret in GH Actions. |
93-
| `st2_packs` | string |`"st2"` | Comma separated list of packs to install. If you modify this option, be sure to also include `st2` in the list. |
94-
| `st2_ansible_extra_vars_file` | string | | Relative path from project root to Ansible vars file. If you'd like to adjust more advanced configuration; st2 version, st2.conf, RBAC, chatops, auth, etc. See https://github.com/stackStorm/ansible-st2#variables for the full list of settings. The Ansible vars will take higher precedence over the GHA inputs. |
95-
| **Cleanup** |
96-
| `tf_stack_destroy` | bool | `false` | Set to `true` to Destroy the created AWS infrastructure for this instance |
97-
| `tf_state_bucket_destroy` | bool | `false` | Force purge and deletion of `tf_state_bucket` defined. Any file contained there will be destroyed. `tf_stack_destroy` must also be `true` |
117+
| **VPC configuration** |
118+
| `aws_vpc_create` | bool | | Define if a VPC should be created |
119+
| `aws_vpc_name` | string | | Define a name for the VPC. If none defined, will use `VPC for ${aws_resource_identifier}`. |
120+
| `aws_vpc_cidr_block` | string | `10.0.0.0/16` | Define Base CIDR block which is divided into subnet CIDR blocks. |
121+
| `aws_vpc_public_subnets` | string | `10.10.110.0/24` | Comma separated list of public subnets. |
122+
| `aws_vpc_private_subnets` | string | | Comma separated list of private subnets. If no input, no private subnet will be created. |
123+
| `aws_vpc_availability_zones` | string | `aws_default_region+<random>` | Comma separated list of availability zones. If a list is defined, the first zone will be the one used for the EC2 instance. |
124+
| `aws_vpc_id` | string | | AWS VPC ID to use with existing VPCs. Accepts `vpc-###` values. |
125+
| `aws_vpc_subnet_id` | string | | AWS VPC Subnet ID. If none provided, will pick one. (Ideal when there's only one) |
126+
| `aws_vpc_additional_tags` | string | | Add additional tags to the VPC resources. |
98127

99128
### Note about AWS resource identifiers
100129
Most resources will contain the tag `GITHUB_ORG-GITHUB_REPO-GITHUB_BRANCH` to make them unique. Because some AWS resources have a length limit, we shorten identifiers to a `60` characters max string.
@@ -156,7 +185,7 @@ jobs:
156185
steps:
157186
- id: deploy-st2-advanced
158187
name: Deploy StackStorm with extra Ansible vars
159-
uses: bitovi/github-actions-deploy-stackstorm@main
188+
uses: bitovi/github-actions-deploy-stackstorm@v0.4.0
160189
with:
161190
aws_default_region: us-east-1
162191
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID}}
@@ -176,7 +205,7 @@ We encourage to keep your infrastructure codified!
176205
You can pass additional `BITOPS_` ENV variables to adjust the deployment behavior.
177206
```yaml
178207
- name: Deploy StackStorm to AWS (dry-run)
179-
uses: bitovi/github-actions-deploy-stackstorm@main
208+
uses: bitovi/github-actions-deploy-stackstorm@v0.4.0
180209
env:
181210
# Extra BitOps configuration:
182211
BITOPS_LOGGING_LEVEL: INFO
@@ -196,15 +225,7 @@ You can pass additional `BITOPS_` ENV variables to adjust the deployment behavio
196225
In this example, we instruct BitOps to run a `terraform plan` instead of `terraform apply` and to run Ansible in `--check` mode, additionally, we set the BitOps container logging level to `DEBUG`.
197226

198227
## Future
199-
In the future, this action may support more cloud providers (via [BitOps Plugins](https://bitops.sh/plugins/) like [AWS](https://github.com/bitops-plugins/aws)) such as:
200-
- [Google Cloud Platform](https://cloud.google.com/gcp)
201-
- [Microsoft Azure](https://azure.microsoft.com/en-us/)
202-
- [Nutanix](https://www.nutanix.com/)
203-
- [Open Stack](https://www.openstack.org/)
204-
- [VMWare](https://www.vmware.com/)
205-
- etc
206-
207-
This action may also support multiple deployment types such as:
228+
In the future, this action may support multiple deployment types such as:
208229
- [Kubernetes](https://github.com/StackStorm/stackstorm-k8s)
209230
- Multi-VM
210231

0 commit comments

Comments
 (0)