Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error on run: Property validation failure: [Value of property {/Targets/0/Values} does not match type {Array}]

This CF is being created in YAML not JSON.

I am building Systems Manager Maintenance Windows, Targets and Tasks through Cloudformation.

When creating the stack, the Resources: MaintenanceWindow: section complete successfully. It's the next section (below) that is failing. Not sure about the last section as we never get there.

Here is the location for the full template: https://pastebin.com/DNEkLPGS

I have tried using validators and everything (YAML and the CloudFormation Validators) and everything comes back as good.

Here is the section giving errors:

Parameters:
  MaintenanceTargetName:
    Description: Maintenace Target Name (No Spaces)
    Type: String
  MaintenanceTargetDescription:
    Description: Sample - UAT Servers
    Type: String
    MaxLength: '128'
  MaintenanceTargetTarget:
    Description: Tag Key should equal 'AgentUpdate'
    Type: String
    Default: tag:AgentUpdate
  MaintenaneTargetKeyValue:
    Description: True or False
    Type: String
    Default: True
    AllowedValues:
      - True
      - False

Resources:
  MaintenanceWindowTarget:
    Type: 'AWS::SSM::MaintenanceWindowTarget'
    Properties:
      WindowId: !Ref MaintenanceWindow
      ResourceType: INSTANCE
      Targets:
        - Key: !Ref MaintenanceTargetTarget
          Values: !Ref MaintenaneTargetKeyValue
      Name: !Ref MaintenanceTargetName
      Description: !Ref MaintenanceTargetDescription

Running the template gives the following error:

MaintenanceWindowTarget | CREATE_FAILED | Property validation failure: [Value of property {/Targets/0/Values} does not match type {Array}]

like image 260
DC.Skells Avatar asked Oct 07 '19 17:10

DC.Skells


People also ask

How do you ensure that the Cloudformation template is valid and error free?

To check your template file for syntax errors, you can use the aws cloudformation validate-template command. The aws cloudformation validate-template command is designed to check only the syntax of your template.

What is parameter validation error?

The error occurs when the value of the child stack that's passed from the parent stack doesn't match the parameter type. The error also occurs when the parameter's resource doesn't exist in the account in that Region.

How do I validate aws Cloudformation template?

Validate template syntaxCreate your stack with AWS CloudFormation Designer. Validate your JSON syntax with a text editor, or a command line tool such as the AWS CLI template validator. Validate your YAML syntax with the aws cloudformation validate-template command.

What is aws :: NoValue?

AWS::NoValueRemoves the corresponding resource property when specified as a return value in the Fn::If intrinsic function. For example, you can use the AWS::NoValue parameter when you want to use a snapshot for an Amazon RDS DB instance only if a snapshot ID is provided.


1 Answers

Found the issue, it was a formatting problem:

Resources:
  MaintenanceWindowTarget:
    Type: 'AWS::SSM::MaintenanceWindowTarget'
    Properties:
      WindowId: !Ref MaintenanceWindow
      ResourceType: INSTANCE
      Targets:
        - Key: !Ref MaintenanceTargetTarget
          Values: !Ref MaintenaneTargetKeyValue
      Name: !Ref MaintenanceTargetName
      Description: !Ref MaintenanceTargetDescription

The issue lied in the Targets section:

      Targets:
        - Key: !Ref MaintenanceTargetTarget
          Values: !Ref MaintenaneTargetKeyValue

The above was incorrect. Below is the correction:

      Targets:
        - Key: !Ref MaintenanceTargetTarget
          Values: 
          - !Ref MaintenaneTargetKeyValue

Hope this helps others!!

like image 158
DC.Skells Avatar answered Oct 24 '22 08:10

DC.Skells