문제

I'm using this CloudFormation script to create a Windows instance and install Web Deploy:

{
  "AWSTemplateFormatVersion" : "2010-09-09",

  "Description" : "Test.",

  "Resources" : {

    "InstanceSecurityGroup" : {
      "Type" : "AWS::EC2::SecurityGroup",
      "Properties" : {
        "GroupDescription" : "Enable RDP",
        "SecurityGroupIngress" : [
          {"IpProtocol" : "tcp", "FromPort" : "3389", "ToPort" : "3389", "CidrIp" : "0.0.0.0/0"}
        ]
      }
    },

    "WindowsServer": {
      "Type" : "AWS::EC2::Instance",
      "Metadata" : {
        "AWS::CloudFormation::Init" : {
          "config" : {
            "files" : {
              "c:\\Packages\\WebDeploy_amd64_en-US.msi" : {
                "source" : "http://download.microsoft.com/download/1/B/3/1B3F8377-CFE1-4B40-8402-AE1FC6A0A8C3/WebDeploy_amd64_en-US.msi"
              }
            }
          },
          "commands" : {
            "1-installwebdeploy" : {
              "command" : "msiexec.exe /i c:\\Packages\\WebDeploy_amd64_en-US.msi ADDLOCAL=ALL /qn /norestart"
            }
          }
        }
      },

      "Properties": {
        "InstanceType" : "m1.small",
        "ImageId" : "ami-bbf2e1cf",
        "SecurityGroups" : [ {"Ref" : "InstanceSecurityGroup"} ],
        "KeyName" : "POP",
        "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
            "<script>\n",

            "cfn-init.exe -v -s ", { "Ref" : "AWS::StackId" }, 
            " -r WindowsServer",
            " --region ", { "Ref" : "AWS::Region" }, "\n",

            "</script>"
        ]]}}
      }
    }
  }
}

The MSI package correctly downloads, but the command does not execute. In fact, the cfn-init.log states that no commands were specified:

2013-07-23 12:57:10,740 [DEBUG] CloudFormation client initialized with endpoint https://cloudformation.eu-west-1.amazonaws.com
2013-07-23 12:57:10,740 [DEBUG] Describing resource WindowsServer in stack ***
2013-07-23 12:57:14,079 [DEBUG] Creating Scheduled Task for cfn-init resume
2013-07-23 12:57:14,220 [DEBUG] Scheduled Task created
2013-07-23 12:57:14,328 [INFO] Running configSets: default
2013-07-23 12:57:14,328 [INFO] Running configSet default
2013-07-23 12:57:14,328 [INFO] Running config config
2013-07-23 12:57:14,328 [DEBUG] No packages specified
2013-07-23 12:57:14,328 [DEBUG] No groups specified
2013-07-23 12:57:14,328 [DEBUG] No users specified
2013-07-23 12:57:14,328 [DEBUG] No sources specified
2013-07-23 12:57:14,328 [DEBUG] Parent directory c:\Packages does not exist, creating
2013-07-23 12:57:14,328 [DEBUG] Writing content to c:\Packages\WebDeploy_amd64_en-US.msi
2013-07-23 12:57:14,328 [DEBUG] Retrieving contents from http://download.microsoft.com/download/1/B/3/1B3F8377-CFE1-4B40-8402-AE1FC6A0A8C3/WebDeploy_amd64_en-US.msi
2013-07-23 12:57:14,673 [DEBUG] No mode specified for c:\Packages\WebDeploy_amd64_en-US.msi
2013-07-23 12:57:14,673 [WARNING] Unsupported OS for setting owner/group: nt
2013-07-23 12:57:14,673 [DEBUG] No commands specified
2013-07-23 12:57:14,673 [DEBUG] No services specified
2013-07-23 12:57:14,673 [INFO] ConfigSets completed
2013-07-23 12:57:14,734 [DEBUG] Deleting Scheduled Task for cfn-init resume
2013-07-23 12:57:14,796 [DEBUG] Scheduled Task deleted

What exactly is going on here? Thanks in advance.

도움이 되었습니까?

해결책

Your commands block should be nested inside the config block, at the moment it is at the same level in the hierarchy.

    "AWS::CloudFormation::Init" : {
      "config" : {
        "files" : {
          "c:\\Packages\\WebDeploy_amd64_en-US.msi" : {
            "source" : "http://download.microsoft.com/download/1/B/3/1B3F8377-CFE1-4B40-8402-AE1FC6A0A8C3/WebDeploy_amd64_en-US.msi"
          }
        },
        "commands" : {
          "1-installwebdeploy" : {
            "command" : "msiexec.exe /i c:\\Packages\\WebDeploy_amd64_en-US.msi ADDLOCAL=ALL /qn /norestart"
          }
        }
      },
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top