or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

async-tasks.mdcli-operations.mdcore-deployment.mdindex.mdpackage-utilities.mdrequest-processing.mdssl-management.mdutilities.mdwsgi-processing.md

cli-operations.mddocs/

0

# CLI Operations

1

2

Complete command-line interface operations for Zappa deployment lifecycle management. The ZappaCLI class provides user-friendly commands for initializing, deploying, monitoring, and managing serverless applications.

3

4

## Capabilities

5

6

### Project Initialization

7

8

Initialize new Zappa projects with configuration templates and setup.

9

10

```python { .api }

11

def init(self):

12

"""

13

Initialize a new Zappa project by creating settings template.

14

15

Creates zappa_settings.json configuration file with default settings

16

for development and production environments.

17

18

Returns:

19

bool: True if initialization successful

20

"""

21

```

22

23

### Deployment Operations

24

25

Deploy new applications and update existing deployments.

26

27

```python { .api }

28

def deploy(self):

29

"""

30

Deploy Zappa application to AWS Lambda and API Gateway.

31

32

Creates Lambda function, API Gateway, and all necessary AWS resources.

33

Uses settings from zappa_settings.json configuration file.

34

35

Returns:

36

bool: True if deployment successful

37

"""

38

```

39

40

```python { .api }

41

def update(self):

42

"""

43

Update existing Zappa deployment with new code and configuration.

44

45

Updates Lambda function code and configuration while preserving

46

existing API Gateway and other resources.

47

48

Returns:

49

bool: True if update successful

50

"""

51

```

52

53

### Deployment Management

54

55

Monitor, rollback, and clean up deployments.

56

57

```python { .api }

58

def status(self):

59

"""

60

Show current deployment status and information.

61

62

Displays Lambda function status, API Gateway endpoints,

63

recent deployments, and resource utilization.

64

65

Returns:

66

dict: Status information and metadata

67

"""

68

```

69

70

```python { .api }

71

def undeploy(self):

72

"""

73

Remove Zappa deployment and clean up AWS resources.

74

75

Deletes Lambda function, API Gateway, IAM roles, and other

76

associated AWS resources.

77

78

Returns:

79

bool: True if removal successful

80

"""

81

```

82

83

```python { .api }

84

def rollback(self):

85

"""

86

Roll back deployment to previous version.

87

88

Reverts Lambda function to previous version and updates

89

API Gateway to point to rolled-back function.

90

91

Returns:

92

bool: True if rollback successful

93

"""

94

```

95

96

### Monitoring and Debugging

97

98

Monitor application logs and access remote execution environment.

99

100

```python { .api }

101

def tail(self):

102

"""

103

Stream Lambda function logs in real-time.

104

105

Displays CloudWatch logs for the deployed function with

106

real-time updates and filtering options.

107

108

Returns:

109

None: Runs continuously until interrupted

110

"""

111

```

112

113

```python { .api }

114

def shell(self):

115

"""

116

Open remote Python shell session on Lambda.

117

118

Provides interactive Python REPL running in the Lambda

119

environment with access to deployed application context.

120

121

Returns:

122

None: Interactive session until exit

123

"""

124

```

125

126

### Package Operations

127

128

Create deployment packages and templates without deploying.

129

130

```python { .api }

131

def package(self):

132

"""

133

Create deployment package without deploying to AWS.

134

135

Generates Lambda deployment ZIP package with all

136

dependencies and code for manual deployment or inspection.

137

138

Returns:

139

str: Path to created package file

140

"""

141

```

142

143

```python { .api }

144

def template(self):

145

"""

146

Generate CloudFormation or SAM template for deployment.

147

148

Creates Infrastructure as Code template that can be

149

deployed using CloudFormation or SAM CLI.

150

151

Returns:

152

str: Path to generated template file

153

"""

154

```

155

156

### Event Management

157

158

Manage scheduled events and invocations.

159

160

```python { .api }

161

def schedule(self):

162

"""

163

Schedule events for deployed Lambda function.

164

165

Creates CloudWatch Events rules to trigger Lambda

166

function on specified schedules (cron or rate expressions).

167

168

Returns:

169

bool: True if scheduling successful

170

"""

171

```

172

173

```python { .api }

174

def unschedule(self):

175

"""

176

Remove scheduled events for Lambda function.

177

178

Deletes CloudWatch Events rules and stops

179

scheduled execution of Lambda function.

180

181

Returns:

182

bool: True if unscheduling successful

183

"""

184

```

185

186

```python { .api }

187

def invoke(self):

188

"""

189

Invoke deployed Lambda function with test data.

190

191

Executes Lambda function with specified payload

192

for testing and debugging purposes.

193

194

Returns:

195

dict: Function response and execution details

196

"""

197

```

198

199

### SSL Certificate Management

200

201

Manage SSL certificates for custom domains.

202

203

```python { .api }

204

def certify(self):

205

"""

206

Generate and configure SSL certificates for custom domains.

207

208

Uses Let's Encrypt to obtain SSL certificates and

209

configures them with API Gateway custom domains.

210

211

Returns:

212

dict: Certificate information and domain configuration

213

"""

214

```

215

216

### Configuration Management

217

218

Save and manage deployment configuration settings.

219

220

```python { .api }

221

def save_python_settings_file(self):

222

"""

223

Save current Python settings to configuration file.

224

225

Exports runtime configuration including Python version,

226

dependencies, and environment settings to file.

227

228

Returns:

229

bool: True if save successful

230

"""

231

```

232

233

### Advanced Operations

234

235

Advanced deployment and management operations.

236

237

```python { .api }

238

def check_environment(self):

239

"""

240

Validate deployment environment and dependencies.

241

242

Checks Python version, AWS credentials, dependencies,

243

and configuration for deployment compatibility.

244

245

Returns:

246

dict: Environment validation results

247

"""

248

```

249

250

```python { .api }

251

def check_stage_name(self, stage_name):

252

"""

253

Validate stage name format and availability.

254

255

Checks if stage name follows AWS naming conventions

256

and doesn't conflict with existing deployments.

257

258

Parameters:

259

- stage_name: str, deployment stage name to validate

260

261

Returns:

262

bool: True if stage name is valid

263

"""

264

```

265

266

```python { .api }

267

def print_logs(self):

268

"""

269

Display formatted Lambda function logs.

270

271

Retrieves and displays CloudWatch logs with

272

filtering, coloring, and formatting options.

273

274

Returns:

275

None: Outputs logs to console

276

"""

277

```

278

279

## CLI Entry Point

280

281

```python { .api }

282

def handle():

283

"""

284

Main CLI entry point for command processing.

285

286

Parses command-line arguments and routes to appropriate

287

ZappaCLI methods. Used by 'zappa' and 'z' console commands.

288

289

Returns:

290

None: Exits with status code

291

"""

292

```

293

294

## Configuration Constants

295

296

```python { .api }

297

# Custom Zappa-specific settings

298

CUSTOM_SETTINGS = [

299

'apigateway_policy',

300

'assume_policy',

301

'attach_policy',

302

'aws_region',

303

'delete_local_zip',

304

'delete_s3_zip',

305

'exclude',

306

'exclude_glob',

307

'extra_permissions',

308

'include',

309

'role_name',

310

'touch'

311

]

312

313

# Documentation reference

314

BOTO3_CONFIG_DOCS_URL = "https://boto3.readthedocs.io/en/latest/guide/quickstart.html#configuration"

315

```

316

317

## Usage Examples

318

319

### Basic Deployment Workflow

320

321

```python

322

from zappa.cli import ZappaCLI

323

324

# Create CLI instance

325

cli = ZappaCLI()

326

327

# Initialize new project (creates zappa_settings.json)

328

cli.init()

329

330

# Deploy to AWS (creates all resources)

331

cli.deploy()

332

333

# Update deployment with changes

334

cli.update()

335

336

# Check deployment status

337

cli.status()

338

339

# Stream logs for monitoring

340

cli.tail()

341

342

# Clean up when done

343

cli.undeploy()

344

```

345

346

### Configuration File Format

347

348

The `init()` command creates a `zappa_settings.json` file with the following structure:

349

350

```json

351

{

352

"dev": {

353

"app_function": "app.app",

354

"aws_region": "us-east-1",

355

"profile_name": "default",

356

"project_name": "my-project",

357

"runtime": "python3.9",

358

"s3_bucket": "my-deployments-bucket"

359

},

360

"production": {

361

"app_function": "app.app",

362

"aws_region": "us-east-1",

363

"profile_name": "default",

364

"project_name": "my-project-prod",

365

"runtime": "python3.9",

366

"s3_bucket": "my-deployments-bucket"

367

}

368

}

369

```

370

371

### Command Line Usage

372

373

```bash

374

# Initialize new project

375

zappa init

376

377

# Deploy to dev environment

378

zappa deploy dev

379

380

# Update dev deployment

381

zappa update dev

382

383

# Check status

384

zappa status dev

385

386

# Stream logs

387

zappa tail dev

388

389

# Deploy to production

390

zappa deploy production

391

392

# Roll back production

393

zappa rollback production

394

395

# Remove deployment

396

zappa undeploy dev

397

```