SSM Automation 更新AMI镜像

1、从AMI启动一个实例

2、检测安装ssm agent

3、更新软件包

4、停止实例

5、根据实例创建一个新的AMI镜像

6、终止实例

以上流程完全可以通过ssm 中 Automation 的 AWS-UpdateLinuxAmi 文档搞定。但是在运行过程中一直遇到权限问题(完全按照aws 文档操作配置)。

后经过google得以解决,整理如下:

1、配置完毕了实例role 和 ssm自动化服务role,但是运行中报如下错误

Automation Step Execution fails when it is launching the instance(s). Get Exception from RunInstances API of ec2 Service. 
Exception Message from RunInstances API: [You are not authorized to perform this operation.
Encoded authorization failure message: {{BIG NASTY BASE64 ERROR}} (Service: AmazonEC2; Status Code: 403; Error Code:
UnauthorizedOperation; Request ID: e7feb002-b375–4bfc-3bd4–633943b9e158)]. Please refer to Automation Service Troubleshooting Guide for more diagnosis details.

2、处理方法:把以下策略添加到 AutomationAssumeRole 角色中可以解决以上问题,我遇到的情况连第二步校验超时问题也同时被解决掉了。

{
    "Version": "2012-10-17",
    "Statement": [
        {
              "Sid": "GrantsAccessToIAMRoles",
              "Effect": "Allow",
              "Action": [
                 "iam:*"
               ],
               "Resource": [
                   "arn:aws:iam::AWS-ACCOUNT-NUMBER:role/*"
               ]
        }
    ]
}

猜你喜欢

转载自www.cnblogs.com/husbandmen/p/10566601.html