Skip to content

E1152: Image ID does not validate when using a Systems Manager Parameter (resolve:ssm:...) #339

Description

@IwoTens

Bug summary

Rule E1152 does not validate the template when an Image ID is referenced through a systems manager parameter

Version or commit

1.7.0-beta

Affected interface

CLI

Environment

No response

Validation engine

Not sure

Minimal CloudFormation template

Resources:
  LaunchTemplate:
    Type: AWS::EC2::LaunchTemplate
    Properties:
      LaunchTemplateData:
        ImageId: resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2023/recommended/image_id

Reproduction details

Actual Behavior:

Running cfn-validate with the given minimal cloudformation template results in the following output:

{
  "filePath": "./template.yaml",
  "status": "OK",
  "version": "1.7.0",
  "metadata": {
    "rulesEvaluated": 303,
    "resourcesScanned": 1,
    "counts": {
      "fatal": 0,
      "errors": 1,
      "warnings": 0,
      "informational": 0,
      "debug": 0
    },
    "suppressed": 0,
    "strict": false,
    "severityLevel": "INFO"
  },
  "performance": {
    "schemaInit": {
      "durationMs": 102.556875
    },
    "engineInit": {
      "durationMs": 52.460833
    },
    "modelBuild": {
      "durationMs": 0.106334
    },
    "schemaValidate": {
      "durationMs": 1.30725
    },
    "ruleEvaluation": {
      "durationMs": 105.574792
    },
    "diagnosticFinalize": {
      "durationMs": 0.016667
    },
    "validateTotal": {
      "durationMs": 107.021041
    }
  },
  "diagnostics": [
    {
      "ruleId": "E1152",
      "severity": "ERROR",
      "message": "'resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2023/recommended/image_id' does not match format 'AWS::EC2::Image.Id'",
      "source": "CFN_LINT",
      "entity": {
        "logicalId": "LaunchTemplate",
        "entityType": "Resource",
        "resourceType": "AWS::EC2::LaunchTemplate"
      },
      "propertyPath": "Properties.LaunchTemplateData.ImageId",
      "category": "Intrinsic Function",
      "startLine": 6,
      "startColumn": 9,
      "endLine": 6,
      "endColumn": 16,
      "ruleDescription": "Validate AMI id format",
      "phase": "SCHEMA",
      "context": {
        "actualValue": "resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2023/recommended/image_id"
      }
    }
  ]
}

Expected Behavior:
The template is valid, thus the validation should not fail.

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions