- [Russ] When you sit down
to write an automated deployment,
it very, very rarely works first time.
When I'm doing this, I generally test
some deployment commands manually.
I get confident the deploy is going to work how I planned.
I start small, and gradually add to the build scripts.
That way, I can isolate debugging
down to just the changes I made in my small updates.
When I do hit an error in a CodeDeploy deployment,
where do I start with my debugging?
Number one, I can see all the deployment details
via the console.
I'm looking at a failed deployment in the console right now,
and I'm seeing the message:
"some instances in your deployment group
are experiencing problems."
I can further drill down
into the instance details down here,
and I see the deploy failed
at the very first event, ApplicationStop.
I'm thinking that I don't have the CodeDeploy agent running
on the instance.
We need the CodeDeploy agent to be installed in the instance
for any deployments to work.
Maybe you are installing this
with your user data scripts on your instances,
or maybe you use AWS Systems Manager to do this for you.
I'll include some links in the course readings
with details on how to install the CodeDeploy agent.
I've connected to the instance via Session Manager.
I can check the status of the CodeDeploy agent
with this command:
sudo service codedeploy-agent status.
And that is telling me the service cannot be found.
That's a sign I need to get the agent installed.
What other types of errors can occur in our deployments?
I have fixed my CodeDeploy agent on my instance,
I've re attempted the deployment,
and I see a failure.
Again, in the console,
I can see the details of the deployment.
If I view the instance details down here,
I'm being told:
"scripts/start_server run as root failed with exit code 5."
If I view more on this, there is the output of the script.
It looks like I have a typo in there.
CodeDeploy makes the log tail available to me
via the console and via the APIs.
What if all my scripts ran,
nothing returned an error back to CodeDeploy,
but there is something wrong in my deployment logic,
and I don't see my application working?
Now, I would look at the logs on the instance itself.
Again, in a Session Manager connection to my instance,
I can see the deployment log at this location:
(typing)
opt/codedeploy-agent/deployment-root/deployment-logs
and there is a codedeploy-agent-deployments.log.
At the very end here,
I can see the same error that I was seeing in the console.
I have a typo there in "service httpd start."
There is also a deployment archive on the instance
at this location.
It is in opt/codedeploy-agent/deployment-root.
In here is the ID of my deployment group ID,
(typing)
and under that is all of the deployment IDs
that have occurred on this instance.
Let's choose one of them.
And if I look here, I will see the deployment archive
that was downloaded to my instance,
and a scripts.log for this particular deploy.
The script logs are going to capture the output
of my commands in my deployment scripts,
and any logging I've included.
This should point me to some clues
of why my deployment isn't going to plan.
So, where are you going
to start your deployment detective work?
We can see a lot of information in the console.
Do you need some extra debugging details?
We can always retrieve CodeDeploy logs
from our deployment instances.