2017-09-15 15 views
0

Cloudformation初始化配置文件我使用AWS Cloudformation腳本,彈出一個自動縮放EC2實例 - 下面不寫文件

"GatewayLabAutoScalingGroup": { 
    "Metadata": { 
    "AWS::CloudFormation::Init": { 
     "config": { 
     "commands": { 
      "a_install_pip": { 
      "command": "pip install requests boto3" 
      }, 
      "c_restart_cron": { 
      "command": "service crond restart" 
      }, 
      "d_restart_cfn_hup": { 
      "command": "service cfn-hup restart" 
      } 
     }, 
     "files": { 
      "/etc/cfn/cfn-hup.conf": { 
      "content": { 
       "Fn::Join": [ 
       "", 
       [ 
        "[main]\nstack=", 
        { 
        "Ref": "AWS::StackName" 
        }, 
        "\nregion=", 
        { 
        "Ref": "AWS::Region" 
        }, 
        "\nverbose=true\ninterval=1\n" 
       ] 
       ] 
      }, 
      "group": "root", 
      "mode": "000644", 
      "owner": "root" 
      }, 
      "/usr/local/sbin/join_ad_script.sh": { 
      "content": { 
       "Fn::Join": [ 
       "", 
       [ 
        "sudo yum -y update\nsudo yum -y install sssd realmd krb5-workstation\nsudo realm leave\n\nDOMAIN=\"", 
        { 
        "Ref": "SimpleADDomain" 
        }, 
        "\"\n\ncat <<EOF > /etc/resolv.conf\nnameserver ", 
        { 
        "Fn::Select": [ 
         0, 
         { 
         "Fn::GetAtt": [ 
          "WorkspacesSimplead", 
          "DnsIpAddresses" 
         ] 
         } 
        ] 
        }, 
        "\nnameserver ", 
        { 
        "Fn::Select": [ 
         1, 
         { 
         "Fn::GetAtt": [ 
          "WorkspacesSimplead", 
          "DnsIpAddresses" 
         ] 
         } 
        ] 
        }, 
        "\nEOF\n\n# empty all current sssd cache\nsss_cache -E\n\necho ", 
        { 
        "Ref": "SimpleADPassword" 
        }, 
        " | sudo realm join -U [email protected]${DOMAIN^^} ${DOMAIN^^} --verbose\nsudo sed -re 's/^(PasswordAuthentication)([[:space:]]+)no/\\1\\2yes/' -i.`date -I` /etc/ssh/sshd_config\necho \"enumerate=true\" >> /etc/sssd/sssd.conf\nsudo service sssd restart\nsudo service sshd restart\n\n# empty all current sssd cache\nsss_cache -E\n" 
       ] 
       ] 
      }, 
      "group": "root", 
      "mode": "000755", 
      "owner": "root" 
      } 
     } 
     } 
    } 
    }, 
    "Properties": { 
    "AvailabilityZones": [ 
     { 
     "Fn::Select": [ 
      0, 
      { 
      "Fn::GetAZs": "" 
      } 
     ] 
     } 
    ], 
    "HealthCheckGracePeriod": 300, 
    "HealthCheckType": "EC2", 
    "LaunchConfigurationName": { 
     "Ref": "GatewayLabLaunchConfiguration" 
    }, 
    "LoadBalancerNames": [ 

    ], 
    "MaxSize": 2, 
    "MinSize": 1, 
    "Tags": [ 
     { 
     "Key": "Name", 
     "PropagateAtLaunch": true, 
     "Value": "hub-autoscaling" 
     } 
     } 
    ], 
    "VPCZoneIdentifier": [ 
     { 
     "Ref": "EC2SubnetSubnet1" 
     } 
    ] 
    }, 
    "Type": "AWS::AutoScaling::AutoScalingGroup", 
    "UpdatePolicy": { 
    "AutoScalingRollingUpdate": { 
     "MaxBatchSize": 1, 
     "MinInstancesInService": 1, 
     "PauseTime": "PT60S" 
    } 
    } 
} 

這些文件不會在該實例 實例寫入提供的示例代碼在私人VPC 快到了,我們已經在8080端口上

配置的代理時,該實例連接到NAT網關不使用代理

我有80端口工作正常,22 & 443開闢了

+0

你檢查過'/無功/日誌/雲的init-output.log'文件在實例?這將是理解爲什麼不能將文件放置在實例上的好地方。 – asdf

+0

謝謝@asdf我已經做到了; cfn正在使用169.254.169.254來查詢元數據,它正在失敗;該實例位於代理的後面; 我在/etc/profile.d上創建了proxy.sh,其中http/ftp代理變量導出到環境中 還有一些問題,我很難解決它們 – DWGuru

回答

0

的用戶數據報表最初運行 隨後,他們撥打CFN-init腳本

有腳本中的一些錯誤,他們從來沒有完成;作爲上述是我背後的代理

獲取代理配置實例中作爲的UserData的一部分的問題之一幫助