Skip to content

Instantly share code, notes, and snippets.

@PatMyron
Last active February 14, 2025 02:25
Show Gist options
  • Save PatMyron/c1940c37d2a6fea0fa950a107d485b81 to your computer and use it in GitHub Desktop.
Save PatMyron/c1940c37d2a6fea0fa950a107d485b81 to your computer and use it in GitHub Desktop.
Template format error: Unrecognized resource types
Parameters:
CreateResource:
Default: false
Type: String
AllowedValues: [true, false]
Conditions:
ShouldCreateResource:
!Equals [true, !Ref CreateResource]
Resources:
Macro:
Type: AWS::CloudFormation::Macro
Properties:
FunctionName: !Ref Function
Name: macro
Function:
Type: AWS::Lambda::Function
Properties:
Runtime: python3.7
Role: !GetAtt Role.Arn
Code:
ZipFile: |
def lambda_handler(event, context):
if event['params']['CreateResource'] == 'false':
return {'fragment': {'Type': 'AWS::CloudFormation::WaitConditionHandle'},
'requestId': event['requestId'],
'status': 'success'}
else:
return {'fragment': event['fragment'],
'requestId': event['requestId'],
'status': 'success'}
Handler: index.lambda_handler
Role:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: sts:AssumeRole
Principal:
Service: lambda.amazonaws.com
Stack:
Fn::Transform: # add these lines in another commit after the macro
Name: macro # add these lines in another commit after the macro
Parameters: # add these lines in another commit after the macro
CreateResource: !Ref CreateResource # add these lines in another commit after the macro
Type: AWS::AppStream::Stack
Condition: ShouldCreateResource
@PatMyron
Copy link
Author

PatMyron commented Jul 12, 2021

validate-template / get-template-summary / create-stack-set and create-stack / update-stack through the console throw:
Template format error: Unrecognized resource types: []

create-change-set --change-set-type IMPORT has similar console issues


https://code.amazon.com/packages/AWS21StackBuilderService/blobs/74ba401db270b8329b602a3218f0bb608a2e74f7/--/src/amzn/aws21/sbs/utils/ResourceTypeValidator.java#L22


Should not throw this error where we cannot evaluate conditions


Current workaround of adding transforms like Transform: AWS::Serverless-2016-10-31 to templates:

Transform: AWS::Serverless-2016-10-31 # https://i.amazon.com/CFN-7763

https://stackoverflow.com/q/48228751/cloudformation-conditional-template-validation/69591806#69591806

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