CI/CD automatic deployment from bitbucket to aws ec2 window Instance

0

Hi Team, I am Implementing pipeline in aws, for my hosted website in IIS server in N. verginia region. I am using Bitbucket as source control , I have creted there a pipeline with aws EC2 intance configuration. My code is uploaded to the s3 bucket in aws through Bitbucket. But the application is not being installed on the server. I got following error Below. The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available for deployment, or some instances in your deployment group are experiencing problems.

I am struggleing with above error since last 5 days . Error:screenshot from aws code deploy Bitbucket Error for aws

Any help is appriciated. Thank you!!

profile picture
asked 8 months ago687 views
4 Answers
0
Accepted Answer

Hi Riku, I have restarted the code deploy agent on ec2 instance after attaching IAM policy. But it gives same error.Please suggest. Thank You!!

profile picture
answered 8 months ago
0

Hello.

If you look at the CodeDeploy Agent log in Windows EC2, you can see more detailed errors.
For Windows, it is located in the following location.
https://docs.aws.amazon.com/codedeploy/latest/userguide/deployments-view-logs.html

C:\ProgramData\Amazon\CodeDeploy\log\codedeploy-agent-log.txt

A common problem is permission errors with IAM roles attached to EC2.
Does the EC2 IAM role have the correct policy attached?
GetObject and ListBucket policies must be attached to the EC2 IAM role so that it can access S3 for artifacts.
Attach the following IAM policy to the EC2 IAM role to grant access to S3.
https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonEC2RoleforAWSCodeDeploy.html

AmazonEC2RoleforAWSCodeDeploy
profile picture
EXPERT
answered 8 months ago
profile pictureAWS
EXPERT
reviewed 8 months ago
  • Hi , Thank you for your quick response. I have checked the log. It is giving following below error. 2023-09-11T00:00:17 INFO [codedeploy-agent(10972)]: Version file found in C:/ProgramData/Amazon/CodeDeploy/.version with agent version OFFICIAL_1.6.0.49_msi. 2023-09-11T00:00:17 ERROR [codedeploy-agent(10972)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Error polling for host commands: Aws::Errors::MissingCredentialsError - unable to sign request without credentials set - C:/Windows/TEMP/ocr6AE5.tmp/gemhome/gems/aws-sdk-core-3.121.1/lib/aws-sdk-core/plugins/signature_v4.rb:74:in `sign_request'

    I have serached the the issue on ggogle found some fix. I have added some policies to IAM role. But it won't worked. AmazonEC2RoleforAWSCodeDeploy AWS managed 2 AmazonS3FullAccess AWS managed 3 AmazonS3ReadOnlyAccess AWS managed 3 AmazonSSMManagedInstanceCore AWS managed 1 AWSCodeDeployDeployerAccess AWS managed 2 AWSCodeDeployFullAccess AWS managed 2 AWSCodeDeployRole AWS managed 2 CodeDeployDemo-EC2-Permissions

  • thank you for your reply. Try restarting the CodeDeploy Agent after attaching the IAM policy. https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-verify.html#codedeploy-agent-operations-verify-windows

  • Even if you try adding strong privileges such as Administrator or PowerUserAccess, does it not work? Also try restarting EC2. Also, I think you have set the access key in the URL settings below, but are there any problems with the IAM settings? https://support.atlassian.com/bitbucket-cloud/docs/deploy-to-aws-with-codedeploy/

0

Even if you try adding strong privileges such as Administrator or PowerUserAccess, does it not work?
Also try restarting EC2.
Also, I think you have set the access key in the URL settings below, but are there any problems with the IAM settings?
https://support.atlassian.com/bitbucket-cloud/docs/deploy-to-aws-with-codedeploy/

profile picture
EXPERT
answered 8 months ago
0

Hi , I am getting Permission error as below! Enter image description here Above screenshot is from log. I have tried following

  1. I have given permission as AWScodedploy role to IAM and s3 bucket aceess
  2. Also check if code deploy agent is running or not.
  3. Restartrd the instance when change anything in iam role.

I am badly stuck here. Please guide and help. Thank you in advance!!!

profile picture
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions