Repository: aws-cloudformation/cfn-lint (Python)

Issue:
Nested mappings raise an error
```cfn-lint 0.3.1```

We use nested maps in our templates:

```yaml
Mappings:
  RegionAccountToAZ:
    ap-northeast-1:
      0123456789:
        - ap-northeast-1a
        - ap-northeast-1c
        - none
      9876543210:
        - ap-northeast-1a
        - ap-northeast-1b
        - ap-northeast-1c
```

We'd access this data using a construction like `!FindInMap [RegionAccountToAZ, !Ref 'AWS::Region', !Ref 'AWS::AccountId']`. However cfn-lint says:

```
E7001 Mapping RegionAccountToAZ has invalid property at 9876543210
test.cfn.yaml:3:5

E7001 Mapping RegionAccountToAZ has invalid property at 0123456789
test.cfn.yaml:4:7
```


Discussion:

Patch:
diff --git a/src/cfnlint/rules/mappings/Configuration.py b/src/cfnlint/rules/mappings/Configuration.py
index d05d495e80..9d77016571 100644
--- a/src/cfnlint/rules/mappings/Configuration.py
+++ b/src/cfnlint/rules/mappings/Configuration.py
@@ -14,6 +14,7 @@
   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 """
+import six
 from cfnlint import CloudFormationLintRule
 from cfnlint import RuleMatch
 
@@ -50,7 +51,9 @@ def match(self, cfn):
                             ))
                         else:
                             for secondkey in firstkeyobj:
-                                if isinstance(firstkeyobj[secondkey], (dict, list)):
+                                if not isinstance(
+                                        firstkeyobj[secondkey],
+                                        (six.string_types, list, six.integer_types)):
                                     message = 'Mapping {0} has invalid property at {1}'
                                     matches.append(RuleMatch(
                                         ['Mappings', mapname, firstkey, secondkey],


Test patch:
diff --git a/test/rules/mappings/test_configuration.py b/test/rules/mappings/test_configuration.py
index 61d7906f78..e68f345451 100644
--- a/test/rules/mappings/test_configuration.py
+++ b/test/rules/mappings/test_configuration.py
@@ -29,6 +29,10 @@ def test_file_positive(self):
         """Test Positive"""
         self.helper_file_positive()
 
+    def test_file_positive_configuration(self):
+        """Test Positive"""
+        self.helper_file_positive_template('templates/good/mappings/configuration.yaml')
+
     def test_file_negative(self):
         """Test failure"""
-        self.helper_file_negative('templates/bad/mappings/configuration.yaml', 4)
+        self.helper_file_negative('templates/bad/mappings/configuration.yaml', 3)
diff --git a/test/templates/good/mappings/configuration.yaml b/test/templates/good/mappings/configuration.yaml
new file mode 100644
index 0000000000..38db44be1a
--- /dev/null
+++ b/test/templates/good/mappings/configuration.yaml
@@ -0,0 +1,16 @@
+---
+AWSTemplateFormatVersion: "2010-09-09"
+Description: >
+  Test Mapping Configuration
+Mappings:
+  RegionAccountToAZ:
+    ap-northeast-1:
+      0123456789:
+        - ap-northeast-1a
+        - ap-northeast-1c
+        - none
+      9876543210:
+        - ap-northeast-1a
+        - ap-northeast-1b
+        - ap-northeast-1c
+Resources: {}