1
votes

I'm trying to make an automated CI workflow from Bitbucket to aws EC2 instance using Jenkins hosted in a separate EC2 instance.

I created and configured everything needed (IAM roles, aws client and code deploy agent) as the following article describes:
https://pranavpshah.wordpress.com/configure-aws-codedeploy/

Btw, all the instances are based on ubuntu and running inside a private VPC, and I'm deploying a node.js application.

For instance, I can successfully create a .zip build in S3 bucket, every time I push to Bitbucket repo. But in Code Deploy dashboard, I get "Deployment Failed No hosts succeeded." error message.

enter image description here the status "In progress" takes more than 5 min, every time I start the process.

When the deployment process finished with the status failed, I checked /var/log/aws/codedeploy-agent/codedeploy-agent.log file, and here is what I got:

2015-12-04 17:17:36 INFO  [codedeploy-agent(28199)]: Stopping master 27971
2015-12-04 17:17:36 INFO  [codedeploy-agent(27971)]: master 27971: Received TERM - stopping children and shutting down
2015-12-04 17:17:36 INFO  [codedeploy-agent(27975)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller of master 27971: Received TERM - setting internal shutting down flag and possibly finishing last run
2015-12-04 17:17:55 INFO  [codedeploy-agent(27975)]: [Aws::CodeDeployCommand::Client 200 60.113784 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:us-west-2:219450671821:instance/i-348913ed")  

2015-12-04 17:17:56 INFO  [codedeploy-agent(27975)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller of master 27971: shutting down
2015-12-04 17:17:57 INFO  [codedeploy-agent(28219)]: master 28219: Spawned child 1/1
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: Registering Plugins: ["codedeploy"].
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: Loading plugin codedeploy from /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/register_plugin
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: Registered Plugins: #<Set: {InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller}>.
2015-12-04 17:17:57 INFO  [codedeploy-agent(28223)]: On Premises config file does not exist or not readable
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Configuring deploy control client: Region = "us-west-2"
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Deploy control endpoint override = nil
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Initializing Host Agent: Host Identifier = arn:aws:ec2:us-west-2:219450671821:instance/i-348913ed
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Validating CodeDeploy Plugin Configuration
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControlCertVerifier: Actual certificate subject is '/C=US/ST=Washington/L=Seattle/O=Amazon.com, Inc./CN=codedeploy-commands.us-west-2.amazonaws.com'
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControlCertVerifier: Actual certificate subject is '/C=US/ST=Washington/L=Seattle/O=Amazon.com, Inc./CN=codedeploy-commands.us-west-2.amazonaws.com'
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControlCertVerifier: Actual certificate subject is '/C=US/ST=Washington/L=Seattle/O=Amazon.com, Inc./CN=codedeploy-commands.us-west-2.amazonaws.com'
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: CodeDeploy Plugin Configuration is valid
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Calling PollHostCommand:
2015-12-04 17:17:58 INFO  [codedeploy-agent(28219)]: Started master 28219 with 1 children
2015-12-04 17:18:58 INFO  [codedeploy-agent(28223)]: [Aws::CodeDeployCommand::Client 200 60.534255 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:us-west-2:219450671821:instance/i-348913ed")  

Am I missing something in the configuration ?
Any help please?

2

2 Answers

0
votes
  1. I just checked the detailed information for the deployment Id "d-FEPBDKJMC", seems the instance id is "arn:aws:ec2:us-west-2:219450671821:instance/i-d796060e" instead of "arn:aws:ec2:us-west-2:219450671821:instance/i-348913ed" inside the host agent log that you pasted. So probably should check the log on the right instance.

  2. All the lifecycle events are skipped for the deployment, and I suspect the host agent is not pulling command at all. Since you mentioned that the instance is under a VPC, please make sure Codedeploy and S3 endpoints are whitelisted(We need to connect to these endpoints to do deployments). There is also a doc here about Codedeploy working with VPC, please click Security: https://aws.amazon.com/codedeploy/faqs/.

0
votes

Are you sure the instance has a ROLE to access S3? I missed that out and did not have the role attached to my instance to access S3.

See http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-create-iam-instance-profile.html#getting-started-create-ec2-role-console