2016-01-25 44 views
0

我已經創建了成功部署所需的全部內容。 我試圖在沒有在Amazon實例中配置CodeDeploy代理的情況下進行部署,部署[顯然]失敗。 雖然設置它,但成功。 所以,我的問題是,我應該配置手動使用的每個實例嗎? 如果我在部署組中有100個實例,該怎麼辦? 我應該使用已配置的CodeDeploy代理工具創建AMI嗎?使用IAM用戶憑據爲CodeDeploy設置Amazon Linux實例

編輯

我曾經看過這樣的: https://www.youtube.com/watch?v=qZa5JXmsWZs

與此: https://github.com/andrewpuch/code_deploy_example

和閱讀: http://blogs.aws.amazon.com/application-management/post/Tx33XKAKURCCW83/Automatically-Deploy-from-GitHub-Using-AWS-CodeDeploy

我只是不明白,爲什麼我必須與IAM配置信任該實例。難道它不應該從我發起的角色中獲得信任嗎? 我不是aws角色和策略方面的專家,但是從CD文檔來看,這就是我所理解的。 有沒有辦法讓IAM用戶訪問實例,所以我不必設置CD代理?

EDIT 2

我認爲這個帖子樣的答案:http://adndevblog.typepad.com/cloud_and_mobile/2015/04/practice-of-devops-with-aws-codedeploy-part-1.html

But as you can see, I launched multiple instances but I only installed CodeDeploy agent on one instance, what about others? Do I have to repeat myself and login to them and install them separately? It is OK since I just have 2 or 3. But what if I have handers or even thousand of instances? Actually there are different solutions for this. One of them is, I setup all environment on one instances and create an AMI from it. When I launch my working instance, I will create instance from the one I’ve already configured instead of the AWS default ones. Some other solutions are available

+1

你是說因爲某種原因將IAM角色分配給EC2實例不起作用? –

+0

@Rodrigo M:我認爲我誤解了CD代理的aws-cli。真的很抱歉混淆。我將編輯我的問題。 –

+0

@Mark B:如果將IAM角色分配給EC2實例意味着我不必配置CodeDeploy代理,那麼是的。據我瞭解,我創造了2個角色,但我對他們的用法和必要性感到困惑。 –

回答

1

每個實例只需要在其上安裝代理CodeDeploy。它不需要安裝AWS CLI。有關安裝和操作的詳細信息,請參閱AWS CodeDeploy Agent Operations

您應該在IAM中創建一個實例配置文件/角色,該配置文件/角色將授予任何實例通過CodeDeploy服務接受代碼部署的正確權限。

創建一個名爲ApplicationServer的角色。爲此角色添加以下策略。這是假設你正在使用S3爲您的修改:

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
     { 
      "Effect": "Allow", 
      "Action": [ 
       "s3:Get*", 
       "s3:List*" 
      ], 
      "Resource": [ 
       "arn:aws:s3:::codedeploy-example-com/*" 
      ] 
     }, 
     { 
      "Sid": "Stmt1414002531000", 
      "Effect": "Allow", 
      "Action": [ 
       "cloudwatch:PutMetricData" 
      ], 
      "Resource": [ 
       "*" 
      ] 
     }, 
     { 
      "Sid": "Stmt1414002720000", 
      "Effect": "Allow", 
      "Action": [ 
       "logs:CreateLogGroup", 
       "logs:CreateLogStream", 
       "logs:DescribeLogGroups", 
       "logs:DescribeLogStreams", 
       "logs:PutLogEvents" 
      ], 
      "Resource": [ 
       "*" 
      ] 
     } 
    ] 
} 

爲了您的具體問題:

所以,我的問題是,我應該配置每一個我手動使用 實例?

如果我在部署組中有100個實例,該怎麼辦?我應該創建 AMI並配置了aws-cli工具嗎?

使用您的基本工具配置AMI,或根據需要使用CloudFormation或puppet管理給定實例上的軟件安裝。 CodeDeploy不再需要AWS CLI。只需要最新版本的CodeDeploy代理。

相關問題