2016-08-04 10 views
0

とCloudFormationテンプレートは、私は以下のマッピングがリファレンスまたはトップレベルのFn :: FindInMap

"Mappings": { 
"TimeBasedAutoScale" : { 
    "days" : { 
    "weekend" : {"0":"off","1":"off","2":"off","3":"off","4":"off","5":"off","6":"off","7":"off","8":"off","9":"off","10":"off","11":"off","12":"off","13":"off","14":"off","15":"off","16":"off","17":"off","18":"off","19":"off","20":"off","21":"off","22":"off","23":"off"}, 
    "weekday1" : {"0":"off","1":"off","2":"on","3":"on","4":"on","5":"on","6":"on","7":"on","8":"on","9":"on","10":"on","11":"on","12":"on","13":"on","14":"on","15":"on","16":"on","17":"on","18":"on","19":"on","20":"on","21":"on","22":"off","23":"off"}, 
    "weekday2" : {"0":"off","1":"off","2":"off","3":"on","4":"on","5":"on","6":"on","7":"on","8":"on","9":"on","10":"on","11":"on","12":"on","13":"on","14":"on","15":"on","16":"on","17":"on","18":"on","19":"on","20":"on","21":"on","22":"off","23":"off"} 
    } 
}, 
"TimeBasedSchedule": { 
    "6AMTimeBasedSchedule" : { 
    "schedule" : { 
     "Monday" : { "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekday1"]}, 
     "Tuesday" : { "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekday1"]}, 
     "Wednesday" :{ "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekday1"]}, 
     "Thursday" : { "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekday1"]}, 
     "Friday" : { "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekday1"]}, 
     "Saturday" : { "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekend"]}, 
    "Sunday" : { "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekend"]} 
    } 
}, 
"7AMTimeBasedSchedule" : { 
    "schedule" : { 
    "Monday" : { "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekday1"]}, 
    "Tuesday" : { "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekday1"]}, 
    "Wednesday" :{ "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekday1"]}, 
    "Thursday" : { "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekday1"]}, 
    "Friday" : { "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekday1"]}, 
    "Saturday" : { "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekend"]}, 
    "Sunday" : { "Fn::FindInMap" : [ "TimeBasedAutoScale", "days", "weekend"]} 
    } 
}} 

しかし、検証が失敗した私のテンプレートで定義されているとlooking at the docs後、私は理由を見ることができます。マッピング関数は、3段キーを必要とし、値は文字列またはリストのみになります。

reference以上のマッピングで上記を行うにはどうしますか?

答えて

0

マルチレベルマッピングを実行するには、内包されたFn::FindInMapの組み込み関数をResourcesまたはOutputsセクションに直接適用します。

Launch Stack

{ 
    "Description": "Return 'on' or 'off' according to the provided schedule, hour of day, and day of week.", 
    "Mappings": { 
    "TimeBasedAutoScale": { 
     "weekend" : {"0":"off","1":"off","2":"off","3":"off","4":"off","5":"off","6":"off","7":"off","8":"off","9":"off","10":"off","11":"off","12":"off","13":"off","14":"off","15":"off","16":"off","17":"off","18":"off","19":"off","20":"off","21":"off","22":"off","23":"off"}, 
     "weekday1" : {"0":"off","1":"off","2":"on","3":"on","4":"on","5":"on","6":"on","7":"on","8":"on","9":"on","10":"on","11":"on","12":"on","13":"on","14":"on","15":"on","16":"on","17":"on","18":"on","19":"on","20":"on","21":"on","22":"off","23":"off"}, 
     "weekday2" : {"0":"off","1":"off","2":"off","3":"on","4":"on","5":"on","6":"on","7":"on","8":"on","9":"on","10":"on","11":"on","12":"on","13":"on","14":"on","15":"on","16":"on","17":"on","18":"on","19":"on","20":"on","21":"on","22":"off","23":"off"} 
    }, 
    "TimeBasedSchedule": { 
     "6AMTimeBasedSchedule": { 
     "Monday": "weekday1", 
     "Tuesday": "weekday1", 
     "Wednesday": "weekday1", 
     "Thursday": "weekday1", 
     "Friday": "weekday1", 
     "Saturday": "weekend", 
     "Sunday": "weekend" 
     }, 
     "7AMTimeBasedSchedule": { 
     "Monday": "weekday2", 
     "Tuesday": "weekday2", 
     "Wednesday": "weekday2", 
     "Thursday": "weekday2", 
     "Friday": "weekday2", 
     "Saturday": "weekend", 
     "Sunday": "weekend" 
     } 
    } 
    }, 
    "Parameters": { 
    "Schedule": { 
     "Description": "Selected schedule", 
     "Type": "String", 
     "AllowedValues" : [ "6AMTimeBasedSchedule", "7AMTimeBasedSchedule" ], 
     "Default": "6AMTimeBasedSchedule" 
    }, 
    "DayOfWeek": { 
     "Description": "Day of week", 
     "Type": "String", 
     "AllowedValues" : [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ], 
     "Default": "Monday" 
    }, 
    "HourOfDay": { 
     "Description": "Hour of Day", 
     "Type": "Number", 
     "MinValue": "0", 
     "MaxValue": "23", 
     "Default": "0" 
    } 
    }, 
    "Resources": { 
    "Dummy": { 
     "Type": "AWS::CloudFormation::WaitConditionHandle" 
    } 
    }, 
    "Outputs": { 
    "Result": { 
     "Value": { 
     "Fn::FindInMap": [ 
      "TimeBasedAutoScale", 
      {"Fn::FindInMap": ["TimeBasedSchedule", "6AMTimeBasedSchedule", {"Ref": "DayOfWeek"}]}, 
      {"Ref": "HourOfDay"} 
     ] 
     } 
    } 
    } 
} 
:ここ

はあなたの例の完全な作業バージョンです
関連する問題