TO install requirements and run unit tests:
pip install -r requirements.txt
python -m unittest discover test
- Build the docker container
docker build . -t ecs-base
- Run the docker container
docker run -t ecs-base
This project uses Terraform and the AWS CLI to deploy the service to the BNC ECS Cluster. To have the CI/CD pipeline deploy a service which has be deployed using a fork of this project you can follow the instructions below.
By default Terraform will not create the required workspaces. Before setting up the deployment in the CI environment, ensure you have created all of the appropriate workspaces.
The default workspaces for BNC are:
- development
- production
To create the workspaces run the following commands:
cd deployment/terraform/ecs-service
terraform workspace new production
terraform workspace new development
- Fill in the following environment variables.
AWS_DEFAULT_REGION=
STATE_S3_BUCKET=
STATE_DYNAMODB_TABLE=
KEY=<The project key for the ECR repository>, e.g bnc/<team>/ecr/<service-name>
SERVICE_KEY=<The project key for ECS service>, e.g ecs/<service-name>
SPLUNK_URL=
- Encrypt the following global environment variables using the Travis-CI CLI.
DEPLOYMENT_ACCESS_KEY_ID=
DEPLOYMENT_SECRET_ACCESS_KEY=
KMS_KEY_ID=
ROLE_ARN=
OPERATIONS_ROLE_ARN=
- Encrypt the following environment variables for the development deployment:
TF_WORKSPACE=
SPLUNK_TOKEN=
-
cd deployment/terraform/ecr
-
Copy
backend.tfvars.example
tobackend.tfvars
. -
Fill out the
backend.tfvars
-
Run
terraform init "-backend-config=backend.tfvars"
. -
Copy
master.tfvars.example
tomaster.tfvars
. -
Fill in the
master.tfvars
with the correct values. -
Now the project is fully setup and you will have the ability to run terraform commands.
terraform plan "-var-file=master.tfvars"
-
cd deployment/terraform/ecs-service
-
Copy
backend.tfvars.example
tobackend.tfvars
. -
Fill out the
backend.tfvars
-
Run
terraform init "-backend-config=backend.tfvars"
. -
Copy
master.tfvars.example
tomaster.tfvars
. -
Fill in the
master.tfvars
with the correct values. -
Select the development work space
terraform workspace select development
-
Now the project is fully setup and you will have the ability to run terraform commands.
terraform plan "-var-file=master.tfvars"