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
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!!!
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
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.
recommended file system mount options. The nofail option will allow this servetr to boot even if the volume is not availble. On Debian derivatives, including earlier than Ubuntu 16.04 nobootwait is also necessary
To test if the file entry is correct unmount the volume and use the /etc/fstab to mount it again
If there are no errors, the file should be correct.
When your website calls the Socket.IO backend API from another domain, the browser console displays the error message
Access to XMLHttpRequest at ‘http://…:3000/socket.io/?EIO=3&transport=polling&t=N7Y-Fot’ from origin ‘http://….com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
To enable Cross-origin resource sharing add the code to the top of your Socket.IO server.js file
const server = require('express')();
// require 'cors'
const cors = require('cors')
// Add CORS before any other routing
const http = require('http').createServer(server);
const io = require('socket.io')(http);
Before building the application install the cors package