|
1 | | -# Deploy StackStorm |
| 1 | +# Github Action: Deploy StackStorm (βeta) |
2 | 2 |
|
3 | | -GitHub action to deploy [StackStorm](https://stackstorm.com/) to an AWS VM (EC2). |
| 3 | +[](LICENSE.md) |
| 4 | +[](https://github.com/bitovi/github-actions-deploy-stackstorm/releases) |
| 5 | + |
| 6 | + |
| 7 | +[](https://www.bitovi.com/community/slack?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
| 8 | + |
| 9 | + |
| 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). |
4 | 11 |
|
5 | 12 | ## Prerequisites |
6 | 13 | - 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) |
7 | 14 | - The following secrets should be added to your GitHub actions secrets: |
8 | | - - AWS_ACCESS_KEY_ID |
9 | | - - AWS_SECRET_ACCESS_KEY |
10 | | - - ST2_AUTH_USERNAME |
11 | | - - ST2_AUTH_PASSWORD |
| 15 | + - `AWS_ACCESS_KEY_ID` |
| 16 | + - `AWS_SECRET_ACCESS_KEY` |
| 17 | + - `ST2_AUTH_USERNAME` |
| 18 | + - `ST2_AUTH_PASSWORD` |
12 | 19 |
|
13 | 20 |
|
14 | 21 | ## Example usage |
15 | 22 |
|
16 | | -Create `.github/workflow/deploy.yaml` with the following to build on push. |
| 23 | +Create a Github Action Workflow `.github/workflow/deploy-st2.yaml` with the following to build on push to the `main` branch. |
17 | 24 |
|
18 | 25 | ```yaml |
19 | | -name: Deploy ST2 Single VM with GHA |
| 26 | +# Deploy ST2 Single VM with GHA |
| 27 | +name: CD |
20 | 28 |
|
21 | 29 | on: |
22 | 30 | push: |
23 | 31 | branches: [ main ] |
24 | 32 |
|
25 | | - |
26 | 33 | jobs: |
27 | | - deploy: |
| 34 | + deploy-st2: |
28 | 35 | runs-on: ubuntu-latest |
29 | 36 | steps: |
30 | | - - id: deploy |
31 | | - name: Deploy |
| 37 | + - id: deploy-st2 |
| 38 | + name: Deploy StackStorm |
| 39 | + # NOTE: we recommend pinning to the latest numeric version |
| 40 | + # See: https://github.com/bitovi/github-actions-deploy-stackstorm/releases |
32 | 41 | uses: bitovi/github-actions-deploy-stackstorm@main |
33 | 42 | with: |
| 43 | + aws_default_region: us-east-1 |
34 | 44 | aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID}} |
35 | 45 | aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}} |
36 | | - aws_default_region: us-east-1 |
37 | 46 | st2_auth_username: ${{ secrets.ST2_AUTH_USERNAME}} |
38 | 47 | st2_auth_password: ${{ secrets.ST2_AUTH_PASSWORD}} |
39 | 48 | ``` |
40 | 49 |
|
41 | 50 | This will create the following resources in AWS: |
42 | 51 | - An EC2 instance |
| 52 | +- Route53 records |
43 | 53 | - A load balancer |
44 | | -- Security groups |
45 | | -- Optionally, a VPC with subnets |
| 54 | +- Security groups (ports `80`, `443`, `22`) |
| 55 | +- Optionally, a VPC with subnets (see `aws_create_vpc`) |
46 | 56 |
|
47 | | -> For more details about what is created, see `operations/deployment/terraform/modules` |
| 57 | +> For more details about what is created, see [operations/deployment/terraform/modules](operations/deployment/terraform/modules/) |
48 | 58 |
|
49 | 59 | ## Customizing |
50 | 60 |
|
51 | 61 | ### Inputs |
52 | 62 |
|
53 | | -The following inputs can be used as `step.with` keys |
| 63 | +The following inputs can be used as `steps.with` keys: |
54 | 64 |
|
55 | 65 | | Name | Type | Default | Description | |
56 | 66 | |------------------|---------|-------------|------------------------------------| |
57 | | -| `checkout` | Bool | true | Specifies if this action should checkout the code (i.e. whether or not to run the `uses: actions/checkout@v3` action prior to deploying so that the deployment has access to the repo files) | |
58 | | -| `aws_access_key_id` | String | | AWS access key ID (Required) | |
59 | | -| `aws_secret_access_key` | String | | AWS secret access key (Required) | |
60 | | -| `aws_session_token` | String | | AWS session token | |
61 | | -| `aws_default_region` | String | us-east-1 | AWS default region (Required) | |
62 | | -| `tf_state_bucket` | String | `${org}-${repo}-{branch}-tf-state` | AWS S3 bucket to use for Terraform state. | |
63 | | -| `tf_state_bucket_destroy` | Bool | false | Force purge and deletion of tf_state_bucket defined. Any file contained there will be destroyed. `stack_destroy` must also be `true` | |
64 | | -| `ec2_instance_profile` | String | | The AWS IAM instance profile to use for the EC2 instance | |
65 | | -| `ec2_instance_type` | String | t2.medium | The AWS EC2 instance type. | |
66 | | -| `stack_destroy` | Bool | false | Set to "true" to Destroy the stack | |
67 | | -| `aws_resource_identifier` | String | `${org}-{repo}-{branch}` | Set to override the AWS resource identifier for the deployment. Use with destroy to destroy specific resources. | |
68 | | -| `aws_create_vpc` | Bool | false | Whether an AWS VPC should be created in the action. | |
69 | | -| `st2_auth_username` | String | | Username used by StackStorm standalone authentication | |
70 | | -| `st2_auth_password` | String | | Password used by StackStorm standalone authentication | |
71 | | -| `st2_packs` | String |`"st2"` | Comma separated list of packs to install. This flag does not work with a --python3 only pack.. If you modify this option, be sure to also include `st2` in the list. | |
72 | | -| `infrastructure_only` | Bool | false | Does infrastructure (i.e. terraform) but **not** the deployment (i.e. ansible) | |
73 | | - |
74 | | - |
75 | | -## Note about resource identifiers |
76 | | - |
77 | | -Most resources will contain the tag GITHUB_ORG-GITHUB_REPO-GITHUB_BRANCH, some of them, even the resource name after. |
78 | | -We limit this to a 60 characters string because some AWS resources have a length limit and short it if needed. |
79 | | - |
80 | | -We use the kubernetes style for this. For example, kubernetes -> k(# of characters)s -> k8s. And so you might see some compressions are made. |
81 | | - |
82 | | -For some specific resources, we have a 32 characters limit. If the identifier length exceeds this number after compression, we remove the middle part and replace it for a hash made up from the string itself. |
| 67 | +| `checkout` | bool | `true` | Specifies if this action should checkout the code (i.e. whether or not to run the `uses: actions/checkout@v3` action prior to deploying so that the deployment has access to the repo files) | |
| 68 | +| **AWS configuration** | |
| 69 | +| `aws_access_key_id` | string | | AWS access key ID (Required) | |
| 70 | +| `aws_secret_access_key` | string | | AWS secret access key (Required) | |
| 71 | +| `aws_session_token` | string | | AWS session token | |
| 72 | +| `aws_default_region` | string | `us-east-1` | AWS default region (Required) | |
| 73 | +| `ec2_instance_type` | string | `t2.medium` | The AWS EC2 instance type. | |
| 74 | +| `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 | |
| 75 | +| `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. | |
| 76 | +| `aws_create_vpc` | bool | `false` | Whether an AWS VPC should be created in the action. Otherwise, the existing default VPC will be used. | |
| 77 | +| `infrastructure_only` | bool | `false` | Does infrastructure (i.e. terraform) but **not** the deployment (i.e. ansible) | |
| 78 | +| **Teraform configuration** | |
| 79 | +| `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. | |
| 80 | +| **StackStorm configuration** | |
| 81 | +| `st2_auth_username` | string | | Username used by StackStorm standalone authentication. Set as a secret in GH Actions. | |
| 82 | +| `st2_auth_password` | string | | Password used by StackStorm standalone authentication. Set as a secret in GH Actions. | |
| 83 | +| `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. | |
| 84 | +| **Cleanup** | |
| 85 | +| `stack_destroy` | bool | `false` | Set to `true` to Destroy the created AWS infrastructure for this instance | |
| 86 | +| `tf_state_bucket_destroy` | bool | `false` | Force purge and deletion of `tf_state_bucket` defined. Any file contained there will be destroyed. `stack_destroy` must also be `true`. Use if you want to clean up the resources | |
| 87 | + |
| 88 | + |
| 89 | +## Note about AWS resource identifiers |
| 90 | +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. |
| 91 | + |
| 92 | +We use the Kubernetes style for this. For example, `Kubernetes` -> `k(# of characters)s` -> `k8s`. And so you might see how compressions are made. |
| 93 | + |
| 94 | +For some specific resources, we have a `32` characters limit. If the identifier length exceeds this number after compression, we remove the middle part and replace it with a hash made up of the string itself. |
83 | 95 |
|
84 | 96 | ### S3 buckets naming |
85 | | - |
86 | | -Buckets name can be made of up to 63 characters. If the length allows us to add `-tf-state`, we will do so. If not, a simple `-tf` will be added. |
| 97 | +Bucket names can be made of up to 63 characters. If the length allows us to add `-tf-state`, we will do so. If not, a simple `-tf` will be added. |
87 | 98 |
|
88 | 99 | ## Made with BitOps |
89 | | -[BitOps](https://bitops.sh) allows you to define Infrastructure-as-Code for multiple tools in a central place. This action uses a BitOps [Operations Repository](https://bitops.sh/operations-repo-structure/) to set up the necessary Terraform and Ansible to create infrastructure and deploy to it. |
| 100 | +[BitOps](https://bitops.sh/) allows you to define Infrastructure-as-Code for multiple tools in a central place. This action uses BitOps [Operations Repository Structure](https://bitops.sh/operations-repo-structure/) to organize the necessary Terraform and Ansible steps, create infrastructure and deploy to it. |
90 | 101 |
|
91 | 102 | ## Future |
92 | | -In the future, this action will support more cloud providers (via [BitOps Plugins](https://bitops.sh/plugins/) like [AWS](https://github.com/bitops-plugins/aws)) such as |
| 103 | +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: |
93 | 104 | - [Google Cloud Platform](https://cloud.google.com/gcp) |
94 | 105 | - [Microsoft Azure](https://azure.microsoft.com/en-us/) |
95 | 106 | - [Nutanix](https://www.nutanix.com/) |
96 | 107 | - [Open Stack](https://www.openstack.org/) |
97 | 108 | - [VMWare](https://www.vmware.com/) |
98 | 109 | - etc |
99 | 110 |
|
100 | | -This action will also support multiple deployment types such as: |
| 111 | +This action may also support multiple deployment types such as: |
101 | 112 | - [Kubernetes](https://github.com/StackStorm/stackstorm-k8s) |
102 | 113 | - Multi-VM |
103 | 114 |
|
104 | | -## Contributing |
105 | | -We would love for you to contribute to [bitovi/github-actions-deploy-docker-to-ec2](https://github.com/bitovi/github-actions-deploy-docker-to-ec2). [Issues](https://github.com/bitovi/github-actions-deploy-docker-to-ec2/issues) and [Pull Requests](https://github.com/bitovi/github-actions-deploy-docker-to-ec2/pulls) are welcome! |
| 115 | +This action is still in its early stages, so we welcome your feedback! [Open an issue](issues/) if you have a feature request. |
106 | 116 |
|
107 | | -## License |
108 | | -The scripts and documentation in this project are released under the [MIT License](https://github.com/bitovi/github-actions-deploy-docker-to-ec2/blob/main/LICENSE). |
| 117 | +## Contributing |
| 118 | +We would love for you to contribute to [bitovi/github-actions-deploy-stackstorm](/). [Issues](issues/) and [Pull Requests](pulls/) are welcome! |
109 | 119 |
|
110 | 120 | ## Provided by Bitovi |
111 | 121 | [Bitovi](https://www.bitovi.com/) is a proud supporter of Open Source software. |
112 | 122 |
|
113 | | - |
114 | 123 | ## Need help? |
115 | | -Bitovi has consultants that can help. Drop into [Bitovi's Community Slack](https://www.bitovi.com/community/slack), and talk to us in the `#devops` channel! |
| 124 | +Bitovi has consultants that can help. Drop into [Bitovi's Community Slack](https://www.bitovi.com/community/slack), and talk to us in the `#devops` channel! |
116 | 125 |
|
117 | | -Need DevOps Consulting Services? Head over to https://www.bitovi.com/devops-consulting, and book a free consultation. |
| 126 | +Need DevOps Consulting Services? Head over to https://www.bitovi.com/devops-consulting, and book a free consultation. |
0 commit comments