Antwort

1

Sie müssen den Befehl cfn-signal verwenden, um das Signal an die Wolkenbildung zu übergeben. Bitte überprüfen Sie die Dokumentation unter http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-signal.html

Ich habe Cloudformation Snippet, die cfn-Signal für die Weitergabe des Signals verwendet hinzugefügt.

Die Skripterstellung stellt sicher, dass die Cloud-Erstellung maximal 300 Sekunden auf die zu erstellende Instanz wartet, bevor ein Fehler in der Cloud-Erstellung gemeldet wird.

{ 
    "AWSTemplateFormatVersion": "2010-09-09", 
    "Resources": { 
    "EC2Instance": { 
     "Type": "AWS::EC2::Instance", 
     "Properties": { 
     "ImageId": "<AMI>", 
     "InstanceType": "<Instance Type>", 
     "KeyName": "<Key_pair>", 
     "Monitoring": "false", 
     "UserData": { 
      "Fn::Base64": { 
      "Fn::Join": [ 
       "", 
       [ 
       "#!/bin/bash -e\n", 
       "yum update -y aws-cfn-bootstrap\n", 
       "/opt/aws/bin/cfn-signal -e 0 -r \"Failed to create Instance\" ", 
       { 
        "Ref": "WaitHandle" 
       }, 
       "'\n" 
       ] 
      ] 
      } 
     } 
     } 
    }, 
    "WaitHandle": { 
     "Type": "AWS::CloudFormation::WaitConditionHandle" 
    }, 
    "WaitCondition": { 
     "Type": "AWS::CloudFormation::WaitCondition", 
     "DependsOn": "EC2Instance", 
     "Properties": { 
     "Handle": { 
      "Ref": "WaitHandle" 
     }, 
     "Timeout": "300" 
     } 
    } 
    } 
} 
Verwandte Themen