AWS Code deploy cannot reach instance service

0

I'm going to use ec2, s3, codedeploy to configure cicd through github Action

These are the settings.

This is Code deploy IAM Role AmazonEC2FullAccess ,AmazonS3FullAccess, AWSCodeDeployRole

this is EC2 IAM Role AmazonS3FullAccess, AWSCodeDeployRole, AmazonEC2RoleforAWSCodeDeploy, AWSCodeDeployFullAccess, AWSCodeDeployRoleForECS

This is User IAM Role User access was done using a local programming key AmazonEC2FuullAccess, AmazonS3FullAccess, AWSCodeDeployFullAccess, AWSCodeDeployRole, IAMFullAccess,PowerUserAccess

And I can access S3 through aws cli and download the zip file Just code deployment doesn't work When codedeploy is turned on, the following error occurs

2023-05-20 14:54:40 ERROR [codedeploy-agent(725)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Cannot reach InstanceService: Aws::CodeDeployCommand::Errors::AccessDeniedException - 2023-05-20 14:56:10 INFO [codedeploy-agent(725)]: Version file found in /opt/codedeploy-agent/.version with agent version OFFICIAL_1.3.2-1902_deb. 2023-05-20 14:56:10 INFO [codedeploy-agent(725)]: [Aws::CodeDeployCommand::Client 400 0.035239 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:ap-northeast-2:634327468890:instance/i-023d83ff3c7b4341e") Aws::CodeDeployCommand::Errors::AccessDeniedException

2023-05-20 14:56:10 ERROR [codedeploy-agent(725)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Cannot reach InstanceService: Aws::CodeDeployCommand::Errors::AccessDeniedException - 2023-05-20 14:57:40 INFO [codedeploy-agent(725)]: Version file found in /opt/codedeploy-agent/.version with agent version OFFICIAL_1.3.2-1902_deb. 2023-05-20 14:57:40 INFO [codedeploy-agent(725)]: [Aws::CodeDeployCommand::Client 400 0.032228 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:ap-northeast-2:634327468890:instance/i-023d83ff3c7b4341e") Aws::CodeDeployCommand::Errors::AccessDeniedException

2개 답변
2

You probably have AWS credential file stored somewhere in the instance, e.g, /root/.aws/credentials or /home/{user}/.aws/credentials. Remove this file and restart the CodeDeploy agent service e,g. systemctl restart codeploy-agent. I found the solution at https://stackoverflow.com/questions/37721601/aws-code-deploy-deployment-failed

답변함 일 년 전
  • Worked for me after following it.

  • I must use /root/.aws/credentials or /home/{user}/.aws/credentials because I want to upload logs to cloudwatch to other areas. How do I configure it?

0

I thought that CodeDeploy Agent was not getting the IAM information from the instance profile properly.
What happens if I restart EC2 itself?

profile picture
전문가
답변함 일 년 전
  • I've done it dozens of times, and nothing happens... I'm so sad

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠