Amazon Linux 2安装AWS CodeDeploy Agent失败求助
Looks like you ran into a classic "wrong executable" issue here—your ./install command is calling the system's GNU coreutils install tool instead of the actual AWS CodeDeploy installation script. That's why you're getting that "missing destination file operand" error, since the system install expects completely different arguments.
Why this happens
Most likely, your initial wget command failed to download the correct CodeDeploy script. If you used ${AWS::Region} outside of a CloudFormation template (like directly in an EC2 shell), that variable won't resolve to your actual AWS region. This means wget probably created an empty or corrupted install file, and when you tried to run it, the shell fell back to the system's install command in your PATH.
Step-by-Step Fix
Let's fix this by re-downloading the correct script and ensuring we're running the right one:
Clean up the broken/corrupted file first
rm -f ./installRe-download the CodeDeploy installation script with your actual AWS region
Replace<your-region>with your EC2 instance's region (e.g.,us-east-1,ap-southeast-1,eu-west-1):wget https://aws-codedeploy-<your-region>.s3.<your-region>.amazonaws.com/latest/installExample for N. Virginia region:
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/installMake the script executable
chmod +x ./installVerify you have the right script (optional but recommended)
Check the first few lines of the file to confirm it's the CodeDeploy Ruby script:head ./installYou should see something like
#!/usr/bin/env rubyat the top—this confirms it's not the systeminstalltool.Run the installation again
sudo ./install autoCheck if the agent is running
sudo service codedeploy-agent status
Quick Automation Tip
If you're running these commands in a script or automation, you can fetch the region dynamically from the EC2 instance metadata to avoid hardcoding:
REGION=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | cut -d'"' -f4) wget https://aws-codedeploy-${REGION}.s3.${REGION}.amazonaws.com/latest/install
This ensures you always download the correct script for your instance's region without manual input.
内容的提问来源于stack exchange,提问作者Christian Bongiorno

