2013-05-29 17:42:21 |
Zane Bitter |
description |
Take the following template:
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Just a WaitCondition.",
"Parameters" : {
"KeyName" : {"Type" : "String", "Default": "mine" },
},
"Resources" : {
"WH" : {
"Type" : "AWS::CloudFormation::WaitConditionHandle"
},
"S1": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId" : "a",
"InstanceType" : "m1.large",
"KeyName" : { "Ref" : "KeyName" },
"UserData" : { "Fn::Join" : [ "", [ "#!/bin/bash -v\n",
"echo ",
{ "Ref" : "WH" },
"\n" ] ] }
}
},
"WC" : {
"Type" : "AWS::CloudFormation::WaitCondition",
"DependsOn": "S1",
"Properties" : {
"Handle" : {"Ref" : "WH"},
"Timeout" : "5"
}
},
"S2": {
"Type": "AWS::EC2::Instance",
"DependsOn": "WC",
"Metadata" : {
"test" : {"Fn::GetAtt": ["WC", "Data"]}
},
"Properties": {
"ImageId" : "a",
"InstanceType" : "m1.large",
"KeyName" : { "Ref" : "KeyName" },
"UserData" : "#!/bin/bash -v\n"
}
}
}
}
This implements what you'd imagine to be a fairly common pattern - it starts up one server, which posts some result of its software configuration to a WaitCondition, and said result is used in the Metadata of a second server.
This causes an exception, because it attempts to refresh the metadata of the second server (actually of all resources, but it is a NOP for everything except Instances and WaitConditionHandles) and this fails because the second server has not been created yet, and therefore is not stored in the database.
Note that the issue here is not that "S2" references "WC" in its metadata, simply that its creation has not started at the time that "S1" starts posting data to the WaitConditionHandle. |
Take the following template:
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Just a WaitCondition.",
"Parameters" : {
"KeyName" : {"Type" : "String", "Default": "mine" },
},
"Resources" : {
"WH" : {
"Type" : "AWS::CloudFormation::WaitConditionHandle"
},
"S1": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId" : "a",
"InstanceType" : "m1.large",
"KeyName" : { "Ref" : "KeyName" },
"UserData" : { "Fn::Join" : [ "", [ "#!/bin/bash -v\n",
"echo ",
{ "Ref" : "WH" },
"\n" ] ] }
}
},
"WC" : {
"Type" : "AWS::CloudFormation::WaitCondition",
"DependsOn": "S1",
"Properties" : {
"Handle" : {"Ref" : "WH"},
"Timeout" : "5"
}
},
"S2": {
"Type": "AWS::EC2::Instance",
"DependsOn": "WC",
"Metadata" : {
"test" : {"Fn::GetAtt": ["WC", "Data"]}
},
"Properties": {
"ImageId" : "a",
"InstanceType" : "m1.large",
"KeyName" : { "Ref" : "KeyName" },
"UserData" : "#!/bin/bash -v\n"
}
}
}
}
This implements what you'd imagine to be a fairly common pattern - it starts up one server, which posts some result of its software configuration to a WaitCondition, and said result is used in the Metadata of a second server.
Posting to the WaitConditionHandle causes an exception, because it attempts to refresh the metadata of the second server (actually of all resources, but it is a NOP for everything except Instances and WaitConditionHandles) and this fails because the second server has not been created yet, and therefore is not stored in the database.
Note that the issue here is not that "S2" references "WC" in its metadata, simply that its creation has not started at the time that "S1" starts posting data to the WaitConditionHandle. |
|