@devramps/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +204 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2563 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 DevRamps
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# @devramps/cli
|
|
2
|
+
|
|
3
|
+
DevRamps CLI - Bootstrap AWS infrastructure for CI/CD pipelines.
|
|
4
|
+
|
|
5
|
+
This CLI tool helps you set up IAM roles in your AWS accounts that allow DevRamps to deploy your applications securely using OIDC federation.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
### Node.js
|
|
10
|
+
|
|
11
|
+
This tool requires Node.js version 18 or higher.
|
|
12
|
+
|
|
13
|
+
**First time installing Node.js?**
|
|
14
|
+
|
|
15
|
+
- **macOS**: Install via Homebrew: `brew install node`
|
|
16
|
+
- **Windows**: Download from [nodejs.org](https://nodejs.org/) or use [nvm-windows](https://github.com/coreybutler/nvm-windows)
|
|
17
|
+
- **Linux**: Use your package manager or [nvm](https://github.com/nvm-sh/nvm):
|
|
18
|
+
```bash
|
|
19
|
+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
|
|
20
|
+
nvm install 18
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Verify your installation:
|
|
24
|
+
```bash
|
|
25
|
+
node --version # Should be v18.0.0 or higher
|
|
26
|
+
npm --version # Should be v8.0.0 or higher
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### AWS CLI
|
|
30
|
+
|
|
31
|
+
You need AWS credentials configured. The CLI uses these credentials to assume roles in your target accounts.
|
|
32
|
+
|
|
33
|
+
1. Install the AWS CLI: [AWS CLI Installation Guide](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
|
|
34
|
+
2. Configure credentials:
|
|
35
|
+
```bash
|
|
36
|
+
aws configure
|
|
37
|
+
```
|
|
38
|
+
Or set environment variables:
|
|
39
|
+
```bash
|
|
40
|
+
export AWS_ACCESS_KEY_ID=your_access_key
|
|
41
|
+
export AWS_SECRET_ACCESS_KEY=your_secret_key
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
You can run the CLI directly using npx (no installation required):
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx @devramps/cli bootstrap
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or install it globally:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install -g @devramps/cli
|
|
56
|
+
devramps bootstrap
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
### Bootstrap Command
|
|
62
|
+
|
|
63
|
+
The `bootstrap` command creates IAM roles in your target AWS accounts based on your pipeline definitions.
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx @devramps/cli bootstrap [options]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Options
|
|
70
|
+
|
|
71
|
+
| Option | Description |
|
|
72
|
+
|--------|-------------|
|
|
73
|
+
| `--target-account-role-name <name>` | Role to assume in target accounts. Default: `OrganizationAccountAccessRole`, fallback: `AWSControlTowerExecution` |
|
|
74
|
+
| `--pipeline-slugs <slugs>` | Comma-separated list of pipeline slugs to bootstrap. Default: all pipelines |
|
|
75
|
+
| `--dry-run` | Show what would be deployed without actually deploying |
|
|
76
|
+
| `--verbose` | Enable verbose logging for debugging |
|
|
77
|
+
|
|
78
|
+
#### Examples
|
|
79
|
+
|
|
80
|
+
Bootstrap all pipelines:
|
|
81
|
+
```bash
|
|
82
|
+
npx @devramps/cli bootstrap
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Bootstrap specific pipelines:
|
|
86
|
+
```bash
|
|
87
|
+
npx @devramps/cli bootstrap --pipeline-slugs my-app,my-other-app
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Use a custom role name for cross-account access:
|
|
91
|
+
```bash
|
|
92
|
+
npx @devramps/cli bootstrap --target-account-role-name MyCustomRole
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Preview changes without deploying:
|
|
96
|
+
```bash
|
|
97
|
+
npx @devramps/cli bootstrap --dry-run
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Project Structure
|
|
101
|
+
|
|
102
|
+
Your project should have a `.devramps` folder at the root with the following structure:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
your-project/
|
|
106
|
+
├── .devramps/
|
|
107
|
+
│ ├── my-pipeline/
|
|
108
|
+
│ │ ├── pipeline.yaml # Required: Pipeline definition
|
|
109
|
+
│ │ └── aws_additional_iam_policies.yaml # Optional: Additional IAM policies
|
|
110
|
+
│ └── another-pipeline/
|
|
111
|
+
│ └── pipeline.yaml
|
|
112
|
+
└── ... your application code
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Additional IAM Policies
|
|
116
|
+
|
|
117
|
+
You can specify additional IAM policies in either JSON or YAML format for e.g. infrastructure synthesis:
|
|
118
|
+
|
|
119
|
+
**aws_additional_iam_policies.yaml**:
|
|
120
|
+
```yaml
|
|
121
|
+
- Version: "2012-10-17"
|
|
122
|
+
Statement:
|
|
123
|
+
- Effect: Allow
|
|
124
|
+
Action:
|
|
125
|
+
- s3:GetObject
|
|
126
|
+
- s3:PutObject
|
|
127
|
+
Resource: "arn:aws:s3:::my-bucket/*"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**aws_additional_iam_policies.json**:
|
|
131
|
+
```json
|
|
132
|
+
[
|
|
133
|
+
{
|
|
134
|
+
"Version": "2012-10-17",
|
|
135
|
+
"Statement": [
|
|
136
|
+
{
|
|
137
|
+
"Effect": "Allow",
|
|
138
|
+
"Action": ["s3:GetObject", "s3:PutObject"],
|
|
139
|
+
"Resource": "arn:aws:s3:::my-bucket/*"
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## What Gets Created
|
|
147
|
+
|
|
148
|
+
For each pipeline and target account combination, the bootstrap command creates a CloudFormation stack named `DevRamps-<pipeline-slug>-Bootstrap` containing:
|
|
149
|
+
|
|
150
|
+
1. **OIDC Identity Provider** (`devramps.com`) - Enables secure, credential-less authentication
|
|
151
|
+
2. **IAM Role** (`DevRamps-CICD-DeploymentRole`) - The role that DevRamps assumes to deploy your application
|
|
152
|
+
- Trust policy allowing only your organization and pipeline
|
|
153
|
+
- Policies for each deployment step type
|
|
154
|
+
- Any additional policies you've specified
|
|
155
|
+
|
|
156
|
+
## Supported Step Types
|
|
157
|
+
|
|
158
|
+
| Step Type | Description |
|
|
159
|
+
|-----------|-------------|
|
|
160
|
+
| `DEVRAMPS:EKS:DEPLOY` | Deploy to EKS using kubectl |
|
|
161
|
+
| `DEVRAMPS:EKS:HELM` | Deploy to EKS using Helm |
|
|
162
|
+
| `DEVRAMPS:ECS:DEPLOY` | Deploy to ECS |
|
|
163
|
+
| `DEVRAMPS:APPROVAL:BAKE` | Wait/approval step (no AWS permissions needed) |
|
|
164
|
+
| `CUSTOM:*` | Custom steps (define permissions in additional policies) |
|
|
165
|
+
|
|
166
|
+
## Troubleshooting
|
|
167
|
+
|
|
168
|
+
### "Could not find .devramps folder"
|
|
169
|
+
|
|
170
|
+
Make sure you're running the command from the root of your project, where the `.devramps` folder is located.
|
|
171
|
+
|
|
172
|
+
### "No AWS credentials found"
|
|
173
|
+
|
|
174
|
+
Configure AWS credentials using one of these methods:
|
|
175
|
+
- Run `aws configure` to set up credentials
|
|
176
|
+
- Set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables
|
|
177
|
+
- Use AWS SSO: `aws sso login`
|
|
178
|
+
|
|
179
|
+
### "Unable to assume role"
|
|
180
|
+
|
|
181
|
+
Your current AWS credentials don't have permission to assume the target role. Make sure:
|
|
182
|
+
1. The role exists in the target account
|
|
183
|
+
2. Your current credentials have `sts:AssumeRole` permission for that role
|
|
184
|
+
3. The role's trust policy allows your current identity to assume it
|
|
185
|
+
|
|
186
|
+
Try specifying a different role:
|
|
187
|
+
```bash
|
|
188
|
+
npx @devramps/cli bootstrap --target-account-role-name MyCustomRole
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### "Authentication timed out"
|
|
192
|
+
|
|
193
|
+
The browser authentication flow has a 5-minute timeout. If you see this error:
|
|
194
|
+
1. Make sure your browser opened the DevRamps authentication page
|
|
195
|
+
2. Complete the login and organization selection
|
|
196
|
+
3. If the page didn't open, check if a popup blocker is preventing it
|
|
197
|
+
|
|
198
|
+
## Contributing
|
|
199
|
+
|
|
200
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|