Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E1011 error on Fn::FindInMap #3416

Closed
isuftin opened this issue Jun 26, 2024 · 4 comments · Fixed by #3419
Closed

E1011 error on Fn::FindInMap #3416

isuftin opened this issue Jun 26, 2024 · 4 comments · Fixed by #3419

Comments

@isuftin
Copy link

isuftin commented Jun 26, 2024

CloudFormation Lint Version

1.3.6

What operating system are you using?

MacOS, Alpine Linux

Describe the bug

cfn-lint on FindInMap returns E1011 'EnvironmentMapping' is not one of []

Expected behavior

No error

Reproduction template

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "EBS Volume",
  "Resources": {
    "EBS": {
      "Type": "AWS::EC2::Volume",
      "Properties": {
        "AutoEnableIO": false,
        "AvailabilityZone": { "Ref": "AvailabilityZone" },
        "Encrypted": true,
        "KmsKeyId": { "Fn::FindInMap": ["EnvironmentMapping", "kms", "key"] },
        "VolumeType": "st1",
        "Size": 512
      },
      "DeletionPolicy": "Snapshot",
      "UpdateReplacePolicy" : "Retain"
    }
  },
  "Mappings": {
    "EnvironmentMapping": {
      "Fn::Transform": {
        "Name": "AWS::Include",
        "Parameters": {
          "Location": {
            "Fn::Sub": "s3://my-bucket/snippets/${Environment}.json"
          }
        }
      }
    }
  },
  "Outputs": {
    "EBSID": {
      "Description": "Physical ID of EBS Volume",
      "Value": { "Ref": "EBS" }
    }
  },
  "Parameters": {
    "AvailabilityZone": {
      "Description": "Availability Zone for EBS volume",
      "Type": "String",
      "AllowedValues": ["us-west-2a", "us-west-2b", "us-west-2c"],
      "Default": "us-west-2a"
    },
    "Environment": {
      "Description": "Defines the environment that this stack lives in",
      "Type": "String",
      "AllowedValues": [
        "development",
        "test",
        "qa",
        "prod-internal",
        "management"
      ],
      "Default": "test"
    }
  }
}
@kddejong
Copy link
Contributor

I'll take a look into it. By quick a look the Fn::Transform is messing with the logic. We don't fully support Fn::Transform. Clearing up this issue may result in another error so need to think if we can handle a transform here.

@isuftin
Copy link
Author

isuftin commented Jun 26, 2024

@kddejong - Note that this was working in 1.3.4 so it looks like a regression happened >=1.3.5

@kddejong
Copy link
Contributor

I'm going to add some logic to handle Fn::Transform inside mappings. This will prevent the resolvers from failing and throwing the error you are seeing.

@kddejong
Copy link
Contributor

v0 version of these errors for reference. This should allow us to do a lot better than we were doing in v0. We can now reasonably handle Fn::Transforms inside of Mappings.

W1011 FindInMap first key "kms" doesn't exist in map "EnvironmentMapping" at Resources/EBS/Properties/KmsKeyId/Fn::FindInMap
local/issue/3416.json:11:65

E7001 Mapping EnvironmentMapping has invalid property at Parameters
local/issue/3416.json:23:11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants