|
1 | | -# deploy-beanstalk |
| 1 | +# cdk-log-parser |
2 | 2 |
|
3 | 3 | [](https://codecov.io/gh/time-loop/deploy-beanstalk) |
4 | 4 |
|
5 | | -`deploy-beanstalk` is a TypeScript library for deploying an artifact living in S3 to a group of AWS Elastic Beanstalk Environments. |
6 | | - |
7 | | -## Why? |
8 | | - |
9 | | -- **CI Tool Decoupling** |
10 | | - - The possibility of switching over to any CI tool (GitHub actions, GitLab CI, etc.) is attractive. To prep for that, we need portable scripts that can be run Anywhere™. |
11 | | - - CI scripts can be written in any language such that engineers can easily read and improve upon them. |
12 | | - - Consequently, we can easily introduce tests to our CI scripts. |
13 | | -- **Parallel deployments** |
14 | | - - We can utilize language functionality (like TypeScript async functions, Golang goroutines, etc.) to allow for parallel deployments to multiple beanstalks at once...in whatever batched fashion we so desire. |
15 | | -- **Build once, deploy many** |
16 | | - - The [TooManyApplicationVersions error](https://stackoverflow.com/questions/9589531/how-to-avoid-a-toomanyapplicationversion-exception-on-aws-elastic-beanstalk) is a nuisance and should be avoided. Indeed, it's a sign of bad build/deploy design which can potentially block deploys entirely. With `deploy-beanstalk`, no more than one Application Version is created per unique Beanstalk Application in the selected group, regardless of Environment count. |
17 | | - |
18 | | -## Usage |
19 | | - |
20 | | -`tools/ci/deploy/deploy.ts` handles asynchronous+simultaneous deployments to a group of beanstalk environments. It does this by creating an Application Version (one per Beanstalk Application only) from an artifact in S3 followed by issuing deployments of that Application Version to each respective beanstalk environment in the group. |
21 | | - |
22 | | -The library can be pulled from GitHub Packages. |
23 | | - |
24 | | -### Authentication |
25 | | - |
26 | | -> ***TL;DR:*** Follow the [abridged instructions](https://github.com/time-loop/cdk-library#setup-github-packages-access) written in cdk-library. |
27 | | -
|
28 | | -You need to setup scoped access to GitHub Packages in your `~/.npmrc`. To do so, create a GitHub PAT with scope `read:packages`. With such a limited scope, setting expiry to `never` is permissible. Canonical instructions to do this can be [found here ](https://docs.github.com/en/[email protected]/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). |
29 | | - |
30 | | -> NOTE: If you are working with a GitHub Workflow, the provided `GITHUB_TOKEN` might Just Work for you as this is a public package. However, if you also need to access packages that are private to your org, you might consider adding an `ALL_PACKAGE_READ_TOKEN` org secret followed by populating your .npmrc appropriately. |
31 | | -
|
32 | | -After creating a PAT, follow [canonical instructions to setup your authentication to GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry). |
33 | | - |
34 | | -### Installation |
35 | | - |
36 | | -Use `npm` or any relevant package manager in your project like so: |
37 | | - |
38 | | -```bash |
39 | | -# --save-dev is optional, depending on whether this is used in the main app or |
40 | | -# a complementary tool like for CI/CD pipelines. |
41 | | -npm install [--save-dev] @time-loop/deploy-beanstalk |
42 | | -``` |
43 | | - |
44 | | -### Importing |
45 | | - |
46 | | -```typescript |
47 | | -import { |
48 | | - deployToGroup, // function to call which deploys to a group |
49 | | - IBeanstalkGroup, // Allows us to dictate beanstalk environments to deploy to |
50 | | - IDeployToGroupProps // Rest of the configuration needed to deploy |
51 | | -} from '@time-loop/deploy-beanstalk'; |
52 | | -``` |
53 | | - |
54 | | -### Grouping |
55 | | - |
56 | | -An example configuration for a group of beanstalk environments and the artifact to deploy to them: |
57 | | - |
58 | | -```typescript |
59 | | -const group: IBeanstalkGroup = { |
60 | | - environments: [ |
61 | | - { |
62 | | - app: 'ClickupExampleAppOne', |
63 | | - name: 'ExampleEnvironmentOne', |
64 | | - }, |
65 | | - { |
66 | | - app: 'ClickupExampleAppTwo', |
67 | | - name: 'ExampleEnvironmentTwo', |
68 | | - }, |
69 | | - ], |
70 | | - versionProps: { |
71 | | - artifact: { |
72 | | - S3Bucket: 'example-bucket-clickup', |
73 | | - S3Key: 'exampleDir/clickupExampleArtifact.zip', |
74 | | - }, |
75 | | - label: 'ExampleLabel', |
76 | | - description: 'Example desc', |
77 | | - errorIfExists: true, |
78 | | - }, |
79 | | - name: 'ExampleBeanstalkGroup', |
80 | | - region: 'us-west-2', |
81 | | -}; |
82 | | -``` |
83 | | - |
84 | | -### Deploying |
85 | | - |
86 | | -```typescript |
87 | | -try { |
88 | | - ... |
89 | | - const props: IDeployToGroupProps = { |
90 | | - group, |
91 | | - force: true, |
92 | | - // Allows 5 mins to verify health prior to deploy |
93 | | - preDeployHealthCheckProps: { |
94 | | - attempts: 5, |
95 | | - timeBetweenAttemptsMs: 60000, |
96 | | - }, |
97 | | - // Allows 20 mins after deploy to verify health |
98 | | - postDeployHealthCheckProps: { |
99 | | - attempts: 20, |
100 | | - timeBetweenAttemptsMs: 60000, |
101 | | - }, |
102 | | - }; |
103 | | - await deployToGroup(props); |
104 | | -} catch (e) { |
105 | | - console.error(e); |
106 | | - process.exit(1); |
107 | | -} |
108 | | -``` |
| 5 | +`cdk-log-parser` is a TypeScript cli tool used for reducing cdk diff log output to only real changes. |
0 commit comments