Bravops is an abbreviation for 'Bravo Operations'.
This is the cdk repository of Bravo operations project. All cdk codes are written in typescript.
You can easily install the synthesize, deploy stacks to the cloud server and delete it using script using aws-cdk.
Let's enjoy cloud world ;-)
- Initialize automatically
- Install packages ( jq, pip3, aws, zip, docker, node modules )
- Unzip the resources ( lambda, application .. etc )
- Set the aws account profile
- Synthesize automatically
- Generate the template files of stacks
- Deploy automatically
- Deploy stacks to the AWS
- Destroy automatically
- Destroy stacks from the AWS
We need some package resources to build our infra. Currently available resources are as follows.
- lambda package
- application package
There are some rules for package resource files.
- All resource packages should be placed in the
./resources
folder. - All resource packages must be a zip file.
- File format: release_{project}{package}{git tag}.zip
- Example: release_{project}_lambda_v2021.01.0016.zip
The elements that should be included in each package are as follows.
-
Lambda
- release.txt : Package released information such as git tag
- functions : Folder containing the function zip files to be deployed
- layers : Folder containg the layer zip files to be deployed
-
Application
- release.txt : Package released information such as git tag
- application.jar : Application file
- Dockerfile : Dockerfile for creating docker images
Firstly, you should review and modify the configuration of the project.
See the configuration folder. The configuration folder path is ./zconfig
.
There are three configure files.
dev.json
: This is for the dev environment.stage.json
: This is for the stage environment.prod.json
: This is for the prod environment.
The below json is a sample configuration format.
The name of the profile must match with your profile and region of aws credentials(~/.aws/config or ~/.aws/credentials)
{
"account": {
"id": "123456789112",
"profile": "aws-bravo-dev",
"region": "ap-northeast-2"
},
"project": {
"name": "bravo",
"env": "dev",
"version": "v0.1.3",
"description": "The Dev aws infra of the Bravo project.",
"tags": [
{ "key": "", "value": "" },
{ "key": "", "value": "" },
{ "key": "", "value": "" }
],
"stacks": {
"core": [
"vpc",
"secrets",
"rds",
"rds-sub",
"cognito",
"nlb",
"..."
],
"service": [
"kinesis",
"sns",
"cloudwatch",
"s3",
"ecs",
"iot",
"api",
"..."
]
},
"debug": true
},
"api": {
"domain": ""
},
"rds": {
"name": "BRAVO_MAIN",
"port": "3306",
"username": "admin",
"tz": "Asia/Seoul",
"charset": "utf8mb4"
},
"sns": {
"firebase": {
"apikey": ""
}
},
"iot": {
"endpoint": ""
},
"acm": {
"apiCertificateArn": ""
},
"cloudwatch": {
"alarmSlackHookUrl": ""
},
"resources": {
"application": {
"path": "resources/docker",
"file": "release_bravo_application_v2021.01.0004.zip",
"out": "application"
},
"lambda": {
"path": "resources/lambda",
"file": "release_bravo_lambda_v2021.01.0016.zip",
"out": "lambda"
}
}
}
Please run ./scripts/initialize.sh { name of env }
script.
initialize.sh
: The script to initialize the project
It initializes the environment by setting the aws profile of the project.
The name of the aws profile that needs to be set is the value set in the project configuration file.
And It installs the necessary packages. The installed packages are as follows.
- Packages: jq, zip, pip3, aws-cli, cdk, docker, npm modules
- jq is a lightweight and flexible command-line JSON processor
- zip is a command-line to compresse one or more files or deirectories
- pip3 is the package installer for Python
- aws-cli is AWS command-line interface
- cdk is AWS cloud development kit
- docker is Open source software container platform
- node modules are npm packages needed by the project
Plus, If your environment is Window Subsystem Linux, there are things you have to do yourself.
- To do list
- Install docker desktop on your windows
- Start the docker desktop program
- Enable 'Expose daemon on tcp://localhost:2357 without TLS' options
Please run ./scripts/synthesize.sh { name of env }
script.
synthesize.sh
: This is the script to Synthesize the CDK App of the project.
It synthesize the CDK App of the project.
The cloudformation template files are generated to the out/{env}
folder automatically.
You can check the generated template files in that folder.
If you want to synthesize the specific stack, Please run -s { the name of stack }
option.
Please run ./scripts/deploy.sh { name of env }
script.
deploy.sh
: This is the script to deploy the CDK App of the project.
It deploy the CDK App of the project to the AWS.
If you want to deploy the specific stack, Please run -s { the name of stack }
option.
Please run ./scripts/destroy.sh { name of env }
script.
destroy.sh
: This is the script to destroy the CDK App of the project.
It destroy the CDK App of the project from the AWS.
If you want to destroy the specific stack, Please run -s { the name of stack }
option.