0

我已经创建了成功部署所需的一切。我试图在没有在 Amazon 实例中配置 CodeDeploy 代理的情况下进行部署,并且部署 [显然] 失败了。不过设置好之后,就成功了。所以,我的问题是,我应该配置我手动使用的每个实例吗?如果部署组中有 100 个实例怎么办?我是否应该在已配置 CodeDeploy 代理工具的情况下创建 AMI?

编辑

我看过这个: 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 代理了?

编辑 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

4

1 回答 1

1

每个实例只需要在其上安装 CodeDeploy 代理。它不需要安装 AWS CLI。有关安装和操作的详细信息,请参阅AWS CodeDeploy 代理操作

您应该在 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 个实例怎么办?我是否应该使用已配置的 aws-cli 工具创建 AMI?

使用您的基本工具配置 AMI,或根据需要使用 CloudFormation 或 puppet 管理给定实例上的软件安装。同样,CodeDeploy 不需要 AWS CLI。仅需要最新版本的 CodeDeploy 代理。

于 2016-01-25T21:50:42.413 回答