|
1 |
| -# github-actions-deploy-stackstorm |
| 1 | +# Deploy StackStorm |
| 2 | + |
| 3 | +GitHub action to deploy [StackStorm](https://stackstorm.com/) to an AWS VM (EC2). |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | +- 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 | +- 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 |
| 12 | + |
| 13 | + |
| 14 | +## Example usage |
| 15 | + |
| 16 | +Create `.github/workflow/deploy.yaml` with the following to build on push. |
| 17 | + |
| 18 | +```yaml |
| 19 | +name: Deploy ST2 Single VM with GHA |
| 20 | + |
| 21 | +on: |
| 22 | + push: |
| 23 | + branches: [ main ] |
| 24 | + |
| 25 | + |
| 26 | +jobs: |
| 27 | + deploy: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - id: deploy |
| 31 | + name: Deploy |
| 32 | + uses: bitovi/github-actions-deploy-stackstorm@main |
| 33 | + with: |
| 34 | + aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID}} |
| 35 | + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}} |
| 36 | + aws_default_region: us-east-1 |
| 37 | + st2_auth_username: ${{ secrets.ST2_AUTH_USERNAME}} |
| 38 | + st2_auth_password: ${{ secrets.ST2_AUTH_PASSWORD}} |
| 39 | +``` |
| 40 | +
|
| 41 | +This will create the following resources in AWS: |
| 42 | +- An EC2 instance |
| 43 | +- A load balancer |
| 44 | +- Security groups |
| 45 | +- Optionally, a VPC with subnets |
| 46 | +
|
| 47 | +> For more details about what is created, see `operations/deployment/terraform/modules` |
| 48 | + |
| 49 | +## Customizing |
| 50 | + |
| 51 | +### Inputs |
| 52 | + |
| 53 | +The following inputs can be used as `step.with` keys |
| 54 | + |
| 55 | +| Name | Type | Default | Description | |
| 56 | +|------------------|---------|-------------|------------------------------------| |
| 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 | +| `ec2_instance_profile` | String | | The AWS IAM instance profile to use for the EC2 instance | |
| 64 | +| `ec2_instance_type` | String | t2.medium | The AWS EC2 instance type. | |
| 65 | +| `stack_destroy` | Bool | false | Set to "true" to Destroy the stack | |
| 66 | +| `aws_resource_identifier` | String | `${org}-{repo}-{branch}` | Set to override the AWS resource identifier for the deployment. Use with destroy to destroy specific resources. | |
| 67 | +| `aws_create_vpc` | Bool | false | Whether an AWS VPC should be created in the action. | |
| 68 | +| `st2_auth_username` | String | | Username used by StackStorm standalone authentication | |
| 69 | +| `st2_auth_password` | String | | Password used by StackStorm standalone authentication | |
| 70 | +| `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. | |
| 71 | +| `infrastructure_only` | Bool | false | Does infrastructure (i.e. terraform) but **not** the deployment (i.e. ansible) | |
| 72 | + |
| 73 | + |
| 74 | +## Note about resource identifiers |
| 75 | + |
| 76 | +Most resources will contain the tag GITHUB_ORG-GITHUB_REPO-GITHUB_BRANCH, some of them, even the resource name after. |
| 77 | +We limit this to a 60 characters string because some AWS resources have a length limit and short it if needed. |
| 78 | + |
| 79 | +We use the kubernetes style for this. For example, kubernetes -> k(# of characters)s -> k8s. And so you might see some compressions are made. |
| 80 | + |
| 81 | +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. |
| 82 | + |
| 83 | +### S3 buckets naming |
| 84 | + |
| 85 | +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. |
| 86 | + |
| 87 | +## Made with BitOps |
| 88 | +[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. |
| 89 | + |
| 90 | +## Future |
| 91 | +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 |
| 92 | +- [Google Cloud Platform](https://cloud.google.com/gcp) |
| 93 | +- [Microsoft Azure](https://azure.microsoft.com/en-us/) |
| 94 | +- [Nutanix](https://www.nutanix.com/) |
| 95 | +- [Open Stack](https://www.openstack.org/) |
| 96 | +- [VMWare](https://www.vmware.com/) |
| 97 | +- etc |
| 98 | + |
| 99 | +This action will also support multiple deployment types such as: |
| 100 | +- [Kubernetes](https://github.com/StackStorm/stackstorm-k8s) |
| 101 | +- Multi-VM |
| 102 | + |
| 103 | +## Contributing |
| 104 | +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! |
| 105 | + |
| 106 | +## License |
| 107 | +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). |
| 108 | + |
| 109 | +## Provided by Bitovi |
| 110 | +[Bitovi](https://www.bitovi.com/) is a proud supporter of Open Source software. |
| 111 | + |
| 112 | + |
| 113 | +## Need help? |
| 114 | +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! |
| 115 | + |
| 116 | +Need DevOps Consulting Services? Head over to https://www.bitovi.com/devops-consulting, and book a free consultation. |
0 commit comments