aws / aws-codedeploy-agent

Host Agent for AWS CodeDeploy
https://aws.amazon.com/codedeploy
Apache License 2.0
329 stars 187 forks source link

Agent Install erroneously reports Amazon EC2 instances are not supported. #83

Closed chriskinsman closed 6 years ago

chriskinsman commented 7 years ago

I am installing CodeDeploy agent using:

aws deploy install --config-file codedeploy.onpremises.yml --region us-west-2

This is on a VPS machine at a small hosting provider we are considering to place our service closer to some end users. When running the above line it comes back and says:

Amazon EC2 instances are not supported.

What is it checking that makes it think this is an EC2 instance? The provider swears it is not.

Thanks,

Chris

ambareesha commented 7 years ago

Hi,

Can you please check what gets returned on the instance when the following commands are run?-

curl http://169.254.169.254/latest/meta-data curl http://169.254.169.254/latest/meta-data/mac

We expect the first meta-data curl command to fail and if it doesn't, it considers the host an EC2Instance.

chriskinsman commented 7 years ago

The first one does not fail it returns:

nstance-id mac local-ipv4 public-ipv4 network_config/content_path hostname SUBID ipv6-addr ipv6-prefix

The second returns: 56:00:00:3e:cc:8f

ambareesha commented 7 years ago

That does look like ec2 instance metadata. Refer to http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html

chriskinsman commented 7 years ago

However it isn't running on EC2. It is a provider Vultr that happens to have a very similar metadata service that they run to support cloud-init on ubuntu.

ambareesha commented 7 years ago

Ah, I see...

gaohan137 commented 7 years ago

Hi there, I just tried to register an EC2 instance and it went through. Can you verify that the onpremises config file has required fields and correct content?

chriskinsman commented 7 years ago

There was a valid on premises config.

It was generated with: aws deploy register --instance-name $HOSTNAME --tags Key=location,Value=vultr --region us-west-2

I kept that line and am now copying that file to /etc/codedeploy-agent/conf and everything works.

Calling:

aws deploy install --config-file codedeploy.onpremises.yml --region us-west-2

is what was causing the issue. Is that the line you wanted me to test again?

ambareesha commented 7 years ago

Was your problem solved? If not, can you try this workaround for now: sudo iptables -A OUTPUT -d 169.254.169.254 -j REJECT aws deploy install --config-file codedeploy.onpremises.yml --region us-west-2 sudo iptables -D OUTPUT -d 169.254.169.254 -j REJECT

Let us know if this works for you.

chriskinsman commented 7 years ago

I figured a way around. I suspect however you should have a command line flag to disable this check. The iptables workaround is fairly ugly