When the Linux disk drive is full, first we need to identify the reason for the drive overuse. Many times the drive is filled with one large log file, that can be identified and truncated.
To list the directory sizes under the current directory execute
du -sh *
To empty a file, overwrite it with nothing, so the process that writes into it still can access it.
cat /dev/null > ./MY_LARGE_LOG_FILE
When we free up the disk space, the server needs time to recover and do some housekeeping. The load average numbers show how busy the server was in the recent minutes. Check the load on the computer with
Error: EPERM: operation not permitted, rename ‘C:\Users\MY_USERNAME\.config\configstore\update-notifier-nodemon.json.3604946166’ -> ‘C:\Users\MY_USERNAME\.config\configstore\update-notifier-nodemon.json’
In case of this error rename the C:\Users\MY_USERNAME\.config\configstore\update-notifier-nodemon.json to update-notifier-nodemon.json.ORIGINAL to allow NPM to use the file name as the target of a rename operation.
If the script successfully created the CodeDeploy application the first deployment starts automatically
In the AWS console open the CodeDeploy page
Select the application name
On the Deployments tab select the deployment
Check the deployment status
In the ECS cluster
In the AWS console select the cluster and the service
Select the Deployments tab
CodeDeploy starts to launch a new, Replacement task
At this pint the prod and test listeners of the load balancer both point to the old task version
When the new task started 100% of the traffic still routed to the old version
The load balancer’s Test listener starts to route traffic to the new task behind target group “b”
When the deployment succeeded and none of the specified Hook Lambdas (if any) returned failure, the Test and Production traffic both are routed to the new task version
The old (blue) task stays active during the time span we specified in the “termination_wait_minutes” variable of the Python script. During that time we can click the Stop and roll back deployment button to restore the prior version of the task.
While the old (blue) task is still available the deployment is still “running”. To be able to start a new deployment we need to click the “Terminate original task set” button.
When the wait time is over, the old deployment terminates in the service
If you get the error message
AWS CodeDeploy does not have the permissions required to assume the role …
make sure you have used the correct role ARN from
Deployment fails with error code 404
If you deploy a Socket.IO server make sure you add 404 to the valid Success Codes in both Load Balancer target groups.
Copy the contents of the client/dist folder into the bucket. The webpack local test server deletes the contents of the dist folder, so you always have to copy the error.html file there before the upload to S3.
# Copy the assets to the dist directory
cp error.html dist/
# Upload to S3
aws s3 cp dist s3://MY_BUCKET_NAME --recursive
Test the static website
Navigate to the address you have copied from the Static website hosting page
Create an SSL certificate
Modern browsers display the “Not secure” message in the address line if the site is not accessed through HTTPS. To use HTTPS we need an SSL certificate.
Open the Certificate Manager and click the Request a certificate button
Select Request a public certificate
To use the certificate for www.mysite.com or api.mysite.com create the *.mysite.com wildcard certificate. The wildcard certificate does not work without the subdomain, to attach the certificate to mysite.com create a separate certificate for mysite.com.
Create a CloudFront Distribution
To be able to attach an SSL certificate to the URL we need a CloudFront Distribution in front of the S3 bucket.
Open the CloudFront console and click the Create Distribution button
Select the Web delivery method
Select the S3 bucket which contains the files of the static site
Enter the URL of your website into the Alternate Domain Names (CNAMES) field
Select the SSL certificate you have created above. Make sure you specify the entry point of the site (index.html) as the Default Root Object
To deploy the new version of a Docker container image and launch new tasks with the new version
Build and push the new Docker image
Build the new Docker container image
Push the new image to ECR (Elastic Container Registry)
Create a new revision of the ECS Task Definition
Open the ECS section of the AWS Console
On the Amazon ECS page click Clusters and select the cluster
On the Services tab click the Task Definition
On the Task Definition page click the Create new revision button
Scroll down to the Container Definitions section select the container definition
In the Image field update the Docker image version
Click the Update button at the bottom of the Container page
Click the Create button at the bottom of the Task Definition page
A new task definition revision has been created
Update the Service to use the new Task Definition revision
Go back to the Cluster
On the Services tab select the service
In the upper right corner click the Update button
In the Revision dropdown select the new Task Definition revision
At the bottom of the Configure service page click the Next step button. If you click the “Skip to review” button, the task definition revision is not updated in the service!!!
Select the CodeDeploy deployment
At the bottom of the Review page click the Update Service button
Click the service name to return to the service
Deregister the old Task Definition revision
If we don’t use the blue-green deployment with CodeDeploy, we need to manually deregister the old revision of the task definition to force the service to direct all traffic to the new task definition.
To tell the service to use only the new revision of the Task Definition deregister the old revision otherwise both versions will run side-by-side in the service
Return to the Task Definition
Select the old revision of the Task Definition and select Deregister in the drop-down
Click the Deregister button
Check the running tasks
On the Tasks tab of the cluster, only the new revision of the Task Definition should run. If there are open connections to the old revision, it stays in running state with the INACTIVE status until those connections are closed.
Update the Scheduled Tasks
If you have configured a scheduled task based on the task definition you need to update the task definition reference to specify the latest revision.
Select the cluster
Select the Scheduled Tasks tab
Select the scheduled task
Click the arrow next to the Target name and check the Task definition revision
To edit the Task definition revision click the Edit button in the upper right corner
In the Schedule targets section click the arrow next to the Target name. The revision will be auto-populated with the latest value.
Click the Update button at the bottom of the page to save the new value.
Click the View scheduled task button to check the revision
Click the arrow next to the Target name and check the revision.