Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 如何使用codedeploy将代码自动部署到ASG下新创建的EC2实例?_Amazon Web Services_Autoscaling_Aws Code Deploy - Fatal编程技术网

Amazon web services 如何使用codedeploy将代码自动部署到ASG下新创建的EC2实例?

Amazon web services 如何使用codedeploy将代码自动部署到ASG下新创建的EC2实例?,amazon-web-services,autoscaling,aws-code-deploy,Amazon Web Services,Autoscaling,Aws Code Deploy,我在ASG下有2个EC2实例。我使用设置为使用自动缩放的DeploymentGroup1在codeDeploy中创建了Application1 我面临的问题是,当设置新的EC2实例时,codedeploy不会创建新的部署,代码也不会推送到实例。看起来连日志都看不出来发生了什么 当我为我的自动缩放组列出钩子时,我确实看到了它们: $ aws autoscaling describe-lifecycle-hooks --auto-scaling-group-name SAND-web-ASG {

我在ASG下有2个EC2实例。我使用设置为使用自动缩放的DeploymentGroup1在codeDeploy中创建了Application1

我面临的问题是,当设置新的EC2实例时,codedeploy不会创建新的部署,代码也不会推送到实例。看起来连日志都看不出来发生了什么

当我为我的自动缩放组列出钩子时,我确实看到了它们:

$ aws autoscaling describe-lifecycle-hooks --auto-scaling-group-name SAND-web-ASG 
{
    "LifecycleHooks": [
        {
            "GlobalTimeout": 60000,
            "HeartbeatTimeout": 600,
            "AutoScalingGroupName": "SAND-web-ASG",
            "LifecycleHookName": "CodeDeploy-managed-automatic-launch-deployment-hook-DeployToNewEC2underASG-...",
            "NotificationMetadata": "....",
            "DefaultResult": "ABANDON",
            "NotificationTargetARN": "arn:aws:sqs:us-west-1:blabla:blahh-us-west-1-prod-default-autoscaling-lifecycle-hook",
            "LifecycleTransition": "autoscaling:EC2_INSTANCE_LAUNCHING"
        }
    ]
}
这里有什么遗漏或错误吗??这些不是自定义的,而是由codedeploy创建的

我遵循了,所有内容都已创建,但由于某些原因,在创建新实例时,codedeploy不会创建新部署。。我有点迷路了为什么

我的服务角色有两个IAM策略:

1-来自amazon AwscodePloyrole的默认值

2-具有以下权限的codePipelinePolicy(自定义):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "autoscaling:CompleteLifecycleAction",
        "autoscaling:DeleteLifecycleHook",
        "autoscaling:DescribeAutoScalingGroups",
        "autoscaling:DescribeLifecycleHooks",
        "autoscaling:PutLifecycleHook",
        "autoscaling:RecordLifecycleActionHeartbeat",
        "autoscaling:CreateAutoScalingGroup",
        "autoscaling:UpdateAutoScalingGroup",
        "autoscaling:EnableMetricsCollection",
        "autoscaling:DescribeAutoScalingGroups",
        "autoscaling:DescribePolicies",
        "autoscaling:DescribeScheduledActions",
        "autoscaling:DescribeNotificationConfigurations",
        "autoscaling:DescribeLifecycleHooks",
        "autoscaling:SuspendProcesses",
        "autoscaling:ResumeProcesses",
        "autoscaling:AttachLoadBalancers",
        "autoscaling:PutScalingPolicy",
        "autoscaling:PutScheduledUpdateGroupAction",
        "autoscaling:PutNotificationConfiguration",
        "autoscaling:PutLifecycleHook",
        "autoscaling:DescribeScalingActivities",
        "autoscaling:DeleteAutoScalingGroup",
        "ec2:DescribeInstances",
        "ec2:DescribeInstanceStatus",
        "ec2:TerminateInstances",
        "tag:GetTags",
        "tag:GetResources",
        "sns:Publish",
        "cloudwatch:DescribeAlarms",
        "elasticloadbalancing:DescribeLoadBalancers",
        "elasticloadbalancing:DescribeInstanceHealth",
        "elasticloadbalancing:RegisterInstancesWithLoadBalancer",
        "elasticloadbalancing:DeregisterInstancesFromLoadBalancer"
      ],
      "Resource": "*"
    }
  ]
}
我是错过了什么,还是有什么错(愚蠢的错误)我没有看到

非常感谢你的建议。 非常感谢。
Ernest

根据您的描述,我没有看到您提到已成功部署到应用程序。在扩展过程中,CodeDeploy将尝试部署应用程序的目标版本,但如果没有找到,则它将根本不会发布部署,这将导致您看到的问题。您应该执行部署以更新应用程序的目标版本,然后尝试放大并查看这是否解决了问题。

这些EC2实例上是否安装并运行了CodeDeploy代理?如果不是,就必须这样做。如果是,请检查CodeDeploy代理的日志(在/opt/CodeDeploy agent/deployment root/deployment logs中)。是的,代理已安装。
它是Amazon Linux操作系统,日志位于/var/log/aws/CodeDeploy agent/CodeDeploy-agent.log下
并显示
2017-07-19 15:17:13信息[CodeDeploy agent(3534)]:在/opt/codedeploy agent/.Version中找到版本文件。2017-07-19 15:18:13信息[codedeploy agent(3534)]:[Aws::CodeDeployCommand::Client 200 60.290274 0重试]轮询\u主机\u命令(主机标识符:“arn:Aws:ec2:us-west-1::instance/i-”)2017-07-19 15:18:14信息[codedeploy agent(3534)]:在/opt/codedeploy agent/版本中找到版本文件。
谢谢如果您还没有,查看疑难解答指南()。问题是缺少权限。正确设置IAM策略后,一切都开始工作。是否有人成功编写了创建codedeploy部署的lambda函数?我在AWS上发过帖子,但这里的人似乎要快得多。提前谢谢。