Question:
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
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}]
Answer:
Found the issue, it was a formatting problem:
1 2 3 4 5 6 7 8 9 10 11 12 |
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:
1 2 3 4 |
Targets: - Key: !Ref MaintenanceTargetTarget Values: !Ref MaintenaneTargetKeyValue |
The above was incorrect. Below is the correction:
1 2 3 4 5 |
Targets: - Key: !Ref MaintenanceTargetTarget Values: - !Ref MaintenaneTargetKeyValue |
Hope this helps others!!