-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathimportant_commands.sh
101 lines (70 loc) · 2.7 KB
/
important_commands.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
################################################################################
# PART 1: Configure NodeJs, Python and CDK libraries
################################################################################
# Install NodeJs and Python
# --> https://nodejs.org/en/download/
# --> https://www.python.org/downloads/
# Verify that NodeJs/npm is installed correctly
node --version
npm --version
# Verify that Python/pip is installed correctly
python --version || python3 --version
pip --version || pip3 --version
# Install AWS-CDK (on NodeJs)
sudo npm install -g aws-cdk
# Verify correct install of AWS-CDK
npm list --global | grep aws-cdk
################################################################################
# PART 2: Initial Project Setup (Only run these at the beginning)
################################################################################
# Configure AWS credentials (follow steps)
aws configure
# --> Alternative 1: Environment variables added to terminal session
# --> Alternative 2: AWS Cloud9 with the right permissions
# Bootstrap CDK (provision initial resources to work with CDK.. S3, roles, etc)
#! Change "ACCOUNT-NUMBER" and "REGION" to your needed values
cdk bootstrap aws://ACCOUNT-NUMBER/REGION
# Install poetry (for managing Python dependencies)
pip install poetry
# Install poetry dependencies for the virtual environment
poetry install
################################################################################
# PART 3: Main CDK and Python commands (most used)
################################################################################
# Activate Python virtual environment with Poetry tool
poetry shell
# Run unit tests
poe test-unit
# Deploy commands
export DEPLOYMENT_ENVIRONMENT=dev
cdk synth
cdk deploy
################################################################################
# PART 4: Other CDK usefull commands
################################################################################
# Help
cdk --help
cdk deploy --help
# Lists the stacks in the app
cdk list
# Synthesizes and prints the CloudFormation template for the specified stack(s)
cdk synthesize
# Deploys the CDK Toolkit staging stack (necessary resources in AWS account)
cdk bootstrap
# Deploys the specified stack(s)
cdk deploy
# Destroys the specified stack(s)
cdk destroy
# Compares the specified stack with the deployed stack or a local CloudFormation template
cdk diff
# Displays metadata about the specified stack
cdk metadata
# Creates a new CDK project in the current directory from a specified template
cdk init
# Manages cached context values
cdk context
# Opens the CDK API reference in your browser
cdk docs
# Checks your CDK project for potential problems
cdk doctor